From 9429fd34e64438e522582f499cc853e493dbaeef Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 20 Aug 2022 12:33:48 -0700 Subject: [PATCH] more fixes for Android 31 FLAG_IMMUTABLE and android:exported="true" --- .../src/main/java/org/eehouse/android/xw4/DupeModeTimer.java | 3 ++- .../app/src/main/java/org/eehouse/android/xw4/NBSProto.java | 3 ++- .../src/main/java/org/eehouse/android/xw4/TimerReceiver.java | 5 +++-- .../java/org/eehouse/android/xw4/UpdateCheckReceiver.java | 3 ++- .../app/src/main/java/org/eehouse/android/xw4/Utils.java | 2 +- xwords4/android/app/src/xw4Foss/AndroidManifest.xml | 4 +++- xwords4/android/app/src/xw4d/AndroidManifest.xml | 4 +++- xwords4/android/app/src/xw4fdroid/AndroidManifest.xml | 4 +++- 8 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DupeModeTimer.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DupeModeTimer.java index db258a134..0da021efa 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DupeModeTimer.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DupeModeTimer.java @@ -172,7 +172,8 @@ public class DupeModeTimer extends BroadcastReceiver { if ( whenSeconds < sCurTimer ) { sCurTimer = whenSeconds; Intent intent = new Intent( context, DupeModeTimer.class ); - PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 ); + PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, + PendingIntent.FLAG_IMMUTABLE ); long now = Utils.getCurSeconds(); long fire_millis = SystemClock.elapsedRealtime() diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NBSProto.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NBSProto.java index 2d47a72a7..de29f03ee 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NBSProto.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NBSProto.java @@ -379,7 +379,8 @@ public class NBSProto { private PendingIntent makeStatusIntent( Context context, String msg ) { Intent intent = new Intent( msg ); - return PendingIntent.getBroadcast( context, 0, intent, 0 ); + return PendingIntent.getBroadcast( context, 0, intent, + PendingIntent.FLAG_IMMUTABLE ); } private void cacheForRetry( QueueElem elem ) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/TimerReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/TimerReceiver.java index da9b5a17c..f2e5ac20e 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/TimerReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/TimerReceiver.java @@ -389,8 +389,9 @@ public class TimerReceiver extends BroadcastReceiver { (AlarmManager)context.getSystemService( Context.ALARM_SERVICE ); Intent intent = new Intent( context, TimerReceiver.class ); intent.putExtra( KEY_TIMER_ID, timerID ); - PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, - PendingIntent.FLAG_CANCEL_CURRENT ); + PendingIntent pi = PendingIntent + .getBroadcast( context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT + | PendingIntent.FLAG_IMMUTABLE ); am.set( AlarmManager.RTC_WAKEUP, firstFireTime, pi ); setJobTimerIf( context, delayMS, timerID ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java index a8731704e..01b346781 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -96,7 +96,8 @@ public class UpdateCheckReceiver extends BroadcastReceiver { (AlarmManager)context.getSystemService( Context.ALARM_SERVICE ); Intent intent = new Intent( context, UpdateCheckReceiver.class ); - PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 ); + PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, + PendingIntent.FLAG_IMMUTABLE ); am.cancel( pi ); long interval_millis; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index 4795b3185..700643708 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -379,7 +379,7 @@ public class Utils { { PendingIntent pi = PendingIntent .getActivity( context, Utils.nextRandomInt(), intent, - PendingIntent.FLAG_ONE_SHOT ); + PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE ); return pi; } diff --git a/xwords4/android/app/src/xw4Foss/AndroidManifest.xml b/xwords4/android/app/src/xw4Foss/AndroidManifest.xml index 8bc916834..ac003211d 100644 --- a/xwords4/android/app/src/xw4Foss/AndroidManifest.xml +++ b/xwords4/android/app/src/xw4Foss/AndroidManifest.xml @@ -22,7 +22,9 @@ - + diff --git a/xwords4/android/app/src/xw4d/AndroidManifest.xml b/xwords4/android/app/src/xw4d/AndroidManifest.xml index 865a6b996..4a2f2b11f 100644 --- a/xwords4/android/app/src/xw4d/AndroidManifest.xml +++ b/xwords4/android/app/src/xw4d/AndroidManifest.xml @@ -25,7 +25,9 @@ - + diff --git a/xwords4/android/app/src/xw4fdroid/AndroidManifest.xml b/xwords4/android/app/src/xw4fdroid/AndroidManifest.xml index d0afcd373..721750a27 100644 --- a/xwords4/android/app/src/xw4fdroid/AndroidManifest.xml +++ b/xwords4/android/app/src/xw4fdroid/AndroidManifest.xml @@ -9,7 +9,9 @@ - +