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

Fix broken intent scans #1059

Merged
merged 3 commits into from Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
### 2.19.3 / 2021-10-5

- Fix failing intent-backed scans broken by Android 12 changes in the 2.19 release. (#1059, David G. Young)

### 2.19.2 / 2021-08-18

- Fix NullPointerException in IntentScanStrategyCoordinator (#1053, PhilipTocsen)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -97,7 +97,7 @@ The following instructions are for project administrators.
git tag <version>
git push --tags
./gradlew release
./gradlew mavenPublish
./gradlew mavenPublish # Wait 10 mins before using the next command
./gradlew closeAndReleaseRepository

4. Keep checking for a half hour or so at https://repo1.maven.org/maven2/org/altbeacon/android-beacon-library/ to see that the new release shows up.
Expand Up @@ -254,10 +254,17 @@ void stopAndroidOBackgroundScan() {
}

// Low power scan results in the background will be delivered via Intent
@SuppressLint("WrongConstant")
PendingIntent getScanCallbackIntent() {
Intent intent = new Intent(mContext, StartupBroadcastReceiver.class);
intent.putExtra("o-scan", true);
return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
/* Android 12 (SDK 31) requires that all PendingIntents be created with either FLAG_MUTABLE or
FLAG_IMMUTABLE. In this case we must use FLAG_MUTABLE because the scan will set additional flags
on the intent -- that is how Andorid's Intent-driven scan APIs work. But because this library
is being compiled with SDK 30, the FLAG_MUTABLE is not available yet. We therefore use the hard-coded
value for this flag from SDK 31 release 1 and will fix that once the final SDK 31 is tested with this library.
*/
return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | 0x02000000);
}

private final CycledLeScanCallback mCycledLeScanCallback = new CycledLeScanCallback() {
Expand Down