diff options
author | Yabin Huang <yabinh@google.com> | 2021-06-25 16:18:38 -0700 |
---|---|---|
committer | Yabin Huang <yabinh@google.com> | 2021-06-25 16:24:55 -0700 |
commit | 35ceb31c1e1664870916476d1a6619c0efb0c3b8 (patch) | |
tree | dc5267e3993f84a485a484a2f5f827fed2eff256 | |
parent | 3f4e295393c43012a00cc24991e04d96abfc93b6 (diff) | |
download | LocalMediaPlayer-35ceb31c1e1664870916476d1a6619c0efb0c3b8.tar.gz |
Specify FLAG_IMMUTABLE when creating PendingIntentandroid-12.0.0_r32android-12.0.0_r29android-12.0.0_r28android-12.0.0_r27android-12.0.0_r26android-12.0.0_r21android-12.0.0_r20android-12.0.0_r19android-12.0.0_r18android-12.0.0_r16android12-qpr1-releaseandroid12-qpr1-d-s3-releaseandroid12-qpr1-d-s2-releaseandroid12-qpr1-d-s1-releaseandroid12-qpr1-d-releaseandroid12-dev
Targeting S+ (version 31 and above) requires that one of
FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a
PendingIntent. So this CL uses FLAG_IMMUTABLE to create
the PendingIntent because the flag is recommended in most cases.
Bug: 192103710
Test: manual
Change-Id: I1fadcd24c66a445513285ccf1aaa1a66c92b4d68
-rw-r--r-- | src/com/android/car/media/localmediaplayer/Player.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/com/android/car/media/localmediaplayer/Player.java b/src/com/android/car/media/localmediaplayer/Player.java index e39b394..ea47595 100644 --- a/src/com/android/car/media/localmediaplayer/Player.java +++ b/src/com/android/car/media/localmediaplayer/Player.java @@ -147,7 +147,8 @@ public class Player extends MediaSession.Callback { private Notification.Action makeNotificationAction(String action, int iconId, int stringId) { PendingIntent intent = PendingIntent.getBroadcast(mContext, REQUEST_CODE, - new Intent(action), PendingIntent.FLAG_UPDATE_CURRENT); + new Intent(action), + PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); Notification.Action notificationAction = new Notification.Action.Builder(iconId, mContext.getString(stringId), intent) .build(); @@ -235,7 +236,8 @@ public class Player extends MediaSession.Callback { Intent prefsIntent = new Intent(); prefsIntent.setClass(mContext, PermissionsActivity.class); prefsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, prefsIntent, 0); + PendingIntent pendingIntent = + PendingIntent.getActivity(mContext, 0, prefsIntent, PendingIntent.FLAG_IMMUTABLE); Bundle extras = new Bundle(); extras.putString(Utils.ERROR_RESOLUTION_ACTION_LABEL, |