Comments (21)
from android-beacon-library.
@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.
from android-beacon-library.
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.
- iBeacon layout, manufacturer code, and region configuration are set successfully, as the other test device works with no issues proving that. Samsung also works as expected when the screen is unlocked.
- The version of the library is set to 2.20.4
- Applied all the settings suggested in https://dontkillmyapp.com/samsung
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:
// 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.
And then, I changed the manufacturerCode
to Apple one(0x004c) instead of the actual manufacturer's one, and now it can scan iBeacons on my Samsung device even if the screen is off.
Maybe this is how it should be -- setting Apple manufacturer code for iBeacon scanning even though you have the iBeacon from a different manufacturer, I don't know, never seen it in the documentation. Maybe this helps someone
locked_to_unlocked_logs.txt
unlocked_to_locked_logs.txt
locked_logs.txt
from android-beacon-library.
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?
from android-beacon-library.
Hi @davidgyoung.
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
Nice, I will test your fix and give you feedback later!
Does your app target Android 14? Do you know if this matters?
Yes, we target Android 14 but I am not sure if this matters. As far as I remember I did some tests were I went back in the git history of the project and it also did not work when we did not target Android 14.
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!
from android-beacon-library.
@davidgyoung Pixel 7 is working again! 👏
from android-beacon-library.
Test results on various devices:
Model OS Library Version Ranges with Screen Off
-------- ---------- --------------- ------------------------
Pixel 4a Android 13 2.20.2 YES
Pixel 4a Android 13 #1176 YES
Pixel 6a Android 12 2.20.2 YES
Pixel 6a Android 12 #1176 YES
Pixel 6a Android 13 2.20.2 YES
Pixel 6a Android 13 #1176 YES
Pixel 6a Android 14 2.20.2 YES
Pixel 6a Android 14 #1176 YES
Pixel 7 Android 14 2.20.2 NO
Pixel 7 Android 14 #1176 YES
Note: the two different Android 14 build numbers above are:
Pixel 6a Android 14 build number UP1A.231105.003
Pixel 7 Android 14 build number U1B2.230922.006
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
from android-beacon-library.
I did a few more tests with Pixel 7 Android 14, varying the target SDK in the app:
Model OS Library Version Target SDK Ranges with Screen Off Notes
-------- ---------- --------------- ---------- ---------------------- -----
Pixel 7 Android 14 2.20.2 33 YES Clean install
Pixel 7 Android 14 2.20.2 34 YES Upgrade from above
Pixel 7 Android 14 2.20.2 34 NO Clean install
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.
from android-beacon-library.
I don't recognize the beacon after a few minutes after the screen is turned off.
After a few minutes (10 minutes to 15 minutes), sometimes it is recognized.
Your Kotlin reference code is used and Alt Beacon Library 2.20.2 is being used.
In the code below, which part should I activate or modify it to use the beacons in a short time (within 1 minute to 2 minutes) even in the LCD OFF state below?
Or is it impossible to scan a beacon within 1 to 2 minutes in Android LCD OFF?
In the code below, which part should I activate or modify it to use the beacons in a short time (within 1 minute to 2 minutes) even in the LCD OFF state below?
I added the code below.
Added code
BeaconManager.setBackgroundBetWeyenscanperiod (100);
BeaconManager.SetBackgroundScanperiod (1000);
BeaconManager.SetForegroundBet WeEenscanperiod (100)
BeaconManager.setScanperiod (1000)
from android-beacon-library.
Hi @davidgyoung,
Same issue with Motorola g54 even with Android version 13.
Build: 5.10.168-android12-9-00003-g828a3b1f7462-ab10564101
From logcat: "BtGatt.ScanManager com.android.bluetooth W Cannot start unfiltered scan in screen-off. This scan will be resumed later: 14"
from android-beacon-library.
@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?
from android-beacon-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
from android-beacon-library.
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?
from android-beacon-library.
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.
from android-beacon-library.
@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.
from android-beacon-library.
@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 Build.MANUFACTURER.equalsIgnoreCase("asus")
to the scan filter check if statement solves the issue on my Asus.
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());
}
from android-beacon-library.
thanks, @juliankotrba. it sounds like we do need to include Asus and Motorola on Android 13
from android-beacon-library.
Seeing the same issue on
14, UP1A.231005.007, 22101316UG, Xiaomi
Running version 2.20.4
from android-beacon-library.
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.
hi @davidgyoung @akoskuczi-bw , i face the same issue in Motorola edge40, Samsung F12. Please consider fixing this issue for these devices.
I am using the same flutter library to access iBeacon.
from android-beacon-library.
Related Issues (20)
- Range beacons when app is terminating HOT 7
- Beacons ranging not working on android 13 HOT 1
- App stops scanning right after screen is locked and starts giving the results right after unlocked HOT 1
- Android beacon library - multiple regions monitoring - unable remove regions HOT 2
- startForeground Exception when app is not in foreground HOT 3
- StartupBroadcastReceiver throws NullPointerException HOT 2
- Cannot parse iBeacons HOT 3
- BeaconService.startForegroundIfConfigured HOT 12
- TargetSdk 34 (android 14) Beacon foreground service no longer working due to new Google restriction HOT 1
- Do we have sample app to implement the library including the operation running in Background HOT 4
- Only a maximum of 2 beacons can be received at a time HOT 1
- java.io.FileNotFoundException android-distance.json HOT 3
- android-distance.json database not found
- Crash when parsing _lengthy_ beacon data fields HOT 3
- Custom Distance calculator is being overwritten HOT 6
- Samsung devices not detecting beacons by intent after first screen off HOT 1
- Can we use this with tauri mobile? HOT 3
- Main thread can be blocked sometimes
- Android 14 didDetermineStateForRegion no beacon is detected or scanned HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-beacon-library.