I'm developing an Android app that continuously scans for BLE advertisements in the background.
I use a foreground service to perform BLE scanning, and I restart the scanner every 3 minutes.
The sensor periodically broadcasts BLE advertisements, and I want the app to receive these advertisements reliably without missing them.
When the app is in the foreground, the scan duty cycle is effectively 100%. However, as soon as the app goes into the background or the screen is turned off, it drops to around 5%.
I confirmed this behavior by analyzing the HCI snoop log, and captured the actual LE_Set_Extended_Scan_Parameters values:
Foreground: interval = 100 ms, window = 100 ms (duty ≈ 100%)
Background / Screen off: interval = 10240 ms, window ≈ 511.9 ms (duty ≈ 5%)
This behavior was observed on a Pixel 10a running Android 17.
Relevant implementation details:
Scanning is performed via BluetoothLeScanner from a foreground service (FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE).
ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).
ScanFilter.Builder().setManufacturerData(MANUFACTURER_ID, byteArrayOf(), byteArrayOf())
BluetoothAdapter.isOffloadedFilteringSupported() is true on this device (filtering_support: 1, extended_scan_support: 1 per dumpsys bluetooth_manager).
Is there any way to prevent the BLE scan duty cycle from degrading when the app is in the background or the screen is turned off?
In particular, I'm looking for a way to maintain a high scan duty cycle and reliably receive the sensor's periodic BLE advertisements while the app is running in the background or the screen is off.