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.

Huawei Blocks Scans When Screen is Off

See original GitHub issue

Expected behavior

An application should be able to detect beacon region exit or entrance regardless of the application state: either foreground or background.

Actual behavior

When an application is in the background mode and screen is locked after some iterations of BeaconManager’s scanning you can see the following error in logs: E/BtGatt.GattService: App 'package_name' is scanning too frequently on screen off

After that each subsequent iteration causes the same error. After first appearance of this error exit from beacon’s region may happen (if was entered previously) and no more any region entrance can be detected.

Steps to reproduce this behavior

  1. Configure the BeaconManager for background scanning like that:
beaconManager.setBackgroundMode(true);
beaconManager.setBackgroundScanPeriod(5000L);
beaconManager.setBackgroundBetweenScanPeriod(30000L);
  1. Start the application
  2. Go to the background using “Home” button
  3. Lock the device’s screen
  4. See device’s logs by tag “scan” without package filters

Mobile device model and OS version

Samsung Galaxy S7 (Android 7.0) Huawei Honor 8 (Android 7.0)

Android Beacon Library version

2.11

As I know it is a quite common issue related to Android’s N DOZE mode. Some other beacon manufacturers (kontaktio, estimote) faced the same issue (with exact same case and error) lately. Mostly, the following official restriction mentioned: “Since Nougat, every application is allowed to start/stop BLE scan a maximum of 5 times per 30s.” but with the AltBeacon library the issue occurs even if I configure the BeaconManager like that:

beaconManager.setBackgroundScanPeriod(200L);
beaconManager.setBackgroundBetweenScanPeriod(120000L);

I’ve read issues #506, #509 and #512 but didn’t found working solution. I really like AltBeacon library, it works so great but this issue totally confused me. Please, help. Maybe I missed something.

Thank you!

IMPORTANT: This forum is reserved for feature requests or reproducible bugs with the library itself. If you need help with using the library with your project, please open a new question on StackOverflow.com.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:60 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
isaacurbinacommented, Jan 16, 2021

In my experience, I still get bluetooth scan results up to 1 minute after screen goes off, however, once that time is up, I always get empty list of results for scan. The only workaround I found so far is to send a notification every N minutes to turn the screen on and keep getting results for another minute only for Huawei devices. This would reduce battery life but it’s the only think that’s worked so far.

0reactions
mreda7commented, Jun 1, 2022

We have also this problems and the only solution was like @isaacurbina have said is to send a notification every N minutes to turn the screen on.

Do you know if this problem happens on other Android phone manufacturers other than Huawei ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The last scanned time displayed on the HUAWEI Vision Virus ...
Learn about 'The last scanned time displayed on the HUAWEI Vision Virus scan screen is incorrect'. Find all usage guide, troubleshooting tips and...
Read more >
Huawei Bluetooth behaviour in background scanning
Currently I have problems with HUAWEI devices. It seems that HUAWEI stops bluetooth scanning completely when device goes to sleep mode. I couldn ......
Read more >
How to Detect Malware in Huawei P30 Lite – Anti-Virus Scan
Make sure that the Huawei P30 Lite is well protected in order to do that, you should perform anti-virus scan. Find out if...
Read more >
Stop your Huawei smartphone from closing apps when you ...
Not all apps are affected by this problem. Huawei maintains a list of popular apps that are not closed from doing their thing...
Read more >
Avast Mobile Security - FAQs
Regardless of the timeout settings, App Lock always locks your apps when your screen turns off. When one app is unlocked, all other...
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