This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch main in repository tor-android-service.
The following commit(s) were added to refs/heads/main by this push: new f324999 Bug 41481: Update PendingIntent for Android 12+ f324999 is described below
commit f324999c1773a8d8c83c50106a2cac30be93aabf Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Mon Nov 28 09:54:28 2022 +0100
Bug 41481: Update PendingIntent for Android 12+ --- .../main/java/org/torproject/android/service/TorService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/service/src/main/java/org/torproject/android/service/TorService.java b/service/src/main/java/org/torproject/android/service/TorService.java index f1ddcda..662d3cc 100644 --- a/service/src/main/java/org/torproject/android/service/TorService.java +++ b/service/src/main/java/org/torproject/android/service/TorService.java @@ -142,17 +142,25 @@ public final class TorService extends Service implements TorServiceConstants, Or } intent.setAction(TorServiceConstants.TOR_APP_USERNAME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); + int flags = 0; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + flags = flags | PendingIntent.FLAG_IMMUTABLE; + } + PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, flags);
if (mNotifyBuilder == null) { mNotifyBuilder = new NotificationBuilderCompat(this, NOTIFICATION_CHANNEL_ID) .setContentTitle(getString(R.string.app_name)).setContentIntent(pendIntent).setCategory("service") .setSmallIcon(R.drawable.ic_stat_tor);
+ flags = PendingIntent.FLAG_UPDATE_CURRENT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + flags = flags | PendingIntent.FLAG_IMMUTABLE; + } Intent intentRefresh = new Intent(CMD_NEWNYM); PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(getApplicationContext (), 0, - intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT); + intentRefresh, flags); mNotifyBuilder.addAction(R.drawable.ic_refresh_white_24dp, getString(R.string .menu_new_identity), pendingIntentNewNym);