From 8ceb579ec7684ca1a38eb617ec54d3e1d6074558 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 11 Apr 2017 11:32:44 -0400 Subject: [PATCH] Changing importance should record user locked field. Test: runtest systemui Change-Id: Ia200acb2e2a2b2163fd4a728a2bfc5430070c580 --- .../android/systemui/statusbar/NotificationInfo.java | 1 + .../systemui/statusbar/NotificationInfoTest.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java index b4b1cd3409f6b..fab4e592a9aa0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java @@ -274,6 +274,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G MetricsLogger.action(mContext, MetricsEvent.ACTION_SAVE_IMPORTANCE, selectedImportance - mStartingUserImportance); mSingleNotificationChannel.setImportance(selectedImportance); + mSingleNotificationChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); try { mINotificationManager.updateNotificationChannelForPackage( mPkg, mAppUid, mSingleNotificationChannel); 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 2bb7f3b2b36d9..66385a1dfb01e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java @@ -61,6 +61,7 @@ import com.android.systemui.SysuiTestCase; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import java.util.ArrayList; import java.util.Arrays; @@ -585,11 +586,16 @@ public class NotificationInfoTest extends SysuiTestCase { mNotificationChannel.getImportance(), mSbn, null, null, null, null, Collections.singleton(TEST_PACKAGE_NAME)); - Switch enabledSwitch = (Switch) mNotificationInfo.findViewById(R.id.channel_enabled_switch); + Switch enabledSwitch = mNotificationInfo.findViewById(R.id.channel_enabled_switch); enabledSwitch.setChecked(false); mNotificationInfo.handleCloseControls(true); + + ArgumentCaptor updated = + ArgumentCaptor.forClass(NotificationChannel.class); verify(mMockINotificationManager, times(1)).updateNotificationChannelForPackage( - eq(TEST_PACKAGE_NAME), anyInt(), eq(mNotificationChannel)); + anyString(), anyInt(), updated.capture()); + assertTrue((updated.getValue().getUserLockedFields() + & NotificationChannel.USER_LOCKED_IMPORTANCE) != 0); } @Test