From 17ea3c0bcc2fe0a72042bcb5af0ec27b8e7ec3da Mon Sep 17 00:00:00 2001 From: paulhu Date: Sun, 11 Oct 2020 01:40:09 +0800 Subject: [PATCH] Add a mutability flag to the PendingIntent It's soon going to be required for apps targeting S+ to specify explicitly either FLAG_MUTABLE or FLAG_IMMUTABLE when creating a PendingIntent. Thus, add a mutability flag to the PendingIntent that doesn't specify it before. Bug: 170602021 Bug: 170766590 Test: atest FrameworksNetTests Change-Id: I56581033c0a1b450b6626112cdae5e5d9aac873f --- .../java/com/android/server/connectivity/LingerMonitor.java | 5 +++-- .../server/connectivity/NetworkNotificationManager.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/LingerMonitor.java b/services/core/java/com/android/server/connectivity/LingerMonitor.java index 04c000f645..7fdc7a0a52 100644 --- a/services/core/java/com/android/server/connectivity/LingerMonitor.java +++ b/services/core/java/com/android/server/connectivity/LingerMonitor.java @@ -159,8 +159,9 @@ public class LingerMonitor { @VisibleForTesting protected PendingIntent createNotificationIntent() { - return PendingIntent.getActivityAsUser(mContext, 0, CELLULAR_SETTINGS, - PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT); + return PendingIntent.getActivityAsUser(mContext, 0 /* requestCode */, CELLULAR_SETTINGS, + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, + null /* options */, UserHandle.CURRENT); } // Removes any notification that was put up as a result of switching to nai. diff --git a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java index 34b0aa2464..26356b440d 100644 --- a/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java +++ b/services/core/java/com/android/server/connectivity/NetworkNotificationManager.java @@ -325,7 +325,8 @@ public class NetworkNotificationManager { public void setProvNotificationVisible(boolean visible, int id, String action) { if (visible) { Intent intent = new Intent(action); - PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); + PendingIntent pendingIntent = PendingIntent.getBroadcast( + mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE); showNotification(id, NotificationType.SIGN_IN, null, null, pendingIntent, false); } else { clearNotification(id);