Bluetooth Low Energy scan result delivery is reduced when the screen is OFF

1k Views Asked by At

I am developing an android application that uses Bluetooth Low Energy to receive data from a peripheral device. The device itself sends the data as part of it's advertising message and it could send the message at any time. So the applications works by continuously scanning for BLE devices. When the screen is ON the application receives scan results as intended. When the screen is OFF it appears that it only receives scan results every 5 seconds. I guess that the phone is trying to optimize for battery life but this app is mission-critical so we can not afford to lose messages.

The scanning is done by a Service which is set as a 'foreground service' so that the OS knows that it is important. The service also acquires a PowerManager.PARTIAL_WAKE_LOCK but that does not seem to help. The application is excluded from battery optimizations so that it does not enter Doze or deep sleep mode. The application is using the following ScanSettings:

ScanSettings.SCAN_MODE_LOW_LATENCY
ScanSettings.CALLBACK_TYPE_ALL_MATCHES
ScanSettings.MATCH_MODE_AGGRESSIVE
ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT

I am working with a Galaxy S7 but I have been told the same behaviour happens with a Galaxy S7 Edge. I have tested with other non-samsung devices and they work as intended (continuously receiving scan results when the screen is OFF).

The question: is there something that I, as a developer, can do to make the BT adapter deliver scan results continuously even when the screen is OFF?

1

There are 1 best solutions below

0
On BEST ANSWER

Samsung automatically change scan mode to low_power if screen is turned off. It's their customisation on their Android OS, so unfortunately no way to change it.