Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop scanning BLE Beacons when screen is off (Samsung S23U/S24U Android 14) #4562

Open
vtimer opened this issue Aug 7, 2024 · 3 comments
Open
Labels
bug Something isn't working sensor-tracking

Comments

@vtimer
Copy link

vtimer commented Aug 7, 2024

Home Assistant Android app version(s):
2024.7.3-full
Android version(s):
Android 14
Device model(s):
Samsung Galaxy S23 Ultra SM-S918B
Samsung Galaxy S24 Ultra SM-S928B
Home Assistant version:
Core 2024.7.4
Supervisor 2024.08.0
Operating System 12.4
Frontend 20240710.0
Last working Home Assistant release (if known):
nope
Description of problem, include YAML if issue is related to notifications:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Tested on two phones: Samsung S23U and S24U (Android 14).
When the phone screen is off, beacons (Holyiot NRF52810) are not detected, attribute Beacon Monitor has state Monitoring .
Screen OFF

When the screen is on (simply wake phone up with tap on the screen, the phone can be locked or unlocked - it doesn’t matter) scan working normally.
Screen ON

Home Assistant app settings:
Beacon monitor - Enabled
Enable beacon monitor - Enabled
Settings by default

Android settings:
Permission - Location: Allow all the time
Battery: Unrestricted

On Samsung Galaxy S8 Plus (Android 9) and Poco F3 (Android 13) phones with the same version of Home Assistant and the same HAOS server and app settings, beacon values are transmitted normally when the screen is off

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

