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

Beacon scanning stops after 10 minutes when app is on foreground and enableForegroundServiceScanning is used. #1203

Open
elican-doenyas opened this issue Sep 27, 2024 · 1 comment

Comments

@elican-doenyas
Copy link

Expected behavior

Beacon scanning should continue as usual independent of the time app is used.

Actual behavior

Beacon scanning stops after ~10 minutes while app is on foreground and enableForegroundServiceScanning is called. This is also reproducible in the AltBeaconReference application.

Steps to reproduce this behavior

  • Call beaconManager.enableForegroundServiceScanning
  • Start ranging beacons with call to beaconManager.startRangingBeacons()
  • Open the app and leave it on foreground for 10+ minutes
  • Observe that beacon scanning halts after ~10 minutes

Mobile device model and OS version

Samsung S23 - Android 14

Android Beacon Library version

org.altbeacon:android-beacon-library:2.20.5 & org.altbeacon:android-beacon-library:2.20

@elican-doenyas
Copy link
Author

@davidgyoung I have pinpointed the reason for this issue, the DEFAULT_SCAN_TIMOUT_MILLIS was reduced from 30 minutes to 10 minutes in the Android OS with the following commit;

https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2237636/1/android/app/src/com/android/bluetooth/btservice/AdapterService.java

So the variable in the CycledLeScanner class to restart scanning and enforce long scans below;

public static final long ANDROID_N_MAX_SCAN_DURATION_MILLIS = 30 * 60 * 1000l; // 30 minutes

should be switched to 10 minutes.

Also, as far as I understand, in order to enforce long scans we need to set the mLongScanForcingEnabled parameter of CycledLeScanner, but I could not find where we can set this as an integrator of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant