summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Huang <yabinh@google.com>2021-06-25 16:18:38 -0700
committerYabin Huang <yabinh@google.com>2021-06-25 16:24:55 -0700
commit35ceb31c1e1664870916476d1a6619c0efb0c3b8 (patch)
treedc5267e3993f84a485a484a2f5f827fed2eff256
parent3f4e295393c43012a00cc24991e04d96abfc93b6 (diff)
downloadLocalMediaPlayer-35ceb31c1e1664870916476d1a6619c0efb0c3b8.tar.gz
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.java6
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,