Skip to content

Commit

Permalink
Merge pull request #1059 from AltBeacon/fix-broken-intent-scans
Browse files Browse the repository at this point in the history
Fix broken intent scans
  • Loading branch information
davidgyoung committed Oct 5, 2021
2 parents ad2af77 + 6d0bf0b commit 6f66678
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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

0 comments on commit 6f66678

Please sign in to comment.