diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index 0af026eb3509e..02d2b8e4ef0f6 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -76,7 +76,6 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager.Keyg import com.android.systemui.statusbar.notification.NotificationFilter; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.logging.NotificationLogger; -import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController; import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.phone.AutoHideController; @@ -308,7 +307,6 @@ public class Dependency { @Inject Lazy mPackageManagerWrapper; @Inject Lazy mSensorPrivacyController; @Inject Lazy mDockManager; - @Inject Lazy mChannelEditorDialogController; @Inject Lazy mINotificationManager; @Inject Lazy mSysUiStateFlagsContainer; @Inject Lazy mAlarmManager; @@ -498,7 +496,6 @@ public class Dependency { mProviders.put(PackageManagerWrapper.class, mPackageManagerWrapper::get); mProviders.put(SensorPrivacyController.class, mSensorPrivacyController::get); mProviders.put(DockManager.class, mDockManager::get); - mProviders.put(ChannelEditorDialogController.class, mChannelEditorDialogController::get); mProviders.put(INotificationManager.class, mINotificationManager::get); mProviders.put(SysUiState.class, mSysUiStateFlagsContainer::get); mProviders.put(AlarmManager.class, mAlarmManager::get); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java index 78ee5f25b111b..c712287e3fea2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java @@ -51,6 +51,7 @@ import com.android.systemui.statusbar.notification.interruption.NotificationInte import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger; import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl; +import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController; import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController; @@ -111,6 +112,7 @@ public interface NotificationsModule { INotificationManager notificationManager, LauncherApps launcherApps, ShortcutManager shortcutManager, + ChannelEditorDialogController channelEditorDialogController, CurrentUserContextTracker contextTracker, Provider builderProvider) { return new NotificationGutsManager( @@ -123,6 +125,7 @@ public interface NotificationsModule { notificationManager, launcherApps, shortcutManager, + channelEditorDialogController, contextTracker, builderProvider); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt index e75b705112508..87905f2c05bca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt @@ -22,6 +22,7 @@ import android.app.NotificationChannel import android.app.NotificationChannel.DEFAULT_CHANNEL_ID import android.app.NotificationChannelGroup import android.app.NotificationManager.IMPORTANCE_NONE +import android.app.NotificationManager.Importance import android.content.Context import android.content.DialogInterface import android.graphics.Color @@ -37,8 +38,10 @@ import android.view.Window import android.view.WindowInsets.Type.statusBars import android.view.WindowManager import android.widget.TextView + import com.android.internal.annotations.VisibleForTesting import com.android.systemui.R + import javax.inject.Inject import javax.inject.Singleton @@ -59,11 +62,13 @@ private const val TAG = "ChannelDialogController" @Singleton class ChannelEditorDialogController @Inject constructor( c: Context, - private val noMan: INotificationManager + private val noMan: INotificationManager, + private val dialogBuilder: ChannelEditorDialog.Builder ) { val context: Context = c.applicationContext - lateinit var dialog: Dialog + private var prepared = false + private lateinit var dialog: ChannelEditorDialog private var appIcon: Drawable? = null private var appUid: Int? = null @@ -80,7 +85,9 @@ class ChannelEditorDialogController @Inject constructor( // Map from NotificationChannel to importance private val edits = mutableMapOf() - var appNotificationsEnabled = true + private var appNotificationsEnabled = true + // System settings for app notifications + private var appNotificationsCurrentlyEnabled: Boolean? = null // Keep a mapping of NotificationChannel.getGroup() to the actual group name for display @VisibleForTesting @@ -106,10 +113,16 @@ class ChannelEditorDialogController @Inject constructor( this.appNotificationsEnabled = checkAreAppNotificationsOn() this.onSettingsClickListener = onSettingsClickListener + // These will always start out the same + appNotificationsCurrentlyEnabled = appNotificationsEnabled + channelGroupList.clear() channelGroupList.addAll(fetchNotificationChannelGroups()) buildGroupNameLookup() padToFourChannels(channels) + initDialog() + + prepared = true } private fun buildGroupNameLookup() { @@ -157,7 +170,9 @@ class ChannelEditorDialogController @Inject constructor( } fun show() { - initDialog() + if (!prepared) { + throw IllegalStateException("Must call prepareDialogForApp() before calling show()") + } dialog.show() } @@ -178,6 +193,7 @@ class ChannelEditorDialogController @Inject constructor( appUid = null packageName = null appName = null + appNotificationsCurrentlyEnabled = null edits.clear() providedChannels.clear() @@ -188,12 +204,27 @@ class ChannelEditorDialogController @Inject constructor( return groupNameLookup[groupId] ?: "" } - fun proposeEditForChannel(channel: NotificationChannel, edit: Int) { + fun proposeEditForChannel(channel: NotificationChannel, @Importance edit: Int) { if (channel.importance == edit) { edits.remove(channel) } else { edits[channel] = edit } + + dialog.updateDoneButtonText(hasChanges()) + } + + fun proposeSetAppNotificationsEnabled(enabled: Boolean) { + appNotificationsEnabled = enabled + dialog.updateDoneButtonText(hasChanges()) + } + + fun areAppNotificationsEnabled(): Boolean { + return appNotificationsEnabled + } + + private fun hasChanges(): Boolean { + return edits.isNotEmpty() || (appNotificationsEnabled != appNotificationsCurrentlyEnabled) } @Suppress("unchecked_cast") @@ -241,7 +272,7 @@ class ChannelEditorDialogController @Inject constructor( } } - if (appNotificationsEnabled != checkAreAppNotificationsOn()) { + if (appNotificationsEnabled != appNotificationsCurrentlyEnabled) { applyAppNotificationsOn(appNotificationsEnabled) } } @@ -252,7 +283,8 @@ class ChannelEditorDialogController @Inject constructor( } private fun initDialog() { - dialog = Dialog(context) + dialogBuilder.setContext(context) + dialog = dialogBuilder.build() dialog.window?.requestFeature(Window.FEATURE_NO_TITLE) // Prevent a11y readers from reading the first element in the dialog twice @@ -265,7 +297,7 @@ class ChannelEditorDialogController @Inject constructor( onFinishListener?.onChannelEditorDialogFinished() } }) - findViewById(R.id.half_shelf_container).apply { + findViewById(R.id.half_shelf_container)?.apply { controller = this@ChannelEditorDialogController appIcon = this@ChannelEditorDialogController.appIcon appName = this@ChannelEditorDialogController.appName @@ -306,6 +338,28 @@ class ChannelEditorDialogController @Inject constructor( or WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) } +class ChannelEditorDialog(context: Context) : Dialog(context) { + fun updateDoneButtonText(hasChanges: Boolean) { + findViewById(R.id.done_button)?.setText( + if (hasChanges) + R.string.inline_ok_button + else + R.string.inline_done_button) + } + + class Builder @Inject constructor() { + private lateinit var context: Context + fun setContext(context: Context): Builder { + this.context = context + return this + } + + fun build(): ChannelEditorDialog { + return ChannelEditorDialog(context) + } + } +} + interface OnChannelEditorDialogFinishedListener { fun onChannelEditorDialogFinished() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt index 983315ed98e74..b776123129c70 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt @@ -59,7 +59,7 @@ class ChannelEditorListView(c: Context, attrs: AttributeSet) : LinearLayout(c, a } private fun updateRows() { - val enabled = controller.appNotificationsEnabled + val enabled = controller.areAppNotificationsEnabled() val transition = AutoTransition() transition.duration = 200 @@ -114,7 +114,7 @@ class ChannelEditorListView(c: Context, attrs: AttributeSet) : LinearLayout(c, a .getString(R.string.notification_channel_dialog_title, appName) appControlRow.switch.isChecked = enabled appControlRow.switch.setOnCheckedChangeListener { _, b -> - controller.appNotificationsEnabled = b + controller.proposeSetAppNotificationsEnabled(b) updateRows() } } @@ -150,6 +150,7 @@ class ChannelRow(c: Context, attrs: AttributeSet) : LinearLayout(c, attrs) { } override fun onFinishInflate() { + super.onFinishInflate() channelName = findViewById(R.id.channel_name) channelDescription = findViewById(R.id.channel_description) switch = findViewById(R.id.toggle) 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 9c7de2bbf2ae2..06279bd97d7ba 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 @@ -87,6 +87,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx private final VisualStabilityManager mVisualStabilityManager; private final AccessibilityManager mAccessibilityManager; private final HighPriorityProvider mHighPriorityProvider; + private final ChannelEditorDialogController mChannelEditorDialogController; // Dependencies: private final NotificationLockscreenUserManager mLockscreenUserManager = @@ -127,6 +128,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx INotificationManager notificationManager, LauncherApps launcherApps, ShortcutManager shortcutManager, + ChannelEditorDialogController channelEditorDialogController, CurrentUserContextTracker contextTracker, Provider builderProvider) { mContext = context; @@ -140,6 +142,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx mShortcutManager = shortcutManager; mContextTracker = contextTracker; mBuilderProvider = builderProvider; + mChannelEditorDialogController = channelEditorDialogController; } public void setUpWithPresenter(NotificationPresenter presenter, @@ -348,6 +351,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx pmUser, mNotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, packageName, row.getEntry().getChannel(), row.getUniqueChannels(), @@ -390,6 +394,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx notificationInfoView.bindNotification( pmUser, mNotificationManager, + mChannelEditorDialogController, packageName, row.getEntry().getChannel(), row.getUniqueChannels(), 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 12aa4dfaf6fa8..08affa868073b 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 @@ -174,6 +174,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G PackageManager pm, INotificationManager iNotificationManager, VisualStabilityManager visualStabilityManager, + ChannelEditorDialogController channelEditorDialogController, String pkg, NotificationChannel notificationChannel, Set uniqueChannelsInRow, @@ -187,7 +188,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mINotificationManager = iNotificationManager; mMetricsLogger = Dependency.get(MetricsLogger.class); mVisualStabilityManager = visualStabilityManager; - mChannelEditorDialogController = Dependency.get(ChannelEditorDialogController.class); + mChannelEditorDialogController = channelEditorDialogController; mPackageName = pkg; mUniqueChannelsInRow = uniqueChannelsInRow; mNumUniqueChannelsInRow = uniqueChannelsInRow.size(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java index 2189b872da43c..cc5de65293581 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java @@ -17,10 +17,6 @@ package com.android.systemui.statusbar.notification.row; import static android.app.Notification.EXTRA_IS_GROUP_CONVERSATION; -import static android.app.NotificationManager.IMPORTANCE_LOW; -import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; - -import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -39,10 +35,6 @@ import android.os.Parcelable; import android.os.RemoteException; import android.service.notification.StatusBarNotification; import android.text.TextUtils; -import android.transition.ChangeBounds; -import android.transition.Fade; -import android.transition.TransitionManager; -import android.transition.TransitionSet; import android.util.AttributeSet; import android.view.View; import android.view.accessibility.AccessibilityEvent; @@ -51,7 +43,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.android.internal.annotations.VisibleForTesting; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -108,6 +99,7 @@ public class PartialConversationInfo extends LinearLayout implements public void bindNotification( PackageManager pm, INotificationManager iNotificationManager, + ChannelEditorDialogController channelEditorDialogController, String pkg, NotificationChannel notificationChannel, Set uniqueChannelsInRow, @@ -127,7 +119,7 @@ public class PartialConversationInfo extends LinearLayout implements mDelegatePkg = mSbn.getOpPkg(); mIsDeviceProvisioned = isDeviceProvisioned; mIsNonBlockable = isNonBlockable; - mChannelEditorDialogController = Dependency.get(ChannelEditorDialogController.class); + mChannelEditorDialogController = channelEditorDialogController; mUniqueChannelsInRow = uniqueChannelsInRow; bindHeader(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogControllerTest.kt index 8b81a7a29f846..cc2f28eeafa02 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogControllerTest.kt @@ -36,12 +36,14 @@ import org.junit.Assert.assertEquals import org.junit.Before import org.junit.runner.RunWith import org.junit.Test +import org.mockito.Answers import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.eq import org.mockito.Mock +import org.mockito.Mockito +import org.mockito.Mockito.`when` import org.mockito.Mockito.times import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @SmallTest @@ -59,11 +61,16 @@ class ChannelEditorDialogControllerTest : SysuiTestCase() { @Mock private lateinit var mockNoMan: INotificationManager + @Mock(answer = Answers.RETURNS_SELF) + private lateinit var dialogBuilder: ChannelEditorDialog.Builder + @Mock + private lateinit var dialog: ChannelEditorDialog @Before fun setup() { MockitoAnnotations.initMocks(this) - controller = ChannelEditorDialogController(mContext, mockNoMan) + `when`(dialogBuilder.build()).thenReturn(dialog) + controller = ChannelEditorDialogController(mContext, mockNoMan, dialogBuilder) channel1 = NotificationChannel(TEST_CHANNEL, TEST_CHANNEL_NAME, IMPORTANCE_DEFAULT) channel2 = NotificationChannel(TEST_CHANNEL2, TEST_CHANNEL_NAME2, IMPORTANCE_DEFAULT) @@ -147,7 +154,7 @@ class ChannelEditorDialogControllerTest : SysuiTestCase() { controller.prepareDialogForApp(TEST_APP_NAME, TEST_PACKAGE_NAME, TEST_UID, setOf(channel1, channel2), appIcon, clickListener) - controller.appNotificationsEnabled = false + controller.proposeSetAppNotificationsEnabled(false) controller.apply() verify(mockNoMan, times(1)).setNotificationsEnabledForPackage( @@ -162,7 +169,7 @@ class ChannelEditorDialogControllerTest : SysuiTestCase() { controller.prepareDialogForApp(TEST_APP_NAME, TEST_PACKAGE_NAME, TEST_UID, setOf(channel1, channel2), appIcon, clickListener) - controller.appNotificationsEnabled = true + controller.proposeSetAppNotificationsEnabled(true) controller.apply() verify(mockNoMan, times(1)).setNotificationsEnabledForPackage( @@ -171,12 +178,52 @@ class ChannelEditorDialogControllerTest : SysuiTestCase() { @Test fun testSettingsClickListenerNull_noCrash() { + // GIVEN editor dialog group.channels = listOf(channel1, channel2) controller.prepareDialogForApp(TEST_APP_NAME, TEST_PACKAGE_NAME, TEST_UID, setOf(channel1, channel2), appIcon, null) + // WHEN user taps settings // Pass in any old view, it should never actually be used controller.launchSettings(View(context)) + + // THEN no crash + } + + @Test + fun testDoneButtonSaysDone_noChanges() { + // GIVEN the editor dialog with no changes + `when`(dialogBuilder.build()).thenReturn(dialog) + + group.channels = listOf(channel1, channel2) + controller.prepareDialogForApp(TEST_APP_NAME, TEST_PACKAGE_NAME, TEST_UID, + setOf(channel1, channel2), appIcon, null) + + // WHEN the user proposes a change + controller.proposeEditForChannel(channel1, IMPORTANCE_NONE) + + // THEN the "done" button has been updated to "apply" + verify(dialog).updateDoneButtonText(true /* hasChanges */) + } + + @Test + fun testDoneButtonGoesBackToNormal_changeThenNoChange() { + val inOrderDialog = Mockito.inOrder(dialog) + // GIVEN the editor dialog with no changes + `when`(dialogBuilder.build()).thenReturn(dialog) + + group.channels = listOf(channel1, channel2) + controller.prepareDialogForApp(TEST_APP_NAME, TEST_PACKAGE_NAME, TEST_UID, + setOf(channel1, channel2), appIcon, null) + + // WHEN the user proposes a change + controller.proposeEditForChannel(channel1, IMPORTANCE_NONE) + // and WHEN the user sets the importance back to its original value + controller.proposeEditForChannel(channel1, channel1.importance) + + // THEN the "done" button has been changed back to done + inOrderDialog.verify(dialog, times(1)).updateDoneButtonText(eq(true)) + inOrderDialog.verify(dialog, times(1)).updateDoneButtonText(eq(false)) } private val clickListener = object : NotificationInfo.OnSettingsClickListener { 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 5813740712b6e..eeb912e7aac80 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 @@ -123,6 +123,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { @Mock private INotificationManager mINotificationManager; @Mock private LauncherApps mLauncherApps; @Mock private ShortcutManager mShortcutManager; + @Mock private ChannelEditorDialogController mChannelEditorDialogController; @Mock private PeopleNotificationIdentifier mPeopleNotificationIdentifier; @Mock private CurrentUserContextTracker mContextTracker; @Mock(answer = Answers.RETURNS_SELF) @@ -144,7 +145,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase { mGutsManager = new NotificationGutsManager(mContext, mVisualStabilityManager, () -> mStatusBar, mHandler, mAccessibilityManager, mHighPriorityProvider, - mINotificationManager, mLauncherApps, mShortcutManager, mContextTracker, mProvider); + mINotificationManager, mLauncherApps, mShortcutManager, + mChannelEditorDialogController, mContextTracker, mProvider); mGutsManager.setUpWithPresenter(mPresenter, mStackScroller, mCheckSaveListener, mOnSettingsClickListener); mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter); @@ -350,6 +352,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(PackageManager.class), any(INotificationManager.class), eq(mVisualStabilityManager), + eq(mChannelEditorDialogController), eq(statusBarNotification.getPackageName()), any(NotificationChannel.class), anySet(), @@ -381,6 +384,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(PackageManager.class), any(INotificationManager.class), eq(mVisualStabilityManager), + eq(mChannelEditorDialogController), eq(statusBarNotification.getPackageName()), any(NotificationChannel.class), anySet(), @@ -410,6 +414,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase { any(PackageManager.class), any(INotificationManager.class), eq(mVisualStabilityManager), + eq(mChannelEditorDialogController), eq(statusBarNotification.getPackageName()), any(NotificationChannel.class), anySet(), 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 98ef691ee28c9..8ee86a237e320 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 @@ -30,17 +30,13 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -53,13 +49,11 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; -import android.os.IBinder; import android.os.UserHandle; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; -import android.testing.PollingCheck; import android.testing.TestableLooper; import android.testing.UiThreadTest; import android.view.LayoutInflater; @@ -68,7 +62,6 @@ import android.widget.ImageView; import android.widget.TextView; import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; @@ -120,6 +113,8 @@ public class NotificationInfoTest extends SysuiTestCase { private PackageManager mMockPackageManager; @Mock private VisualStabilityManager mVisualStabilityManager; + @Mock + private ChannelEditorDialogController mChannelEditorDialogController; @Before public void setUp() throws Exception { @@ -185,6 +180,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -208,6 +204,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -227,6 +224,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -257,6 +255,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -277,6 +276,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -304,6 +304,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -326,6 +327,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -345,6 +347,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mDefaultNotificationChannel, mDefaultNotificationChannelSet, @@ -368,6 +371,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mDefaultNotificationChannel, mDefaultNotificationChannelSet, @@ -387,6 +391,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -407,6 +412,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -432,6 +438,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -452,6 +459,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -473,6 +481,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -486,6 +495,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -506,6 +516,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, createMultipleChannelSet(MULTIPLE_CHANNEL_COUNT), mEntry, @@ -531,6 +542,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, createMultipleChannelSet(MULTIPLE_CHANNEL_COUNT), @@ -552,6 +564,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, createMultipleChannelSet(MULTIPLE_CHANNEL_COUNT), @@ -573,6 +586,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -596,6 +610,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -614,6 +629,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -632,6 +648,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -653,6 +670,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -677,6 +695,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -701,6 +720,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -726,6 +746,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -751,6 +772,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -782,6 +804,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -814,6 +837,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -846,6 +870,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -881,6 +906,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -915,6 +941,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -940,6 +967,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -968,6 +996,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -999,6 +1028,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -1025,6 +1055,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -1056,6 +1087,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -1080,6 +1112,7 @@ public class NotificationInfoTest extends SysuiTestCase { mMockPackageManager, mMockINotificationManager, mVisualStabilityManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java index c390e3933d7a2..1bfebfb412e7b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java @@ -98,6 +98,8 @@ public class PartialConversationInfoTest extends SysuiTestCase { private INotificationManager mMockINotificationManager; @Mock private PackageManager mMockPackageManager; + @Mock + private ChannelEditorDialogController mChannelEditorDialogController; @Mock private Icon mIcon; @@ -160,6 +162,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -181,6 +184,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -207,6 +211,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -223,6 +228,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -250,6 +256,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -267,6 +274,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -291,6 +299,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -310,6 +319,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -327,6 +337,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -349,6 +360,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -365,6 +377,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet, @@ -383,6 +396,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, + mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mNotificationChannelSet,