From f58cef4154be5839778e5c8ba786fb88542bd2ea Mon Sep 17 00:00:00 2001 From: Alex Mang Date: Tue, 24 Mar 2020 14:32:03 -0700 Subject: [PATCH] Adding automatic option in long press menu Automatic will be the default selected mode unless the user has overridden the channel with their preferred alert setting Test: manually on device Change-Id: Ia3202725699dcfc3f6bfeb94a91b48025a96c7e9 --- .../drawable/ic_notifications_automatic.xml | 24 ++ .../SystemUI/res/layout/notification_info.xml | 53 ++++- packages/SystemUI/res/values/strings.xml | 6 + .../row/NotificationGutsManager.java | 3 +- .../notification/row/NotificationInfo.java | 70 +++++- .../row/NotificationGutsManagerTest.java | 9 +- .../row/NotificationInfoTest.java | 219 +++++++++++++++--- 7 files changed, 336 insertions(+), 48 deletions(-) create mode 100644 packages/SystemUI/res/drawable/ic_notifications_automatic.xml diff --git a/packages/SystemUI/res/drawable/ic_notifications_automatic.xml b/packages/SystemUI/res/drawable/ic_notifications_automatic.xml new file mode 100644 index 0000000000000..7b29a85b929c2 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_notifications_automatic.xml @@ -0,0 +1,24 @@ + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/notification_info.xml b/packages/SystemUI/res/layout/notification_info.xml index 1c7c22653f9fa..92b3ff335cba5 100644 --- a/packages/SystemUI/res/layout/notification_info.xml +++ b/packages/SystemUI/res/layout/notification_info.xml @@ -149,6 +149,58 @@ asked for it --> android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical"> + + + + + + + android:maxWidth="125dp" style="@style/TextAppearance.NotificationInfo.Button"/> - diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 86e3914c96481..d2a5095fdf368 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1838,6 +1838,9 @@ Bubble + + Automatic + No sound or vibration @@ -1853,6 +1856,9 @@ Keeps your attention with a floating shortcut to this content. + + Have the system determine if this notification should make sound or vibration + Shows at top of conversation section, appears as floating bubble, displays profile picture on lock screen diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java index 9f02d0481d9be..70121251c6e12 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java @@ -390,7 +390,8 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx onAppSettingsClick, mDeviceProvisionedController.isDeviceProvisioned(), row.getIsNonblockable(), - mHighPriorityProvider.isHighPriority(row.getEntry())); + mHighPriorityProvider.isHighPriority(row.getEntry()), + NotificationViewHierarchyManager.showFeedback(row.getEntry())); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java index a131ebef77dbb..310f1d6419cda 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java @@ -89,6 +89,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private TextView mPriorityDescriptionView; private TextView mSilentDescriptionView; + private TextView mAutomaticDescriptionView; private INotificationManager mINotificationManager; private PackageManager mPm; @@ -107,12 +108,14 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private boolean mWasShownHighPriority; private boolean mPressedApply; private boolean mPresentingChannelEditorDialog = false; + private boolean mShowAutomaticSetting; /** * The last importance level chosen by the user. Null if the user has not chosen an importance * level; non-null once the user takes an action which indicates an explicit preference. */ @Nullable private Integer mChosenImportance; + private boolean mIsAutomaticChosen; private boolean mIsSingleDefaultChannel; private boolean mIsNonblockable; private StatusBarNotification mSbn; @@ -126,15 +129,23 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G @VisibleForTesting boolean mSkipPost = false; + // used by standard ui + private OnClickListener mOnAutomatic = v -> { + mIsAutomaticChosen = true; + applyAlertingBehavior(BEHAVIOR_AUTOMATIC, true /* userTriggered */); + }; + // used by standard ui private OnClickListener mOnAlert = v -> { mChosenImportance = IMPORTANCE_DEFAULT; + mIsAutomaticChosen = false; applyAlertingBehavior(BEHAVIOR_ALERTING, true /* userTriggered */); }; // used by standard ui private OnClickListener mOnSilent = v -> { mChosenImportance = IMPORTANCE_LOW; + mIsAutomaticChosen = false; applyAlertingBehavior(BEHAVIOR_SILENT, true /* userTriggered */); }; @@ -154,6 +165,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mPriorityDescriptionView = findViewById(R.id.alert_summary); mSilentDescriptionView = findViewById(R.id.silence_summary); + mAutomaticDescriptionView = findViewById(R.id.automatic_summary); } // Specify a CheckSaveListener to override when/if the user's changes are committed. @@ -184,7 +196,8 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G OnAppSettingsClickListener onAppSettingsClick, boolean isDeviceProvisioned, boolean isNonblockable, - boolean wasShownHighPriority) + boolean wasShownHighPriority, + boolean showAutomaticSetting) throws RemoteException { mINotificationManager = iNotificationManager; mMetricsLogger = Dependency.get(MetricsLogger.class); @@ -205,6 +218,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mAppUid = mSbn.getUid(); mDelegatePkg = mSbn.getOpPkg(); mIsDeviceProvisioned = isDeviceProvisioned; + mShowAutomaticSetting = showAutomaticSetting; int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( pkg, mAppUid, false /* includeDeleted */); @@ -257,9 +271,15 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G silent.setOnClickListener(mOnSilent); alert.setOnClickListener(mOnAlert); - int behavior = mWasShownHighPriority - ? BEHAVIOR_ALERTING - : BEHAVIOR_SILENT; + View automatic = findViewById(R.id.automatic); + if (mShowAutomaticSetting) { + automatic.setVisibility(VISIBLE); + automatic.setOnClickListener(mOnAutomatic); + } else { + automatic.setVisibility(GONE); + } + + int behavior = getAlertingBehavior(); applyAlertingBehavior(behavior, false /* userTriggered */); } @@ -411,7 +431,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G bgHandler.post( new UpdateImportanceRunnable(mINotificationManager, mPackageName, mAppUid, mNumUniqueChannelsInRow == 1 ? mSingleNotificationChannel : null, - mStartingChannelImportance, newImportance)); + mStartingChannelImportance, newImportance, mIsAutomaticChosen)); mVisualStabilityManager.temporarilyAllowReordering(); } } @@ -444,23 +464,39 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G View alert = findViewById(R.id.alert); View silence = findViewById(R.id.silence); + View automatic = findViewById(R.id.automatic); switch (behavior) { case BEHAVIOR_ALERTING: mPriorityDescriptionView.setVisibility(VISIBLE); mSilentDescriptionView.setVisibility(GONE); + mAutomaticDescriptionView.setVisibility(GONE); post(() -> { alert.setSelected(true); silence.setSelected(false); + automatic.setSelected(false); }); break; case BEHAVIOR_SILENT: mSilentDescriptionView.setVisibility(VISIBLE); mPriorityDescriptionView.setVisibility(GONE); + mAutomaticDescriptionView.setVisibility(GONE); post(() -> { alert.setSelected(false); silence.setSelected(true); + automatic.setSelected(false); + }); + break; + + case BEHAVIOR_AUTOMATIC: + mAutomaticDescriptionView.setVisibility(VISIBLE); + mPriorityDescriptionView.setVisibility(GONE); + mSilentDescriptionView.setVisibility(GONE); + post(() -> { + automatic.setSelected(true); + alert.setSelected(false); + silence.setSelected(false); }); break; @@ -468,7 +504,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G throw new IllegalArgumentException("Unrecognized alerting behavior: " + behavior); } - boolean isAChange = mWasShownHighPriority != (behavior == BEHAVIOR_ALERTING); + boolean isAChange = getAlertingBehavior() != behavior; TextView done = findViewById(R.id.done); done.setText(isAChange ? R.string.inline_ok_button @@ -594,25 +630,31 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private final @Nullable NotificationChannel mChannelToUpdate; private final int mCurrentImportance; private final int mNewImportance; + private final boolean mUnlockImportance; public UpdateImportanceRunnable(INotificationManager notificationManager, String packageName, int appUid, @Nullable NotificationChannel channelToUpdate, - int currentImportance, int newImportance) { + int currentImportance, int newImportance, boolean unlockImportance) { mINotificationManager = notificationManager; mPackageName = packageName; mAppUid = appUid; mChannelToUpdate = channelToUpdate; mCurrentImportance = currentImportance; mNewImportance = newImportance; + mUnlockImportance = unlockImportance; } @Override public void run() { try { if (mChannelToUpdate != null) { - mChannelToUpdate.setImportance(mNewImportance); - mChannelToUpdate.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); + if (mUnlockImportance) { + mChannelToUpdate.unlockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); + } else { + mChannelToUpdate.setImportance(mNewImportance); + mChannelToUpdate.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); + } mINotificationManager.updateNotificationChannelForPackage( mPackageName, mAppUid, mChannelToUpdate); } else { @@ -662,9 +704,17 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G .setSubtype(MetricsEvent.BLOCKING_HELPER_UNKNOWN); } + private @AlertingBehavior int getAlertingBehavior() { + if (mShowAutomaticSetting && !mSingleNotificationChannel.hasUserSetImportance()) { + return BEHAVIOR_AUTOMATIC; + } + return mWasShownHighPriority ? BEHAVIOR_ALERTING : BEHAVIOR_SILENT; + } + @Retention(SOURCE) - @IntDef({BEHAVIOR_ALERTING, BEHAVIOR_SILENT}) + @IntDef({BEHAVIOR_ALERTING, BEHAVIOR_SILENT, BEHAVIOR_AUTOMATIC}) private @interface AlertingBehavior {} private static final int BEHAVIOR_ALERTING = 0; private static final int BEHAVIOR_SILENT = 1; + private static final int BEHAVIOR_AUTOMATIC = 2; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java index da7d249cc5ef8..b5cba2cfa5b7d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java @@ -361,7 +361,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(NotificationInfo.OnAppSettingsClickListener.class), eq(false), eq(false), - eq(true) /* wasShownHighPriority */); + eq(true), /* wasShownHighPriority */ + eq(false) /* showAutomaticSetting */); } @Test @@ -393,7 +394,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(NotificationInfo.OnAppSettingsClickListener.class), eq(true), eq(false), - eq(false) /* wasShownHighPriority */); + eq(false), /* wasShownHighPriority */ + eq(false) /* showAutomaticSetting */); } @Test @@ -423,7 +425,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(NotificationInfo.OnAppSettingsClickListener.class), eq(false), eq(false), - eq(false) /* wasShownHighPriority */); + eq(false), /* wasShownHighPriority */ + eq(false) /* showAutomaticSetting */); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java index 6bf60721cd8ed..05e1c3d3cc259 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java @@ -189,7 +189,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name); assertTrue(textView.getText().toString().contains("App Name")); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility()); @@ -213,7 +214,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon); assertEquals(iconDrawable, iconView.getDrawable()); } @@ -233,7 +235,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(GONE, nameView.getVisibility()); } @@ -262,7 +265,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(VISIBLE, nameView.getVisibility()); assertTrue(nameView.getText().toString().contains("Proxied")); @@ -283,7 +287,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(GONE, groupNameView.getVisibility()); } @@ -309,7 +314,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(View.VISIBLE, groupNameView.getVisibility()); assertEquals("Test Group Name", groupNameView.getText()); @@ -330,7 +336,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(TEST_CHANNEL_NAME, textView.getText()); } @@ -350,7 +357,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(GONE, textView.getVisibility()); } @@ -374,7 +382,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } @@ -394,7 +403,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, true, - true); + true, + false); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } @@ -418,7 +428,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final View settingsButton = mNotificationInfo.findViewById(R.id.info); settingsButton.performClick(); @@ -441,7 +452,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } @@ -464,7 +476,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, false, false, - true); + true, + false); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } @@ -484,7 +497,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.bindNotification( mMockPackageManager, mMockINotificationManager, @@ -498,7 +512,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertEquals(View.VISIBLE, settingsButton.getVisibility()); } @@ -521,7 +536,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, true, - true); + true, + false); mNotificationInfo.findViewById(R.id.info).performClick(); // Verify that listener was triggered. @@ -545,7 +561,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); final TextView channelNameView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(GONE, channelNameView.getVisibility()); @@ -567,7 +584,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); assertEquals(GONE, mNotificationInfo.findViewById( R.id.interruptiveness_settings).getVisibility()); assertEquals(VISIBLE, mNotificationInfo.findViewById( @@ -589,7 +607,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, true, - true); + true, + false); final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text); assertEquals(View.VISIBLE, view.getVisibility()); assertEquals(mContext.getString(R.string.notification_unblockable_desc), @@ -598,6 +617,69 @@ public class NotificationInfoTest extends SysuiTestCase { mNotificationInfo.findViewById(R.id.interruptiveness_settings).getVisibility()); } + @Test + public void testBindNotification_automaticIsVisible() throws Exception { + mNotificationInfo.bindNotification( + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + mChannelEditorDialogController, + TEST_PACKAGE_NAME, + mNotificationChannel, + mNotificationChannelSet, + mEntry, + null, + null, + true, + false, + true, + true); + assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); + assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); + } + + @Test + public void testBindNotification_automaticIsGone() throws Exception { + mNotificationInfo.bindNotification( + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + mChannelEditorDialogController, + TEST_PACKAGE_NAME, + mNotificationChannel, + mNotificationChannelSet, + mEntry, + null, + null, + true, + false, + true, + false); + assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); + assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); + } + + @Test + public void testBindNotification_automaticIsSelected() throws Exception { + mNotificationChannel.unlockFields(USER_LOCKED_IMPORTANCE); + mNotificationInfo.bindNotification( + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + mChannelEditorDialogController, + TEST_PACKAGE_NAME, + mNotificationChannel, + mNotificationChannelSet, + mEntry, + null, + null, + true, + false, + true, + true); + assertTrue(mNotificationInfo.findViewById(R.id.automatic).isSelected()); + } + @Test public void testBindNotification_alertIsSelected() throws Exception { mNotificationInfo.bindNotification( @@ -613,7 +695,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected()); } @@ -632,6 +715,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected()); } @@ -651,7 +735,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( anyString(), eq(TEST_UID), any()); @@ -673,6 +758,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); mNotificationInfo.findViewById(R.id.alert).performClick(); @@ -698,7 +784,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.findViewById(R.id.silence).performClick(); mTestableLooper.processAllMessages(); @@ -706,6 +793,32 @@ public class NotificationInfoTest extends SysuiTestCase { anyString(), eq(TEST_UID), any()); } + @Test + public void testDoesNotUpdateNotificationChannelAfterImportanceChangedAutomatic() + throws Exception { + mNotificationChannel.setImportance(IMPORTANCE_DEFAULT); + mNotificationInfo.bindNotification( + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + mChannelEditorDialogController, + TEST_PACKAGE_NAME, + mNotificationChannel, + mNotificationChannelSet, + mEntry, + null, + null, + true, + false, + true, + false); + + mNotificationInfo.findViewById(R.id.automatic).performClick(); + mTestableLooper.processAllMessages(); + verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( + anyString(), eq(TEST_UID), any()); + } + @Test public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnchanged() throws Exception { @@ -723,7 +836,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); @@ -749,7 +863,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.handleCloseControls(true, false); @@ -775,7 +890,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); @@ -807,6 +923,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); mNotificationInfo.findViewById(R.id.alert).performClick(); @@ -823,6 +940,35 @@ public class NotificationInfoTest extends SysuiTestCase { assertEquals(IMPORTANCE_DEFAULT, updated.getValue().getImportance()); } + @Test + public void testAutomaticUnlocksUserImportance() throws Exception { + mNotificationChannel.setImportance(IMPORTANCE_DEFAULT); + mNotificationChannel.lockFields(USER_LOCKED_IMPORTANCE); + mNotificationInfo.bindNotification( + mMockPackageManager, + mMockINotificationManager, + mVisualStabilityManager, + mChannelEditorDialogController, + TEST_PACKAGE_NAME, + mNotificationChannel, + mNotificationChannelSet, + mEntry, + null, + null, + true, + false, + false, + false); + + mNotificationInfo.findViewById(R.id.automatic).performClick(); + mNotificationInfo.findViewById(R.id.done).performClick(); + mNotificationInfo.handleCloseControls(true, false); + + mTestableLooper.processAllMessages(); + assertTrue(mNotificationChannel.hasUserSetImportance()); + assertEquals(mNotificationChannel.getImportance(), IMPORTANCE_DEFAULT); + } + @Test public void testSilenceCallsUpdateNotificationChannel_channelImportanceUnspecified() throws Exception { @@ -840,7 +986,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); @@ -873,6 +1020,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); assertEquals(mContext.getString(R.string.inline_done_button), @@ -909,6 +1057,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); assertEquals(mContext.getString(R.string.inline_done_button), @@ -944,7 +1093,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - true); + true, + false); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); @@ -970,6 +1120,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); assertEquals(mContext.getString(R.string.inline_done_button), @@ -999,6 +1150,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); mNotificationInfo.findViewById(R.id.alert).performClick(); @@ -1031,6 +1183,7 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, + false, false); mNotificationInfo.findViewById(R.id.alert).performClick(); @@ -1058,8 +1211,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - false - ); + false, + false); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); @@ -1090,8 +1243,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - false - ); + false, + false); mNotificationInfo.findViewById(R.id.alert).performClick(); @@ -1115,8 +1268,8 @@ public class NotificationInfoTest extends SysuiTestCase { null, true, false, - false - ); + false, + false); assertFalse(mNotificationInfo.willBeRemoved()); }