Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +15 −11 Original line number Diff line number Diff line Loading @@ -102,9 +102,16 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G }; private OnClickListener mOnStopOrMinimizeNotifications = v -> { Runnable saveImportance = () -> { mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; swapContent(false); }; if (mCheckSaveListener != null) { mCheckSaveListener.checkSave(saveImportance, mSbn); } else { saveImportance.run(); } }; private OnClickListener mOnUndo = v -> { // Reset exit counter that we'll log and record an undo event separately (not an exit event) Loading Loading @@ -300,17 +307,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private void saveImportance() { if (!mIsNonblockable) { // Only go through the lock screen/bouncer if the user hit 'Stop notifications'. // Otherwise, update the importance immediately. if (mCheckSaveListener != null && NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS.equals( mExitReason)) { mCheckSaveListener.checkSave(this::updateImportance, mSbn); } else { updateImportance(); } } } /** * Commits the updated importance values on the background thread. Loading Loading @@ -513,6 +512,11 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G return getHeight(); } @VisibleForTesting public boolean isAnimating() { return mExpandAnimation != null && mExpandAnimation.isRunning(); } /** * Runnable to either update the given channel (with a new importance value) or, if no channel * is provided, update notifications enabled state for the package. Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -158,6 +158,11 @@ public class NotificationInfoTest extends SysuiTestCase { PollingCheck.waitFor(1000, () -> VISIBLE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility()); } private void ensureNoUndoButton() { PollingCheck.waitFor(1000, () -> GONE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility() && !mNotificationInfo.isAnimating()); } private void waitForStopButton() { PollingCheck.waitFor(1000, () -> VISIBLE == mNotificationInfo.findViewById(R.id.prompt).getVisibility()); Loading Loading @@ -567,9 +572,6 @@ public class NotificationInfoTest extends SysuiTestCase { 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)); } Loading Loading @@ -787,7 +789,7 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test public void testCloseControlsDoesNotUpdateIfCheckSaveListenerIsNoOp() throws Exception { public void testBlockDoesNothingIfCheckSaveListenerIsNoOp() throws Exception { mNotificationChannel.setImportance(IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, Loading @@ -795,10 +797,10 @@ public class NotificationInfoTest extends SysuiTestCase { }, null, null, true); mNotificationInfo.findViewById(R.id.block).performClick(); waitForUndoButton(); mTestableLooper.processAllMessages(); ensureNoUndoButton(); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel)); } Loading @@ -813,6 +815,10 @@ public class NotificationInfoTest extends SysuiTestCase { }, null, null, false); mNotificationInfo.findViewById(R.id.block).performClick(); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel)); waitForUndoButton(); mNotificationInfo.handleCloseControls(true, false); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +15 −11 Original line number Diff line number Diff line Loading @@ -102,9 +102,16 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G }; private OnClickListener mOnStopOrMinimizeNotifications = v -> { Runnable saveImportance = () -> { mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS; swapContent(false); }; if (mCheckSaveListener != null) { mCheckSaveListener.checkSave(saveImportance, mSbn); } else { saveImportance.run(); } }; private OnClickListener mOnUndo = v -> { // Reset exit counter that we'll log and record an undo event separately (not an exit event) Loading Loading @@ -300,17 +307,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private void saveImportance() { if (!mIsNonblockable) { // Only go through the lock screen/bouncer if the user hit 'Stop notifications'. // Otherwise, update the importance immediately. if (mCheckSaveListener != null && NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS.equals( mExitReason)) { mCheckSaveListener.checkSave(this::updateImportance, mSbn); } else { updateImportance(); } } } /** * Commits the updated importance values on the background thread. Loading Loading @@ -513,6 +512,11 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G return getHeight(); } @VisibleForTesting public boolean isAnimating() { return mExpandAnimation != null && mExpandAnimation.isRunning(); } /** * Runnable to either update the given channel (with a new importance value) or, if no channel * is provided, update notifications enabled state for the package. Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +12 −6 Original line number Diff line number Diff line Loading @@ -158,6 +158,11 @@ public class NotificationInfoTest extends SysuiTestCase { PollingCheck.waitFor(1000, () -> VISIBLE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility()); } private void ensureNoUndoButton() { PollingCheck.waitFor(1000, () -> GONE == mNotificationInfo.findViewById(R.id.confirmation).getVisibility() && !mNotificationInfo.isAnimating()); } private void waitForStopButton() { PollingCheck.waitFor(1000, () -> VISIBLE == mNotificationInfo.findViewById(R.id.prompt).getVisibility()); Loading Loading @@ -567,9 +572,6 @@ public class NotificationInfoTest extends SysuiTestCase { 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)); } Loading Loading @@ -787,7 +789,7 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test public void testCloseControlsDoesNotUpdateIfCheckSaveListenerIsNoOp() throws Exception { public void testBlockDoesNothingIfCheckSaveListenerIsNoOp() throws Exception { mNotificationChannel.setImportance(IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, Loading @@ -795,10 +797,10 @@ public class NotificationInfoTest extends SysuiTestCase { }, null, null, true); mNotificationInfo.findViewById(R.id.block).performClick(); waitForUndoButton(); mTestableLooper.processAllMessages(); ensureNoUndoButton(); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel)); } Loading @@ -813,6 +815,10 @@ public class NotificationInfoTest extends SysuiTestCase { }, null, null, false); mNotificationInfo.findViewById(R.id.block).performClick(); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel)); waitForUndoButton(); mNotificationInfo.handleCloseControls(true, false); Loading