-
Notifications
You must be signed in to change notification settings - Fork 837
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
No beacons after locked screen #1174
Comments
Hi @juliankotrba thank you for this report. I was able to reoproduce your results. At first glance, this appears to be a change to Android 14. It seems that with the screen off, scans with empty Bluetooth LE scan filters return no results. (This is how Samsung forks of Android behaved since 8.1, but Pixels did not appear to work this way as recently as Android 13). I tried modifying the Android Beacon Library code to use non-empty scan filters (like the library already does for Samsung) and the ranging started working even with the screen off: #1176 Does your app target Android 14? Do you know if this matters? |
Hi @davidgyoung.
Nice, I will test your fix and give you feedback later!
When you were able to reproduce the issue, on which Pixel did you test? For us, the issue only appeared on our Pixel 7, but not Pixel 8 (tested on one Pixel 7 and two Pixel 8). Thanks for your help! |
@davidgyoung Pixel 7 is working again! 👏 |
Good to hear. For the record, my only tests have been with the Pixel 7
which is the only Android 14 device I have hand now. I can try others next
week. It would be good to fully characterize so the library can implement
a proper fix for all.
…On Wed, Dec 6, 2023 at 01:37 Julian Kotrba ***@***.***> wrote:
@davidgyoung <https://github.com/davidgyoung> Pixel 7 is working again! 👏
—
Reply to this email directly, view it on GitHub
<#1174 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH7C4KUUE2JJLR6IW32D3TYIAHBRAVCNFSM6AAAAAA75PVYRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBSGE3TQOBQGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Test results on various devices:
Note: the two different Android 14 build numbers above are: Pixel 6a Android 14 build number UP1A.231105.003 Only the Pixel 7 Android 14 build shown above ever seems to block beacon detections with the screen off unless a non-empty bluetooth scan filter is active as added to library build #1176 |
I did a few more tests with Pixel 7 Android 14, varying the target SDK in the app:
So the problem only happens on the Pixel 7 if set the targetSdk to 34. Further, if you set the targetSdk to 33, run the app, then change the targetSdk to 34 and run the app again (without uninstall), the behavior is not seen. So it seems the behavior only applies to apps targeting Android 14 and newly installed on Pixel 7s. |
@kangjjang, this thread is dedicated to detection problems with the screen off ONLY on Android 14 on Pixel phones. It sounds like you need general help configuring an app for fast background detections. Please see this page: Alternate Scan Strategies. You will need to configure the library to use either a Foreground Service or the Intent Scan Strategy described at the very bottom of this page. If you need further help configuring your custom app, please open a new question on StackOverflow.com, as that is the proper forum for assistance with using the library with third party apps. This thread is ONLY for trouble detecting with the screen off on Android 14 on Pixel phones. |
Hi @davidgyoung, From logcat: "BtGatt.ScanManager com.android.bluetooth W Cannot start unfiltered scan in screen-off. This scan will be resumed later: 14" |
@akoskuczi-bw, the logcat line you mention has been around since Android 8.1, and as originally created, applied only to the case where there are zero scan filters attached to the scan: When do you see this log line with Android 13? Does it happen every time you try to start a scan with the screen off or just sometimes? Is in an app using this library? |
Yes, it is on Android 13. The scanning stops working consistently when the screen is off, and it restarts when the screen is on (not necessarily unlocked). I am using it with the following Flutter plugin: https://github.com/Lukangi/beacon_scanner/tree/main/beacon_scanner |
Researching AOSP commits, I found this change from July 2023 that is now part of Android 14: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2654980 Interestingly the commit is from a Motorola engineer, so perhaps the change went in to an earlier proprietary change on Motorola that does not show up in AOSP. OK, so this sounds believable. However, this does not explain the OP's report that the restriction did not apply to Pixel 8 with Android 14, and my observation above that it did not apply to Pixel 6a with Android 14. Could it be that this AOSP change was not in the Android 14 builds for the Pixel 6a and Pixel 8? What else could explain this? |
I have merged the change to fix this for Android 14. This does not address the problem for Motorola Android 13 as reported by @akoskuczi-bw. Does anybody else on this thread have a Motorola device with Android 13 to confirm the problem there? If we can get a confirmation of this on a second Motorola Android 13 device, I will make a new change that creates a scan filter for those devices, too. (I am reluctant to do this without confirmation since it could be a breaking change for apps that have been running on Motorola phones for the past year.) Until this is resolved I will leave this issue open. |
@davidgyoung I absolutely understand your position regarding Motorola. I'm wondering if anyone can confirm the issue with Motorola. Thank you very much for your time and efforts. |
@akoskuczi-bw @davidgyoung FYI I can't confirm the issue on the Motorola, however, I can reproduce it on our "new" Asus Zenfone 9 running with Android 13. Maybe also on a OnePlus but for that I need to do some more investigation. Adding EDIT: To make it more clear what I did locally to get it working: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
if ((Build.MANUFACTURER.equalsIgnoreCase("samsung") ||
--> Build.MANUFACTURER.equalsIgnoreCase("asus") || <--
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) &&
!mPowerManager.isInteractive()) {
// On the Samsung 8.1 and Android 14.0, scans are blocked with screen off when the
// scan filter is empty (wildcard). We do a more detailed filter on such devices
// only because it might block detections of AltBeacon packets with non-standard
// manufacturer codes. See #769 for details.
LogManager.d(TAG, "Using a non-empty scan filter since this is 14.0 or Samsung 8.1+");
filters = new ScanFilterUtils().createScanFiltersForBeaconParsers(
mBeaconManager.getBeaconParsers());
} |
thanks, @juliankotrba. it sounds like we do need to include Asus and Motorola on Android 13 |
I have a similar issue with a Samsung Galaxy A34 (Android 14) in the latest version of the library(2.20.4). Since the issue is very similar, I'm posting it here instead of creating a new one, even though my device is not a Pixel device. Attaching some log files here to avoid a distracting view in the comment. As mentioned in the top comment, I’m testing the reference app with the foreground service configuration enabled, and I experience that both ranging and monitoring stop immediately when I lock the screen. Once I unlock the screen, it starts working again and successfully sends the “A beacon is nearby” notification. Additionally, if the app was in the foreground when the lock button was hit, ranging and monitoring do not start even after the unlock. I needed to go back to home screen that triggered an “onPause” event which started the beacon scanning again. If you search “onPause” in the logs of “locked_to_unlocked_logs” file, you will see how it triggered the scanning. After that, you can check the “unlocked_to_locked_logs” file and search “Using a non-empty scan filter since this is 14.0 or Samsung 8.1+” logs to see how it stopped scanning. I tested these with an OnePlus 7T (Android 12) and it just works as expected after locking the screen. Since it never stops working, I don’t need to trigger an onPause event when I unlocked.
I hope this is clear, if it’s not or you need more logs not filtered application level, I can provide them too. The issue is easy to reproduce. Edit: I found a solution for my case. I found this comment by @davidgyoung in the CycledLeScannerForLollipop.java - startScan() method: locked_to_unlocked_logs.txt |
Seeing the same issue on |
hi @davidgyoung @akoskuczi-bw , i face the same issue in Motorola edge40, Samsung F12. Please consider fixing this issue for these devices. |
Hi @davidgyoung, Recently, I've been experiencing an issue with the Android version 14 on the OnePlus Nord CE4 device not receiving packets after the screen locks. After updating the below code fix, it started capturing packets.
However, I've noticed that the number of packets captured in the screen lock state is less compared to when the screen is on." |
I am using Realme GT2, Android 14. |
@davidgyoung I can confirm this for Motorola g42, Android 13. I can create a pull request with the fix as well, just let me know. |
Behavior + steps to reproduce this behavior
I am creating this ticket because we experience a weird problem with only one of our test devices (Pixel 7). The issue is one of the classic ones: as soon as we lock the phone and the display goes dark, the ranging stops.
I already tried to change all the different library settings in our app but the behavior stayed the same. To simplify the analysis of the problem for you, I checked out the android-beacon-library-reference-kotlin project (#2aa42a44) and tried to reproduce the problem there, which was actually reproducible. To prove that the problem occurs, I made some small modifications to the project.
I updated the unique region id to match our beacon scheme.
I uncommented the following lines
Then I ran the app on our Pixel 8 (Android 14) and on our Pixel 7. On the Pixel 8, the beeping continued after locking the phone while it stopped on the Pixel 7. I suspect that the problem is due to a device setting, but I haven't been able to identify it yet.
While reading through the GH issues I stumbled across your comment here where you mention three possible reasons why beacons are not detected when the screen is off: #944 (comment)
Ad 1. If the hardware code hasn't been set correctly, this would then lead to problems on different devices right? Since it works on almost all other phones I assume this one is correct.
Ad 2. In case the beacon parser layout is incorrect, I also assume it would also affect other devices.
Ad 3. I uninstalled all BLE scanning apps and tried again, no change in behavior
After the screen becomes active again, the beeping and therefore the ranging starts again.
Mobile device model and OS version
Pixel 7
Android 14
Build number: AP11.231020.016.A1
Security update: 1 November 2023
This devices is enrolled in the beta program
Library Logs:
altbeacon-logs.txt
We would really appreciate it if you could shed some light on this behavior.
Please let me know if any other important information is missing or if there is anything I can assist you with.
Thanks
Julian
The text was updated successfully, but these errors were encountered: