-
Notifications
You must be signed in to change notification settings - Fork 838
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
Parser priority is required for interoperability #1114
Comments
On first glance, I don't see why the list of BeaconParsers couldn't be maintained in an ArrayList. It seems like that is the simplest solution to give you what you are looking for. If this were the case, you could clear the list of parsers, and re-add them in the desired order. |
yes, an arraylist with the same order as the one from BeaconManager would be perfect |
Is this something that could be implemented in a new release or does this break compatibility with other features? |
I think it is safe to make this change as there is no API contract for the order of evaluation -- right not it is indeterminate based on the implementation of Set inside the JVM, which is also subject to change. I also think it is very unlikely this will affect the vast majority of apps which use common beacon parsers for which there is not any overlap between any two. |
AltBeacon is meant to be an 'open' interoperable standard. I have a use case where I have a layout for an alternative beacon that has similarities with AltBeacon but adds additional features. I still want to detect AltBeacon's, but I want to give my parser a priority for trying to find variants on AltBeacon.
To clarify: I have the AltBeacon parser and my own parser. My own parser will detect a subset of beacons detected by the AltBeacon parser
Expected behavior
I originally expected the parser priority to depend on the order on which it was added to the
BeaconManager
, so I cleared thegetBeaconParsers
to remove the default AltBeacon parser. I added my own parser and added the AltBeacon parser again.https://github.com/AltBeacon/android-beacon-library/blob/master/lib/src/main/java/org/altbeacon/beacon/BeaconManager.java#L336-L346
(I would do a
.clear()
on the list to remove AltBeacon)Actual behavior
Due to the HashSet
android-beacon-library/lib/src/main/java/org/altbeacon/beacon/service/ScanHelper.java
Line 75 in db4622c
the order is not determined
If a beacon is parsed by "a" parser:
android-beacon-library/lib/src/main/java/org/altbeacon/beacon/service/ScanHelper.java
Lines 436 to 442 in db4622c
I can manage to get the parser working by not 'readding' the AltBeacon parser. However, I still want to detect AltBeacons that are not a subset of my own parser.
Android Beacon Library version
2.19.4
I have tried the beta with the same result.
Possible Fix
Add a priority to the beacon parser or maintain priority based on its order in the beacon manager.
The text was updated successfully, but these errors were encountered: