Bluetooth LE stop scanning when screen is off

Hi,

I am currently developing an application to scan iBeacon. I am experiencing issue related to ble scan, whenever screen off, the ble stop scanning.

I know Google introduced a new feature. As of Android 8.1, unfiltered scan are blocked when the screen is off. I have applied the scanfilter, but it does not fix the issue on Samsung phone.

Is there any other setting that i have to apply?

Hi dan1582180597,
Can you share below information-

  • Sample application(source code)
  • Issue reproduction detail
  • Dumpstate log
    -Device information like OS/software version where the problem occurs

To get Dumpstate log files please find the following steps:

  1. phone > dialer > *#9900# > check seclog status
    => If seclog status is ‘enable seclog(currently disabled)’ > click enable seclog(currently disabled) > click ok on security notice popup > reboot device > go to the next step(2)
    => If seclog status is ‘disable seclog(currently enabled)’ > go to the next step(2)
  2. reproduce the issue
  3. phone > keypad > *#9900# > run dumpstate/logcat/modem log > copy to sdcard

Thank you.

I am also facing a similar issue. Since I have integrated foreground service, my service is running in the background even in lock mode. I am using filtered BLE scan to get the background BLE data.

Phone Used

  1. Samsung s8+ (SM-G955FD) , OS : 9, One UI version 1.0

Please clone my sample app from https://github.com/mriyas/BleScanner.git

In the sample app, you can see the timer hits periodically to scan BLE data. In the lock mode, the timer is running but the BLE data is not returning any result. It is very visible that whenever you unlock the phone I am able to get the BLE data.

How to reproduce the issue?

  1. Run the sample app
  2. Tap “Start Service”
  3. Check the logs, you will be getting some logs(filter for “onScanResult”) if there is BLE data around.
  4. Lock the screen. you will not get any BLE data, and you can see the log coming soon after you unlock the phone.

Logcat Screenshot :

Dumpstate log file :

Could you please help me to resolve the issue?

Hello, i am facing the same problem, do you find a solution?
I tried everything via android documentation but i cant solve it.

Hi basdanis,
Are you using any non filtered scanner in your app? like, any filter with nothing set?
Google policy and Samsung policy, any scanner using one or more empty filters will be suspended while the screen is off.
The bottom line is you should use effective filters for each scanner if you want to get advertisement reports even when the screen is off.
In addition, avoid LOW_LATENCY for power consumption. Use LOW_LATENCY for a short time only when it is really required for your app.

Thanks