From 689345798a96850abc00020129bf03b42e276282 Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Sat, 5 Dec 2020 21:45:07 -0800 Subject: [PATCH] NotificationUiAdjustmentTest: Mark unaudited PendingIntents with FLAG_MUTABLE_UNAUDITED These PIs need an explicit mutability flag. This temporay flag is being used to mark these points in code and should be replaced ASAP. See go/immutable-pendingintents for more context. Bug: 160794467 Test: TH Exempt-From-Owner-Approval: noop change Change-Id: Ieb6745feef0efe07143803bfb75bb83972df74e2 --- .../NotificationUiAdjustmentTest.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationUiAdjustmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationUiAdjustmentTest.java index 3c9c9cca16195..353647b65cc05 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationUiAdjustmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationUiAdjustmentTest.java @@ -39,8 +39,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentLength() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); Notification.Action action = createActionBuilder("first", R.drawable.ic_corp_icon, pendingIntent).build(); assertThat(NotificationUiAdjustment.needReinflate( @@ -51,8 +54,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentLabels() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); Notification.Action firstAction = createActionBuilder("first", R.drawable.ic_corp_icon, pendingIntent).build(); Notification.Action secondAction = @@ -66,8 +72,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentIcons() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); Notification.Action firstAction = createActionBuilder("same", R.drawable.ic_corp_icon, pendingIntent).build(); Notification.Action secondAction = @@ -82,10 +91,14 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentPendingIntent() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent firstPendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_VIEW), 0); + PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_VIEW), + PendingIntent.FLAG_MUTABLE_UNAUDITED); PendingIntent secondPendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_PROCESS_TEXT), 0); + PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_PROCESS_TEXT), + PendingIntent.FLAG_MUTABLE_UNAUDITED); Notification.Action firstAction = createActionBuilder("same", R.drawable.ic_corp_icon, firstPendingIntent) .build(); @@ -101,8 +114,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentChoices() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); RemoteInput firstRemoteInput = createRemoteInput("same", "same", new CharSequence[] {"first"}); @@ -126,8 +142,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_differentRemoteInputLabel() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); RemoteInput firstRemoteInput = createRemoteInput("same", "first", new CharSequence[] {"same"}); @@ -151,8 +170,11 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase { @Test public void needReinflate_negative() { + // TODO(b/174258598) Please replace FLAG_MUTABLE_UNAUDITED below + // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE. PendingIntent pendingIntent = - PendingIntent.getActivity(mContext, 0, new Intent(), 0); + PendingIntent.getActivity(mContext, 0, new Intent(), + PendingIntent.FLAG_MUTABLE_UNAUDITED); RemoteInput firstRemoteInput = createRemoteInput("same", "same", new CharSequence[] {"same"}); RemoteInput secondRemoteInput =