From 4e7ae02ce0a26ffae98adb1df5ab702bb3b211da Mon Sep 17 00:00:00 2001 From: Geoffrey Pitsch Date: Wed, 11 Jan 2017 12:48:09 -0500 Subject: [PATCH] Do not select an importance for unspecified notifications Test: runtest systemui-notification Bug: 34164846 Change-Id: I4988ce26264853fd9ab84ae02e995641edf933cd --- .../android/systemui/statusbar/NotificationGuts.java | 4 ++-- .../systemui/statusbar/NotificationGutsTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index 088f5382b6845..c7adb60c25f36 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -313,7 +313,7 @@ public class NotificationGuts extends LinearLayout { } else if (mHighImportanceButton.isChecked()) { return NotificationManager.IMPORTANCE_HIGH; } else { - return NotificationManager.IMPORTANCE_NONE; + return NotificationManager.IMPORTANCE_UNSPECIFIED; } } @@ -333,10 +333,10 @@ public class NotificationGuts extends LinearLayout { // Set to current importance setting switch (importance) { + case NotificationManager.IMPORTANCE_UNSPECIFIED: case NotificationManager.IMPORTANCE_NONE: break; case NotificationManager.IMPORTANCE_MIN: - case NotificationManager.IMPORTANCE_UNSPECIFIED: mMinImportanceButton.setChecked(true); break; case NotificationManager.IMPORTANCE_LOW: diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsTest.java index 2cd6dbd17a7c2..c65f7150de0e9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsTest.java @@ -208,6 +208,18 @@ public class NotificationGutsTest { anyString(), anyInt(), any()); } + @Test + @UiThreadTest + public void testCloseControls_DoesNotUpdateNotificationChannelIfUnspecified() throws Exception { + mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED); + mNotificationGuts.bindNotification(mMockPackageManager, mMockINotificationManager, + mMockStatusBarNotification, null, null, null); + + mNotificationGuts.closeControls(-1, -1, true); + verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( + anyString(), anyInt(), any()); + } + @Test @UiThreadTest public void testCloseControls_CallsUpdateNotificationChannelIfChanged() throws Exception {