Loading packages/SystemUI/aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -1968,6 +1968,13 @@ flag { bug: "380901479" } flag { name: "permission_helper_ui_rich_ongoing" namespace: "systemui" description: "[RONs] Guards inline permission helper for demoting RONs" bug: "379186372" } flag { name: "aod_ui_rich_ongoing" namespace: "systemui" Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/BundleNotificationInfoTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -198,7 +198,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); // and the feedback button is clicked, final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading Loading @@ -253,7 +254,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading Loading @@ -294,7 +296,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.kt +4 −0 Original line number Diff line number Diff line Loading @@ -544,6 +544,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(true), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -580,6 +581,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -614,6 +616,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -651,6 +654,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java +82 −45 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name); assertTrue(textView.getText().toString().contains("App Name")); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility()); Loading @@ -213,7 +213,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon); assertEquals(iconDrawable, iconView.getDrawable()); } Loading @@ -235,7 +235,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(GONE, nameView.getVisibility()); } Loading Loading @@ -266,7 +266,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(VISIBLE, nameView.getVisibility()); assertTrue(nameView.getText().toString().contains("Proxied")); Loading @@ -289,7 +289,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(GONE, groupNameView.getVisibility()); } Loading Loading @@ -317,7 +317,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(View.VISIBLE, groupNameView.getVisibility()); assertEquals("Test Group Name", groupNameView.getText()); Loading @@ -340,7 +340,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(TEST_CHANNEL_NAME, textView.getText()); } Loading @@ -362,7 +362,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(GONE, textView.getVisibility()); } Loading @@ -388,7 +388,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } Loading @@ -410,7 +411,8 @@ public class NotificationInfoTest extends SysuiTestCase { true, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } Loading @@ -436,7 +438,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); settingsButton.performClick(); Loading @@ -461,7 +464,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } Loading @@ -486,7 +490,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } Loading @@ -508,7 +513,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.bindNotification( mMockPackageManager, mMockINotificationManager, Loading @@ -524,7 +530,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertEquals(View.VISIBLE, settingsButton.getVisibility()); } Loading @@ -546,7 +553,8 @@ public class NotificationInfoTest extends SysuiTestCase { true, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text); assertEquals(View.VISIBLE, view.getVisibility()); assertEquals(mContext.getString(R.string.notification_unblockable_desc), Loading Loading @@ -589,7 +597,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_call_text); assertEquals(View.VISIBLE, view.getVisibility()); assertEquals(mContext.getString(R.string.notification_unblockable_call_desc), Loading Loading @@ -632,7 +641,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(GONE, mNotificationInfo.findViewById(R.id.non_configurable_call_text).getVisibility()); assertEquals(VISIBLE, Loading @@ -659,7 +669,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); } Loading @@ -681,7 +692,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); } Loading @@ -705,7 +717,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.automatic).isSelected()); } Loading @@ -726,7 +739,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected()); } Loading @@ -747,7 +761,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected()); } Loading @@ -768,7 +783,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( anyString(), eq(TEST_UID), any()); Loading @@ -791,7 +807,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(1, mUiEventLogger.numLogs()); assertEquals(NotificationControlsEvent.NOTIFICATION_CONTROLS_OPEN.getId(), mUiEventLogger.eventId(0)); Loading @@ -815,7 +832,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mTestableLooper.processAllMessages(); Loading @@ -842,7 +860,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mTestableLooper.processAllMessages(); Loading @@ -869,7 +888,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.automatic).performClick(); mTestableLooper.processAllMessages(); Loading Loading @@ -897,7 +917,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); Loading @@ -924,7 +945,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); Loading Loading @@ -959,7 +981,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); Loading Loading @@ -987,7 +1010,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1028,7 +1052,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1065,7 +1090,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.automatic).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1097,7 +1123,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1133,7 +1160,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1171,7 +1199,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.handleCloseControls(false, false); Loading Loading @@ -1202,7 +1231,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1240,7 +1270,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1269,7 +1300,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1300,7 +1332,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1335,7 +1368,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1368,7 +1402,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1401,7 +1436,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); Loading @@ -1427,7 +1463,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertFalse(mNotificationInfo.willBeRemoved()); } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfoTest.java 0 → 100644 +156 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.row; import static android.app.Notification.EXTRA_BUILDER_APPLICATION_INFO; import static android.app.NotificationManager.IMPORTANCE_LOW; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.INotificationManager; import android.app.Notification; import android.app.NotificationChannel; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.UserHandle; import android.platform.test.annotations.EnableFlags; import android.service.notification.StatusBarNotification; import android.telecom.TelecomManager; import android.testing.TestableLooper; import android.view.LayoutInflater; import android.view.View; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.systemui.Dependency; import com.android.systemui.SysuiTestCase; import com.android.systemui.res.R; import com.android.systemui.statusbar.notification.AssistantFeedbackController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.concurrent.CountDownLatch; @SmallTest @RunWith(AndroidJUnit4.class) @TestableLooper.RunWithLooper public class PromotedNotificationInfoTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test_package"; private static final int TEST_UID = 1; private static final String TEST_CHANNEL = "test_channel"; private static final String TEST_CHANNEL_NAME = "TEST CHANNEL NAME"; private TestableLooper mTestableLooper; private PromotedNotificationInfo mInfo; private NotificationChannel mNotificationChannel; private StatusBarNotification mSbn; private NotificationEntry mEntry; private UiEventLoggerFake mUiEventLogger = new UiEventLoggerFake(); @Rule public MockitoRule mockito = MockitoJUnit.rule(); @Mock private MetricsLogger mMetricsLogger; @Mock private INotificationManager mMockINotificationManager; @Mock private PackageManager mMockPackageManager; @Mock private OnUserInteractionCallback mOnUserInteractionCallback; @Mock private ChannelEditorDialogController mChannelEditorDialogController; @Mock private AssistantFeedbackController mAssistantFeedbackController; @Mock private TelecomManager mTelecomManager; @Before public void setUp() throws Exception { final ApplicationInfo applicationInfo = new ApplicationInfo(); applicationInfo.uid = TEST_UID; // non-zero mNotificationChannel = new NotificationChannel( TEST_CHANNEL, TEST_CHANNEL_NAME, IMPORTANCE_LOW); Notification notification = new Notification(); notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, applicationInfo); mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, notification, UserHandle.getUserHandleForUid(TEST_UID), null, 0); mEntry = new NotificationEntryBuilder().setSbn(mSbn).build(); when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(false); mTestableLooper = TestableLooper.get(this); mContext.addMockSystemService(TelecomManager.class, mTelecomManager); mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper()); // Inflate the layout final LayoutInflater layoutInflater = LayoutInflater.from(mContext); mInfo = (PromotedNotificationInfo) layoutInflater.inflate( R.layout.promoted_notification_info, null); mInfo.setGutsParent(mock(NotificationGuts.class)); // Our view is never attached to a window so the View#post methods in // BundleNotificationInfo never get called. Setting this will skip the post and do the // action immediately. mInfo.mSkipPost = true; } @Test @EnableFlags(android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI) public void testBindNotification_setsOnClickListenerForFeedback() throws Exception { // Bind the notification to the Info object final CountDownLatch latch = new CountDownLatch(1); mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, mOnUserInteractionCallback, mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mEntry, null, null, mUiEventLogger, true, false, true, mAssistantFeedbackController, mMetricsLogger, null); // Click demote button final View demoteButton = mInfo.findViewById(R.id.promoted_demote); demoteButton.performClick(); // verify that notiManager tried to demote verify(mMockINotificationManager, atLeastOnce()).setCanBePromoted(TEST_PACKAGE_NAME, mSbn.getUid(), false, true); } } Loading
packages/SystemUI/aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -1968,6 +1968,13 @@ flag { bug: "380901479" } flag { name: "permission_helper_ui_rich_ongoing" namespace: "systemui" description: "[RONs] Guards inline permission helper for demoting RONs" bug: "379186372" } flag { name: "aod_ui_rich_ongoing" namespace: "systemui" Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/BundleNotificationInfoTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -198,7 +198,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); // and the feedback button is clicked, final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading Loading @@ -253,7 +254,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading Loading @@ -294,7 +296,8 @@ public class BundleNotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View feedbackButton = mInfo.findViewById(R.id.notification_guts_bundle_feedback); feedbackButton.performClick(); Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.kt +4 −0 Original line number Diff line number Diff line Loading @@ -544,6 +544,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(true), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -580,6 +581,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -614,6 +616,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading Loading @@ -651,6 +654,7 @@ class NotificationGutsManagerTest(flags: FlagsParameterization) : SysuiTestCase( /* wasShownHighPriority = */ eq(false), eq(assistantFeedbackController), eq(metricsLogger), any<View.OnClickListener>(), ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java +82 −45 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name); assertTrue(textView.getText().toString().contains("App Name")); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility()); Loading @@ -213,7 +213,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon); assertEquals(iconDrawable, iconView.getDrawable()); } Loading @@ -235,7 +235,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(GONE, nameView.getVisibility()); } Loading Loading @@ -266,7 +266,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name); assertEquals(VISIBLE, nameView.getVisibility()); assertTrue(nameView.getText().toString().contains("Proxied")); Loading @@ -289,7 +289,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(GONE, groupNameView.getVisibility()); } Loading Loading @@ -317,7 +317,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name); assertEquals(View.VISIBLE, groupNameView.getVisibility()); assertEquals("Test Group Name", groupNameView.getText()); Loading @@ -340,7 +340,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(TEST_CHANNEL_NAME, textView.getText()); } Loading @@ -362,7 +362,7 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(GONE, textView.getVisibility()); } Loading @@ -388,7 +388,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } Loading @@ -410,7 +411,8 @@ public class NotificationInfoTest extends SysuiTestCase { true, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } Loading @@ -436,7 +438,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); settingsButton.performClick(); Loading @@ -461,7 +464,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } Loading @@ -486,7 +490,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertTrue(settingsButton.getVisibility() != View.VISIBLE); } Loading @@ -508,7 +513,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.bindNotification( mMockPackageManager, mMockINotificationManager, Loading @@ -524,7 +530,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final View settingsButton = mNotificationInfo.findViewById(R.id.info); assertEquals(View.VISIBLE, settingsButton.getVisibility()); } Loading @@ -546,7 +553,8 @@ public class NotificationInfoTest extends SysuiTestCase { true, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text); assertEquals(View.VISIBLE, view.getVisibility()); assertEquals(mContext.getString(R.string.notification_unblockable_desc), Loading Loading @@ -589,7 +597,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_call_text); assertEquals(View.VISIBLE, view.getVisibility()); assertEquals(mContext.getString(R.string.notification_unblockable_call_desc), Loading Loading @@ -632,7 +641,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(GONE, mNotificationInfo.findViewById(R.id.non_configurable_call_text).getVisibility()); assertEquals(VISIBLE, Loading @@ -659,7 +669,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); } Loading @@ -681,7 +692,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic).getVisibility()); assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility()); } Loading @@ -705,7 +717,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.automatic).isSelected()); } Loading @@ -726,7 +739,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected()); } Loading @@ -747,7 +761,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected()); } Loading @@ -768,7 +783,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mTestableLooper.processAllMessages(); verify(mMockINotificationManager, never()).updateNotificationChannelForPackage( anyString(), eq(TEST_UID), any()); Loading @@ -791,7 +807,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(1, mUiEventLogger.numLogs()); assertEquals(NotificationControlsEvent.NOTIFICATION_CONTROLS_OPEN.getId(), mUiEventLogger.eventId(0)); Loading @@ -815,7 +832,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mTestableLooper.processAllMessages(); Loading @@ -842,7 +860,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mTestableLooper.processAllMessages(); Loading @@ -869,7 +888,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.automatic).performClick(); mTestableLooper.processAllMessages(); Loading Loading @@ -897,7 +917,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); Loading @@ -924,7 +945,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); mTestableLooper.processAllMessages(); Loading Loading @@ -959,7 +981,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.handleCloseControls(true, false); Loading Loading @@ -987,7 +1010,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1028,7 +1052,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1065,7 +1090,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.automatic).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1097,7 +1123,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1133,7 +1160,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1171,7 +1199,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.handleCloseControls(false, false); Loading Loading @@ -1202,7 +1231,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1240,7 +1270,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, true, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.silence).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1269,7 +1300,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertEquals(mContext.getString(R.string.inline_done_button), ((TextView) mNotificationInfo.findViewById(R.id.done)).getText()); Loading Loading @@ -1300,7 +1332,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1335,7 +1368,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1368,7 +1402,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); mNotificationInfo.findViewById(R.id.done).performClick(); Loading Loading @@ -1401,7 +1436,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); mNotificationInfo.findViewById(R.id.alert).performClick(); Loading @@ -1427,7 +1463,8 @@ public class NotificationInfoTest extends SysuiTestCase { false, false, mAssistantFeedbackController, mMetricsLogger); mMetricsLogger, null); assertFalse(mNotificationInfo.willBeRemoved()); } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/row/PromotedNotificationInfoTest.java 0 → 100644 +156 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.row; import static android.app.Notification.EXTRA_BUILDER_APPLICATION_INFO; import static android.app.NotificationManager.IMPORTANCE_LOW; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.INotificationManager; import android.app.Notification; import android.app.NotificationChannel; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.UserHandle; import android.platform.test.annotations.EnableFlags; import android.service.notification.StatusBarNotification; import android.telecom.TelecomManager; import android.testing.TestableLooper; import android.view.LayoutInflater; import android.view.View; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.systemui.Dependency; import com.android.systemui.SysuiTestCase; import com.android.systemui.res.R; import com.android.systemui.statusbar.notification.AssistantFeedbackController; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import java.util.concurrent.CountDownLatch; @SmallTest @RunWith(AndroidJUnit4.class) @TestableLooper.RunWithLooper public class PromotedNotificationInfoTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test_package"; private static final int TEST_UID = 1; private static final String TEST_CHANNEL = "test_channel"; private static final String TEST_CHANNEL_NAME = "TEST CHANNEL NAME"; private TestableLooper mTestableLooper; private PromotedNotificationInfo mInfo; private NotificationChannel mNotificationChannel; private StatusBarNotification mSbn; private NotificationEntry mEntry; private UiEventLoggerFake mUiEventLogger = new UiEventLoggerFake(); @Rule public MockitoRule mockito = MockitoJUnit.rule(); @Mock private MetricsLogger mMetricsLogger; @Mock private INotificationManager mMockINotificationManager; @Mock private PackageManager mMockPackageManager; @Mock private OnUserInteractionCallback mOnUserInteractionCallback; @Mock private ChannelEditorDialogController mChannelEditorDialogController; @Mock private AssistantFeedbackController mAssistantFeedbackController; @Mock private TelecomManager mTelecomManager; @Before public void setUp() throws Exception { final ApplicationInfo applicationInfo = new ApplicationInfo(); applicationInfo.uid = TEST_UID; // non-zero mNotificationChannel = new NotificationChannel( TEST_CHANNEL, TEST_CHANNEL_NAME, IMPORTANCE_LOW); Notification notification = new Notification(); notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, applicationInfo); mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, notification, UserHandle.getUserHandleForUid(TEST_UID), null, 0); mEntry = new NotificationEntryBuilder().setSbn(mSbn).build(); when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(false); mTestableLooper = TestableLooper.get(this); mContext.addMockSystemService(TelecomManager.class, mTelecomManager); mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper()); // Inflate the layout final LayoutInflater layoutInflater = LayoutInflater.from(mContext); mInfo = (PromotedNotificationInfo) layoutInflater.inflate( R.layout.promoted_notification_info, null); mInfo.setGutsParent(mock(NotificationGuts.class)); // Our view is never attached to a window so the View#post methods in // BundleNotificationInfo never get called. Setting this will skip the post and do the // action immediately. mInfo.mSkipPost = true; } @Test @EnableFlags(android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI) public void testBindNotification_setsOnClickListenerForFeedback() throws Exception { // Bind the notification to the Info object final CountDownLatch latch = new CountDownLatch(1); mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, mOnUserInteractionCallback, mChannelEditorDialogController, TEST_PACKAGE_NAME, mNotificationChannel, mEntry, null, null, mUiEventLogger, true, false, true, mAssistantFeedbackController, mMetricsLogger, null); // Click demote button final View demoteButton = mInfo.findViewById(R.id.promoted_demote); demoteButton.performClick(); // verify that notiManager tried to demote verify(mMockINotificationManager, atLeastOnce()).setCanBePromoted(TEST_PACKAGE_NAME, mSbn.getUid(), false, true); } }