From 593e8f18cddfa9405e7220f6e196fc79c9d26941 Mon Sep 17 00:00:00 2001 From: Rohan Shah Date: Tue, 22 May 2018 10:06:23 -0700 Subject: [Notif] Don't show bouncer on dismiss For blocking helper, when user dismisses by interacting with elements outside the current notification, we should not show the bouncer. Changed the logic to only show bouncer/use the checksaverunnable when the user hits 'stop notifications' Test: Added test cases, ran via atest, verified manually too Bug: 80132806 Change-Id: Ic204e1794360684cd6359ff93e77e184e39ad57e --- .../systemui/statusbar/NotificationInfo.java | 6 ++-- .../systemui/statusbar/NotificationInfoTest.java | 38 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java index 98e926807431..9b4554e80118 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java @@ -300,9 +300,11 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private void saveImportance() { if (!mIsNonblockable) { - // Only go through the lock screen/bouncer if the user didn't hit 'Keep showing'. + // Only go through the lock screen/bouncer if the user hit 'Stop notifications'. + // Otherwise, update the importance immediately. if (mCheckSaveListener != null - && !NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING.equals(mExitReason)) { + && NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS.equals( + mExitReason)) { mCheckSaveListener.checkSave(this::updateImportance, mSbn); } else { updateImportance(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java index bdeb8bcd6fb8..a72fed4a2b41 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java @@ -508,7 +508,6 @@ public class NotificationInfoTest extends SysuiTestCase { anyString(), eq(TEST_UID), eq(true)); } - @Test public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing() throws Exception { @@ -537,6 +536,43 @@ public class NotificationInfoTest extends SysuiTestCase { anyString(), eq(TEST_UID), eq(true)); } + @Test + public void testCloseControls_nonNullCheckSaveListenerDoesntDelayDismiss() + throws Exception { + NotificationInfo.CheckSaveListener listener = + mock(NotificationInfo.CheckSaveListener.class); + mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, + TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */, + 10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */, + null /* onSettingsClick */, null /* onAppSettingsClick */ , + false /* isNonblockable */, true /* isForBlockingHelper */, + true /* isUserSentimentNegative */); + + mNotificationInfo.handleCloseControls(true /* save */, false /* force */); + + mTestableLooper.processAllMessages(); + verify(listener, times(0)).checkSave(any(Runnable.class), eq(mSbn)); + } + + @Test + public void testCloseControls_checkSaveListenerDelaysStopNotifications() + throws Exception { + NotificationInfo.CheckSaveListener listener = + mock(NotificationInfo.CheckSaveListener.class); + mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, + TEST_PACKAGE_NAME, mNotificationChannel /* notificationChannel */, + 10 /* numUniqueChannelsInRow */, mSbn, listener /* checkSaveListener */, + null /* onSettingsClick */, null /* onAppSettingsClick */ , + false /* isNonblockable */, true /* isForBlockingHelper */, + true /* isUserSentimentNegative */); + + mNotificationInfo.findViewById(R.id.block).performClick(); + waitForUndoButton(); + mNotificationInfo.handleCloseControls(true /* save */, false /* force */); + + mTestableLooper.processAllMessages(); + verify(listener).checkSave(any(Runnable.class), eq(mSbn)); + } @Test public void testCloseControls_blockingHelperDismissedIfShown() throws Exception { -- cgit v1.2.3-59-g8ed1b