LOGS
08-07 21:08:22.459 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:08:22.467 32470  2151 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:08:24.056 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:24.056 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:08:25.655 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:25.655 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:27.257 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:27.257 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:28.856 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:28.857 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:29.962 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:29.962 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:30.456 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:30.456 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:30.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:30.458 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:08:30.458 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:30.458 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:08:30.463 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:08:32.058 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:32.058 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:08:33.655 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:33.655 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:35.255 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:35.255 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:36.856 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:36.856 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:37.142 32470 32708 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:08:37.152 32470 32708 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:08:37.159 32470 32708 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:08:37.167 32470 32708 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:08:37.168 32470 32709 D WebSocketRepository: Sending message 52: {type=ping, id=52}
08-07 21:08:37.169 32470 32709 D WebSocketRepository: Message number 52 sent
08-07 21:08:37.201 32470 32724 D WebSocketRepository: Websocket: onMessage (text)
08-07 21:08:37.202 32470 32724 D WebSocketRepository: Message number 52 received
08-07 21:08:37.962 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:37.962 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:38.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:38.457 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:38.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:38.458 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:08:38.458 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:38.458 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:08:38.461 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:08:40.057 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:40.057 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:08:41.658 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:41.658 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:43.256 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:43.256 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:44.857 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:44.857 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:45.961 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:45.961 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:46.455 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:46.455 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:46.456 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:46.460 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:08:46.460 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:46.460 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:08:46.467 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:08:48.056 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:48.057 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:08:49.657 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:49.657 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:51.258 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:51.258 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:52.855 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:52.856 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:53.959 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:53.960 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:54.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:54.457 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:54.459 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:54.461 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:08:54.461 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:54.461 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:08:54.469 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:08:56.055 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:56.055 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:08:57.656 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:57.656 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:08:59.257 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:08:59.257 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:00.855 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:00.856 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:01.957 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:01.958 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:02.458 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:02.458 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:02.459 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:02.461 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:09:02.462 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:02.462 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:09:02.471 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:09:04.056 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:04.057 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:09:05.656 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:05.657 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:07.181 32470 32522 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:07.190 32470 32522 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:07.197 32470 32522 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:07.201 32470 32522 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:07.202 32470 32720 D WebSocketRepository: Sending message 53: {type=ping, id=53}
08-07 21:09:07.203 32470 32720 D WebSocketRepository: Message number 53 sent
08-07 21:09:07.244 32470 32724 D WebSocketRepository: Websocket: onMessage (text)
08-07 21:09:07.245 32470 32724 D WebSocketRepository: Message number 53 received
08-07 21:09:07.255 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:07.255 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:08.857 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:08.857 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:09.961 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:09.962 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:10.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:10.457 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:10.458 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:10.461 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:09:10.461 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:10.461 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:09:10.468 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:09:12.056 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:12.056 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:09:13.656 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:13.657 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:15.256 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:15.257 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:16.856 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:16.856 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:17.961 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:17.961 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:18.456 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:18.457 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:18.458 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:18.462 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:09:18.463 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:18.463 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:09:18.471 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:09:18.871 32470 32470 D SensorReceiver: Received intent: android.intent.action.TIME_TICK
08-07 21:09:18.893 32470 32521 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:18.962 32470 32521 E SensorReceiver: Issue requesting updates for Notification sensors
08-07 21:09:18.962 32470 32521 E SensorReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:154)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.sensors.NotificationSensorManager.updateActiveNotificationCount(NotificationSensorManager.kt:236)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.sensors.NotificationSensorManager.requestSensorUpdate(NotificationSensorManager.kt:102)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.common.sensors.SensorManager$DefaultImpls.requestSensorUpdate(SensorManager.kt:138)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.sensors.NotificationSensorManager.requestSensorUpdate(NotificationSensorManager.kt:25)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.common.sensors.SensorReceiverBase.updateSensors(SensorReceiverBase.kt:184)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at io.homeassistant.companion.android.common.sensors.SensorReceiverBase$onReceive$3.invokeSuspend(SensorReceiverBase.kt:154)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
08-07 21:09:18.962 32470 32521 E SensorReceiver: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
08-07 21:09:18.978 32470 32521 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:18.981 32470 32521 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:19.078 32470 32521 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: true, usesWifi is: true
08-07 21:09:19.101 32470 32522 I SensorReceiver: Sensor updates and sync completed
08-07 21:09:20.055 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:20.055 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:09:21.656 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:21.657 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:23.257 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:23.257 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:24.856 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:24.857 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:25.960 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:25.960 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:26.456 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:26.456 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:26.457 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:26.460 32470 32696 D BluetoothAdapter: semIsBleEnabled(): ON
08-07 21:09:26.460 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:26.460 32470 32696 D BluetoothLeScanner: Start Scan with callback
08-07 21:09:26.468 32470  6543 D BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=2 mScannerId=0
08-07 21:09:28.058 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:28.058 32470 32696 D BluetoothLeScanner: Stop Scan with callback
08-07 21:09:29.656 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:29.656 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:31.256 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:31.257 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:32.855 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:32.855 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:33.960 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:33.960 32470 32696 D BluetoothLeScanner: could not find callback wrapper
08-07 21:09:34.456 32470 32696 D BluetoothAdapter: getBleEnabledArray(): ON
08-07 21:09:34.456 32470 32696 D BluetoothLeScanner: could not find callback wrapper

Companion App Logs:


Screenshot or video of problem:

Additional information:

@vtimer vtimer added the bug Something isn't working label Aug 7, 2024
@dshokouhi
Copy link
Member

dshokouhi commented Aug 7, 2024

as you ahve samsung devices you have more options to turn off than just battery optimizations. Please go through device settings and look for things like data saver, power saving etc... and turn them all off and/or grant the app the access it needs

edit: as you mentioned its working on other devices then indeed teh issue is with device settings there

@dshokouhi dshokouhi added question Further information is requested sensor-tracking labels Aug 7, 2024
@vtimer
Copy link
Author

vtimer commented Aug 7, 2024

All tests were performed with the following configurations and this does not help

Connections - Data usage - Data saver: Off
Power Saving: Off
Background usage limit - Put unused apps to sleep: Off
Developer options - Suspend execution for cashed apps: Disabled
App info - Appear on top: On
App info - Change system settings Allowed

@dshokouhi
Copy link
Member

thanks for confirming, this might be a library issue as noted in AltBeacon/android-beacon-library#1174

seems like we may need to wait for an update there

@dshokouhi dshokouhi removed the question Further information is requested label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sensor-tracking
Projects
None yet
Development

No branches or pull requests

2 participants