question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Background Scans on Android9 Samsung Devices

See original GitHub issue

Hello and first of all, thank you all very much for this library.

Expected behavior

I use a foreground service for scanning for beacons, with a notification. I am using BLE Beacons as a Geofence. Fortunately I have many devices to test. The application works perfectly fine with Pixel3 (Android Q), Xiaomi Mi9SE (Android P), Oneplus 7 (Android P), Xiaomi Pocophone F1 (Android P), Motorola G6 (Android O).

Actual behavior

The beacon scan on Samsung Galaxy S10 and Galaxy Note 10 works fine if the screen is on. However the scan stops immediately if I turn the screen off, only to resume if it turns on again, even if the device is locked. Those two are the only phones where I see this behaviour.

Steps to reproduce this behavior

The same problem occurs with the beacon reference application. So by uncommenting the code for the foregroundservice, you can reproduce this issue using a Galaxy S10 or Note 10 and trying to turn the screen off - the phone won’t receive beacons any more.

setDebug(true) shows the following when in background:

D/IntentHandler: got ranging data D/CycledLeScanner: Waiting to stop scan cycle for another 97 milliseconds D/CycledLeScanner: Done with scan cycle D/ScanHelper: Beacon simulator not enabled D/ScanHelper: Calling ranging callback D/Callback: attempting callback via local broadcast intent: org.altbeacon.beacon.range_notification D/CycledLeScanner: Not stopping scanning. Device capable of multiple indistinct detections per scan. starting a new scan cycle We are already scanning and have been for 54231 millis D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds Scan started

Mobile device model and OS version

Test device is a Samsung Galaxy Note 10, Android 9.

Android Beacon Library version

Latest, 2.16.3

I highly appreciate any help. Thank you in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davidgyoungcommented, Jul 9, 2021

Yeah, I originally had the same thought about the runtime exception. The problem is that an app might come across an beacon with a non-standard manufacturer id in the wild. This would often cause unexpected crashes for end users after app release, which would be awful. This could often happen even if the developer never saw such a crash 😦

I think your other suggestions are good. The trick is balancing any change vs:

  1. Keeping the API simple for the 99% use case (iBeacon only always Apple manufacturer id of 0x004c)
  2. Backward compatibility of the API to prevent a breaking change
1reaction
davidgyoungcommented, Jul 9, 2021

Radius Networks is the company that invented Altbeacon, so their Bluetooth SIG assigned company ID of 0x118 is usually what is put in AltBeacon manufacturer advertisement headers. This library was not originally designed to require or enforce a specific manufacturer Id. In most cases any manufacturer id is allowed.

But when BLE hardware scan filters are used (which Samsung started requiring two years after this library’s API was designed) the manufacturer Id must be explicitly specified for a match. The library defaults it to 0x118 which works the vast majority of the time as most all AltBeacons use 0x118 by historic convention. But as you have noticed with FeasyBeacon if you change this, it breaks this library’s detections with scan filters.

I am sorry for the trouble this gave you. Any thoughts on how to prevent others from running into this same problem or finding the answer more easily? The library is designed to make it easy for the 99% case. Unfortunately you are the other 1% (or less).

I suppose the library could detect the case where a non-standard altbeacon manufacturer code is detected (in the foreground without scan filters at least) and put a warning in LogCat. But my guess is that you would not have noticed that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to scan, clean & remove a virus from your android phone
Learn how to use the Samsung Smart Manager app to scan, clean, and remove a virus from your android Galaxy phone with our...
Read more >
9 Samsung Galaxy Settings You Need To Turn Off Now
David and David tell you about 9 Samsung # Galaxy #settings you need to turn ... Choose Which Apps Can Use Data In...
Read more >
Your Galaxy Has a Hidden Document Scanner Built in
With One UI 2, your Samsung Galaxy device now has a document scanner built-in, with the ability to automatically detect documents like letters, ......
Read more >
Excessive Wi-Fi Scanning in the Background
When an app performs Wi-Fi scans in the background, it wakes up the CPU, causing rate of battery drain. When too many scans...
Read more >
How to print and scan with Android | Computerworld
With your Android phone in hand, though, such scenarios don't have to be a hassle. In fact, printing and scanning from Android is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found