Skip to content

Commit

Permalink
Ensure that all pending intents have the IMMUTABLE tag
Browse files Browse the repository at this point in the history
Per https://developer.android.com/guide/components/intents-filters#CreateImmutablePendingIntents

> In most cases, your app should create immutable PendingIntent objects, as
> shown in the following code snippet. If a PendingIntent object is immutable,
> then other apps cannot modify the intent to adjust the result of invoking the
> intent.

Our usage here falls into this common case, so we can just make them be immutable
  • Loading branch information
shankari committed Mar 12, 2023
1 parent 7b58b3f commit cddaa01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/android/NotificationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void createNotification(Context context, int id, String title, Str
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0,
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(activityPendingIntent);

Log.d(context, TAG, "Generating notify with id " + id + " and message " + message);
Expand Down Expand Up @@ -85,7 +85,7 @@ public static void createResolveNotification(Context context, int id, String tit
activityIntent.putExtra(NotificationHelper.RESOLUTION_PENDING_INTENT_KEY, intent);

PendingIntent activityPendingIntent = PendingIntent.getActivity(context, 0,
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(activityPendingIntent);
// builder.setAutoCancel(true);

Expand Down

0 comments on commit cddaa01

Please sign in to comment.