Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Beacon data copy #630

Merged
merged 6 commits into from
Dec 16, 2017
Merged

Improve Beacon data copy #630

merged 6 commits into from
Dec 16, 2017

Conversation

cupakromer
Copy link
Contributor

This is a follow up to #629 where it was noticed that some of the internal Beacon data fields were not being copied through parceling / constructors as expected.

This fixes a minor issue where the running average is not set after
restoring a beacon from a parcel. Looking at the history it seems that
the running average was an internal detail until #479 where support was
added for running the service in a separate process.

Part of the reason this needs to be included is that on Android 8.0 the
running average _is_ restored and available for access. The reason the
behavior is different across Android versions is in the way a service
intent versus local notification handles the data `Bundle` (i.e. which
[`Callback`](https://github.com/AltBeacon/android-beacon-library/blob/2.12.3/src/main/java/org/altbeacon/beacon/service/Callback.java#L58-L86)
branch runs). Explicitly setting the `BeaconManager` to use scheduled
scan jobs, forcing the first conditional code path using local
notifications, allows the running average to be available on older
versions.
It's unclear why `mManufacturer` wasn't included with the copy
constructor originally. However, as it's an internal field which is also
included in the serialization and parceling it probably should be copied
here too.

The `mMultiFrameBeacon` field was added later to provide better support
for beacons with extra data packets (#387). It's likely this was just
overlooked as most of the "copying" of beacons occurred through
parceling at the time.
It's unclear from the history why only some of the fields are part of
the `AltBeacon` constructor. When initially implemented the constructor
omitted copying `mRunningAverageRssi` and `mManufacturer`. Since then
several additional data fields were added which are also not in the
`AltBeacon` constructor:

  - `mExtraDataFields`
  - `mServiceUuid`
  - `mBluetoothName`
  - `mParserIdentifier`
  - `mMultiFrameBeacon`

The only real change in this subclass seems to be the additional custom
getter `getMfgReserved`. Based on the fact that the parceling logic and
the builder all delegate to `Beacon` it seems reasonable that the
general intended logic was to wrap the parent class.

This fixes the two constructors so that all setup is based on the
`Beacon` implementation. This ensures that any changes in `Beacon` are
reflected by `AltBeacon` as well.
@davidgyoung davidgyoung merged commit f221213 into master Dec 16, 2017
@cupakromer cupakromer deleted the improve-data-copy branch December 18, 2017 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants