Dialer: PendingIntents need mutability flags

* Mostly immutable but LocationManager wants to modify the intent,
  so needs to be mutable

Change-Id: I59219f008bff0aab561fda50f6c7658ccdcb3fe8
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
index a9ab8c2..d2d31a3 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
@@ -99,7 +99,7 @@
   public static PendingIntent createMarkAllNewVoicemailsAsOldIntent(@NonNull Context context) {
     Intent intent = new Intent(context, CallLogNotificationsService.class);
     intent.setAction(CallLogNotificationsService.ACTION_MARK_ALL_NEW_VOICEMAILS_AS_OLD);
-    return PendingIntent.getService(context, 0, intent, 0);
+    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   public static PendingIntent createMarkSingleNewVoicemailAsOldIntent(
@@ -107,13 +107,13 @@
     Intent intent = new Intent(context, CallLogNotificationsService.class);
     intent.setAction(CallLogNotificationsService.ACTION_MARK_SINGLE_NEW_VOICEMAIL_AS_OLD);
     intent.setData(voicemailUri);
-    return PendingIntent.getService(context, 0, intent, 0);
+    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   public static PendingIntent createCancelAllMissedCallsPendingIntent(@NonNull Context context) {
     Intent intent = new Intent(context, CallLogNotificationsService.class);
     intent.setAction(ACTION_CANCEL_ALL_MISSED_CALLS);
-    return PendingIntent.getService(context, 0, intent, 0);
+    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   public static PendingIntent createCancelSingleMissedCallPendingIntent(
@@ -121,7 +121,7 @@
     Intent intent = new Intent(context, CallLogNotificationsService.class);
     intent.setAction(ACTION_CANCEL_SINGLE_MISSED_CALL);
     intent.setData(callUri);
-    return PendingIntent.getService(context, 0, intent, 0);
+    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   public static PendingIntent createLegacyVoicemailDismissedPendingIntent(
@@ -129,7 +129,7 @@
     Intent intent = new Intent(context, CallLogNotificationsService.class);
     intent.setAction(ACTION_LEGACY_VOICEMAIL_DISMISSED);
     intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
-    return PendingIntent.getService(context, 0, intent, 0);
+    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   @Override
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index f70a744..7f2f663 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -434,7 +434,8 @@
 
     // TODO (a bug): scroll to call
     contentIntent.setData(callUri);
-    return PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+    return PendingIntent.getActivity(context, 0, contentIntent,
+            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
   }
 
   private PendingIntent createCallBackPendingIntent(String number, @NonNull Uri callUri) {
@@ -444,7 +445,8 @@
     intent.setData(callUri);
     // Use FLAG_UPDATE_CURRENT to make sure any previous pending intent is updated with the new
     // extra.
-    return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+    return PendingIntent.getService(context, 0, intent,
+            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
   }
 
   private PendingIntent createSendSmsFromNotificationPendingIntent(
@@ -455,7 +457,8 @@
     intent.setData(callUri);
     // Use FLAG_UPDATE_CURRENT to make sure any previous pending intent is updated with the new
     // extra.
-    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+    return PendingIntent.getActivity(context, 0, intent,
+            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
   }
 
   /** Configures a notification to emit the blinky notification light. */
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
index c127b40..edb5115 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
@@ -225,7 +225,8 @@
     if (voicemail != null) {
       intent.setData(voicemail.voicemailUri);
     }
-    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+    return PendingIntent.getActivity(context, 0, intent,
+            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
   }
 
   /**
diff --git a/java/com/android/dialer/location/CountryDetector.java b/java/com/android/dialer/location/CountryDetector.java
index a50e232..093ddd9 100644
--- a/java/com/android/dialer/location/CountryDetector.java
+++ b/java/com/android/dialer/location/CountryDetector.java
@@ -113,8 +113,8 @@
     LogUtil.i("CountryDetector.registerForLocationUpdates", "registering for location updates");
 
     final Intent activeIntent = new Intent(context, LocationChangedReceiver.class);
-    final PendingIntent pendingIntent =
-        PendingIntent.getBroadcast(context, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+    final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, activeIntent,
+                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
 
     locationManager.requestLocationUpdates(
         LocationManager.PASSIVE_PROVIDER,
diff --git a/java/com/android/incallui/ExternalCallNotifier.java b/java/com/android/incallui/ExternalCallNotifier.java
index 62b1957..d1334f3 100644
--- a/java/com/android/incallui/ExternalCallNotifier.java
+++ b/java/com/android/incallui/ExternalCallNotifier.java
@@ -259,7 +259,8 @@
                       isVideoCall
                           ? R.string.notification_take_video_call
                           : R.string.notification_take_call),
-                  PendingIntent.getBroadcast(context, info.getNotificationId(), intent, 0))
+                  PendingIntent.getBroadcast(context, info.getNotificationId(), intent,
+                          PendingIntent.FLAG_IMMUTABLE))
               .build());
     }
 
diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java
index 2a94cd4..177a1a5 100644
--- a/java/com/android/incallui/StatusBarNotifier.java
+++ b/java/com/android/incallui/StatusBarNotifier.java
@@ -32,8 +32,10 @@
 import static com.android.incallui.NotificationBroadcastReceiver.ACTION_TURN_ON_SPEAKER;
 
 import android.Manifest;
+import android.annotation.SuppressLint;
 import android.app.Notification;
 import android.app.PendingIntent;
+import android.app.Person;
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
@@ -62,6 +64,7 @@
 import androidx.annotation.Nullable;
 import androidx.annotation.RequiresPermission;
 import androidx.annotation.StringRes;
+import androidx.core.content.res.ResourcesCompat;
 
 import com.android.contacts.common.ContactsUtils;
 import com.android.contacts.common.ContactsUtils.UserType;
@@ -166,7 +169,7 @@
    */
   private static PendingIntent createNotificationPendingIntent(Context context, String action) {
     final Intent intent = new Intent(action, null, context, NotificationBroadcastReceiver.class);
-    return PendingIntent.getBroadcast(context, 0, intent, 0);
+    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   /** Creates notifications according to the state we receive from {@link InCallPresenter}. */
@@ -943,7 +946,7 @@
     // and clicks the notification's expanded view.  It's also used to
     // launch the InCallActivity immediately when when there's an incoming
     // call (see the "fullScreenIntent" field below).
-    return PendingIntent.getActivity(context, requestCode, intent, 0);
+    return PendingIntent.getActivity(context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
   }
 
   private void setStatusBarCallListener(StatusBarCallListener listener) {