Add PendingIntent flags

Test: atest
Fixes: 174965424
Fixes: 175014468
Fixes: 175005650
Fixes: 174969959
Fixes: 174970399
Fixes: 174935104
Fixes: 174935955
Fixes: 174965245
Fixes: 174258141
Fixes: 174161800
Fixes: 173741872
Change-Id: I0d3b67d681f49c0c8f96fd9265100b6ca6671a2d
This commit is contained in:
Julia Reynolds
2020-12-08 12:43:57 -05:00
parent 03f2357272
commit 856be9e97b
11 changed files with 15 additions and 43 deletions

View File

@@ -629,10 +629,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
return new Notification.Action.Builder(
Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon),
"action",
// TODO(b/174935104) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getBroadcast(getContext(), 0, new Intent("Action"),
PendingIntent.FLAG_MUTABLE_UNAUDITED)).build();
PendingIntent.FLAG_IMMUTABLE)).build();
}
private static class FakeNotificationLifetimeExtender implements NotificationLifetimeExtender {

View File

@@ -233,10 +233,8 @@ public class NotificationEntryTest extends SysuiTestCase {
return new Notification.Action.Builder(
Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon),
title,
// TODO(b/174965424) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getBroadcast(getContext(), 0, new Intent("Action"),
PendingIntent.FLAG_MUTABLE_UNAUDITED))
PendingIntent.FLAG_IMMUTABLE))
.setContextual(true)
.build();
}
@@ -245,10 +243,8 @@ public class NotificationEntryTest extends SysuiTestCase {
return new Notification.Action.Builder(
Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon),
title,
// TODO(b/174965424) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getBroadcast(getContext(), 0, new Intent("Action"),
PendingIntent.FLAG_MUTABLE_UNAUDITED)).build();
PendingIntent.FLAG_IMMUTABLE)).build();
}
private ArrayList<Notification.Action> createActions(String... titles) {

View File

@@ -476,10 +476,8 @@ public class NotificationInterruptStateProviderImplTest extends SysuiTestCase {
private NotificationEntry createBubble() {
Notification.BubbleMetadata data = new Notification.BubbleMetadata.Builder(
// TODO(b/174970399) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getActivity(mContext, 0, new Intent(),
PendingIntent.FLAG_MUTABLE_UNAUDITED),
PendingIntent.FLAG_MUTABLE),
Icon.createWithResource(mContext.getResources(), R.drawable.android))
.build();
Notification n = new Notification.Builder(getContext(), "a")

View File

@@ -213,11 +213,9 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
notification, UserHandle.CURRENT, null, 0);
mEntry = new NotificationEntryBuilder().setSbn(mSbn).setShortcutInfo(mShortcutInfo).build();
// TODO(b/175005650) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0,
new Intent(mContext, BubblesTestActivity.class),
PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_MUTABLE);
mBubbleSbn = new SbnBuilder(mSbn).setBubbleMetadata(
new Notification.BubbleMetadata.Builder(bubbleIntent,
Icon.createWithResource(mContext, R.drawable.android)).build())

View File

@@ -455,10 +455,8 @@ public class NotificationTestHelper {
private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent) {
Intent target = new Intent(mContext, BubblesTestActivity.class);
// TODO(b/175014468) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target,
PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_MUTABLE);
return new BubbleMetadata.Builder(bubbleIntent,
Icon.createWithResource(mContext, R.drawable.android))

View File

@@ -293,9 +293,7 @@ public class NotificationHistoryDatabase {
.appendPath(file.getAbsolutePath()).build())
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
.putExtra(EXTRA_KEY, file.getAbsolutePath()),
// TODO(b/174161800) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, deletionTime, pi);
}

View File

@@ -462,8 +462,6 @@ public class SnoozeHelper {
}
private PendingIntent createPendingIntent(String pkg, String key, int userId) {
// TODO(b/174969959) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
return PendingIntent.getBroadcast(mContext,
REQUEST_CODE_REPOST,
new Intent(REPOST_ACTION)
@@ -471,7 +469,7 @@ public class SnoozeHelper {
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
.putExtra(EXTRA_KEY, key)
.putExtra(EXTRA_USER_ID, userId),
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
public void scheduleRepostsForPersistedNotifications(long currentTime) {

View File

@@ -127,6 +127,6 @@ public class NotificationAdjustmentExtractorTest extends UiServiceTestCase {
Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon),
"action",
PendingIntent.getBroadcast(getContext(), 0, new Intent("Action"),
PendingIntent.FLAG_MUTABLE_UNAUDITED)).build();
PendingIntent.FLAG_IMMUTABLE)).build();
}
}

View File

@@ -58,10 +58,8 @@ public class NotificationIntrusivenessExtractorTest extends UiServiceTestCase {
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_DEFAULT);
final Notification.Builder builder = new Notification.Builder(getContext())
.setContentTitle("foo")
// TODO(b/174258141) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setFullScreenIntent(PendingIntent.getActivity(
getContext(), 0, new Intent(""), PendingIntent.FLAG_MUTABLE_UNAUDITED),
getContext(), 0, new Intent(""), PendingIntent.FLAG_IMMUTABLE),
true)
.setSmallIcon(android.R.drawable.sym_def_app_icon);
@@ -79,10 +77,8 @@ public class NotificationIntrusivenessExtractorTest extends UiServiceTestCase {
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_DEFAULT);
final Notification.Builder builder = new Notification.Builder(getContext())
.setContentTitle("foo")
// TODO(b/174258141) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setFullScreenIntent(PendingIntent.getActivity(
getContext(), 0, new Intent(""), PendingIntent.FLAG_MUTABLE_UNAUDITED),
getContext(), 0, new Intent(""), PendingIntent.FLAG_IMMUTABLE),
true)
.setSmallIcon(android.R.drawable.sym_def_app_icon);

View File

@@ -357,13 +357,11 @@ public class NotificationListenerServiceTest extends UiServiceTestCase {
private ArrayList<Notification.Action> getSmartActions(String key, int index) {
ArrayList<Notification.Action> actions = new ArrayList<>();
for (int i = 0; i < index; i++) {
// TODO(b/174935955) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent intent = PendingIntent.getBroadcast(
getContext(),
index /*requestCode*/,
new Intent("ACTION_" + key),
PendingIntent.FLAG_MUTABLE_UNAUDITED /*flags*/);
PendingIntent.FLAG_IMMUTABLE /*flags*/);
actions.add(new Notification.Action.Builder(null /*icon*/, key, intent).build());
}
return actions;

View File

@@ -790,10 +790,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
.setName("bubblebot")
.build();
RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build();
// TODO(b/174965245) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(),
PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_MUTABLE);
Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon);
Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply",
inputIntent).addRemoteInput(remoteInput)
@@ -7369,10 +7367,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
ArrayList<Notification.Action> extraAction = new ArrayList<>();
RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build();
// TODO(b/174965245) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(),
PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_IMMUTABLE);
Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon);
Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply",
inputIntent).addRemoteInput(remoteInput)
@@ -7402,10 +7398,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
ArrayList<Notification.Action> extraAction = new ArrayList<>();
RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build();
// TODO(b/174965245) Please replace FLAG_MUTABLE_UNAUDITED below
// with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(),
PendingIntent.FLAG_MUTABLE_UNAUDITED);
PendingIntent.FLAG_MUTABLE);
Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon);
Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply",
inputIntent).addRemoteInput(remoteInput)