Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +11 −7 Original line number Diff line number Diff line Loading @@ -91,22 +91,24 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private boolean mIsForBlockingHelper; private boolean mNegativeUserSentiment; /** Counter tag that describes how the user exit or quit out of this view. */ private String mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_DISMISSED; /** * String that describes how the user exit or quit out of this view, also used as a counter tag. */ private String mExitReason = NotificationCounters.BLOCKING_HELPER_DISMISSED; private OnClickListener mOnKeepShowing = v -> { mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING; mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING; closeControls(v); }; private OnClickListener mOnStopOrMinimizeNotifications = v -> { mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; swapContent(false); }; private OnClickListener mOnUndo = v -> { // Reset exit counter that we'll log and record an undo event separately (not an exit event) mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_DISMISSED; mExitReason = NotificationCounters.BLOCKING_HELPER_DISMISSED; logBlockingHelperCounter(NotificationCounters.BLOCKING_HELPER_UNDO); swapContent(true); }; Loading Loading @@ -300,7 +302,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private void saveImportance() { if (!mIsNonblockable) { if (mCheckSaveListener != null) { // Only go through the lock screen/bouncer if the user didn't hit 'Keep showing'. if (mCheckSaveListener != null && !NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING.equals(mExitReason)) { mCheckSaveListener.checkSave(this::updateImportance, mSbn); } else { updateImportance(); Loading Loading @@ -495,7 +499,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G if (save) { saveImportance(); } logBlockingHelperCounter(mExitReasonCounter); logBlockingHelperCounter(mExitReason); return false; } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -509,6 +509,36 @@ public class NotificationInfoTest extends SysuiTestCase { anyString(), eq(TEST_UID), eq(true)); } @Test public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing() 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 */); NotificationGuts guts = spy(new NotificationGuts(mContext, null)); when(guts.getWindowToken()).thenReturn(mock(IBinder.class)); doNothing().when(guts).animateClose(anyInt(), anyInt(), anyBoolean()); doNothing().when(guts).setExposed(anyBoolean(), anyBoolean()); guts.setGutsContent(mNotificationInfo); mNotificationInfo.setGutsParent(guts); mNotificationInfo.findViewById(R.id.keep).performClick(); verify(mBlockingHelperManager).dismissCurrentBlockingHelper(); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, times(1)) .setNotificationsEnabledWithImportanceLockForPackage( anyString(), eq(TEST_UID), eq(true)); } @Test public void testCloseControls_blockingHelperDismissedIfShown() throws Exception { mNotificationInfo.bindNotification( Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +11 −7 Original line number Diff line number Diff line Loading @@ -91,22 +91,24 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private boolean mIsForBlockingHelper; private boolean mNegativeUserSentiment; /** Counter tag that describes how the user exit or quit out of this view. */ private String mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_DISMISSED; /** * String that describes how the user exit or quit out of this view, also used as a counter tag. */ private String mExitReason = NotificationCounters.BLOCKING_HELPER_DISMISSED; private OnClickListener mOnKeepShowing = v -> { mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING; mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING; closeControls(v); }; private OnClickListener mOnStopOrMinimizeNotifications = v -> { mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; swapContent(false); }; private OnClickListener mOnUndo = v -> { // Reset exit counter that we'll log and record an undo event separately (not an exit event) mExitReasonCounter = NotificationCounters.BLOCKING_HELPER_DISMISSED; mExitReason = NotificationCounters.BLOCKING_HELPER_DISMISSED; logBlockingHelperCounter(NotificationCounters.BLOCKING_HELPER_UNDO); swapContent(true); }; Loading Loading @@ -300,7 +302,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private void saveImportance() { if (!mIsNonblockable) { if (mCheckSaveListener != null) { // Only go through the lock screen/bouncer if the user didn't hit 'Keep showing'. if (mCheckSaveListener != null && !NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING.equals(mExitReason)) { mCheckSaveListener.checkSave(this::updateImportance, mSbn); } else { updateImportance(); Loading Loading @@ -495,7 +499,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G if (save) { saveImportance(); } logBlockingHelperCounter(mExitReasonCounter); logBlockingHelperCounter(mExitReason); return false; } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -509,6 +509,36 @@ public class NotificationInfoTest extends SysuiTestCase { anyString(), eq(TEST_UID), eq(true)); } @Test public void testCloseControls_nonNullCheckSaveListenerDoesntDelayKeepShowing() 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 */); NotificationGuts guts = spy(new NotificationGuts(mContext, null)); when(guts.getWindowToken()).thenReturn(mock(IBinder.class)); doNothing().when(guts).animateClose(anyInt(), anyInt(), anyBoolean()); doNothing().when(guts).setExposed(anyBoolean(), anyBoolean()); guts.setGutsContent(mNotificationInfo); mNotificationInfo.setGutsParent(guts); mNotificationInfo.findViewById(R.id.keep).performClick(); verify(mBlockingHelperManager).dismissCurrentBlockingHelper(); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, times(1)) .setNotificationsEnabledWithImportanceLockForPackage( anyString(), eq(TEST_UID), eq(true)); } @Test public void testCloseControls_blockingHelperDismissedIfShown() throws Exception { mNotificationInfo.bindNotification( Loading