summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/logging/testing/UiEventLoggerFake.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java44
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java25
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/volume/EventsTest.java4
5 files changed, 91 insertions, 14 deletions
diff --git a/core/java/com/android/internal/logging/testing/UiEventLoggerFake.java b/core/java/com/android/internal/logging/testing/UiEventLoggerFake.java
index 130ee64ac887..91ba0dfbcc54 100644
--- a/core/java/com/android/internal/logging/testing/UiEventLoggerFake.java
+++ b/core/java/com/android/internal/logging/testing/UiEventLoggerFake.java
@@ -20,7 +20,7 @@ import com.android.internal.logging.InstanceId;
import com.android.internal.logging.UiEventLogger;
import java.util.LinkedList;
-import java.util.Queue;
+import java.util.List;
/**
* Fake logger that queues up logged events for inspection.
@@ -52,11 +52,24 @@ public class UiEventLoggerFake implements UiEventLogger {
}
}
- private Queue<FakeUiEvent> mLogs = new LinkedList<>();
+ private List<FakeUiEvent> mLogs = new LinkedList<>();
- public Queue<FakeUiEvent> getLogs() {
+ /** Returns list of all logging events recorded. */
+ public List<FakeUiEvent> getLogs() {
return mLogs;
}
+ /** Returns number of logging events recorded. */
+ public int numLogs() {
+ return mLogs.size();
+ }
+ /** Returns a particular logging event. */
+ public FakeUiEvent get(int index) {
+ return mLogs.get(index);
+ }
+ /** Returns event id (as integer) of a particular logging event. */
+ public int eventId(int index) {
+ return mLogs.get(index).eventId;
+ }
@Override
public void log(UiEventEnum event) {
@@ -67,7 +80,7 @@ public class UiEventLoggerFake implements UiEventLogger {
public void log(UiEventEnum event, int uid, String packageName) {
final int eventId = event.getId();
if (eventId > 0) {
- mLogs.offer(new FakeUiEvent(eventId, uid, packageName));
+ mLogs.add(new FakeUiEvent(eventId, uid, packageName));
}
}
@@ -76,7 +89,7 @@ public class UiEventLoggerFake implements UiEventLogger {
InstanceId instance) {
final int eventId = event.getId();
if (eventId > 0) {
- mLogs.offer(new FakeUiEvent(eventId, uid, packageName, instance));
+ mLogs.add(new FakeUiEvent(eventId, uid, packageName, instance));
}
}
}
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 d0b553db2100..3c0ac7ef53fc 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
@@ -21,6 +21,8 @@ import android.os.Handler;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.UiEventLogger;
+import com.android.internal.logging.UiEventLoggerImpl;
import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
@@ -153,6 +155,13 @@ public interface NotificationsModule {
expansionStateLogger);
}
+ /** Provides an instance of {@link com.android.internal.logging.UiEventLogger} */
+ @Singleton
+ @Provides
+ static UiEventLogger provideUiEventLogger() {
+ return new UiEventLoggerImpl();
+ }
+
/** Provides an instance of {@link NotificationBlockingHelperManager} */
@Singleton
@Provides
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 1bd9bbecc26e..cfcbd885754d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -81,6 +81,8 @@ import android.widget.ScrollView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.UiEvent;
+import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
@@ -502,6 +504,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
@VisibleForTesting
protected final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
+ protected final UiEventLogger mUiEventLogger;
private final NotificationRemoteInputManager mRemoteInputManager =
Dependency.get(NotificationRemoteInputManager.class);
private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
@@ -547,7 +550,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
FeatureFlags featureFlags,
NotifPipeline notifPipeline,
NotificationEntryManager entryManager,
- NotifCollection notifCollection
+ NotifCollection notifCollection,
+ UiEventLogger uiEventLogger
) {
super(context, attrs, 0, 0);
Resources res = getResources();
@@ -649,6 +653,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
mDynamicPrivacyController = dynamicPrivacyController;
mStatusbarStateController = statusBarStateController;
initializeForegroundServiceSection(fgsFeatureController);
+ mUiEventLogger = uiEventLogger;
}
private void initializeForegroundServiceSection(
@@ -5524,7 +5529,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
- private void clearNotifications(
+ @VisibleForTesting
+ void clearNotifications(
@SelectedRows int selection,
boolean closeShade) {
// animate-swipe all dismissable notifications, then animate the shade closed
@@ -5567,6 +5573,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
}
}
+ // Log dismiss event even if there's nothing to dismiss
+ mUiEventLogger.log(NotificationPanelEvent.fromSelection(selection));
+
if (viewsToRemove.isEmpty()) {
if (closeShade) {
Dependency.get(ShadeController.class).animateCollapsePanels(
@@ -6737,4 +6746,35 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
public static final int ROWS_HIGH_PRIORITY = 1;
/** Only rows where entry.isHighPriority() is false. */
public static final int ROWS_GENTLE = 2;
+
+ /**
+ * Enum for UiEvent logged from this class
+ */
+ enum NotificationPanelEvent implements UiEventLogger.UiEventEnum {
+ INVALID(0),
+ @UiEvent(doc = "User dismissed all notifications from notification panel.")
+ DISMISS_ALL_NOTIFICATIONS_PANEL(312),
+ @UiEvent(doc = "User dismissed all silent notifications from notification panel.")
+ DISMISS_SILENT_NOTIFICATIONS_PANEL(314);
+ private final int mId;
+ NotificationPanelEvent(int id) {
+ mId = id;
+ }
+ @Override public int getId() {
+ return mId;
+ }
+
+ public static UiEventLogger.UiEventEnum fromSelection(@SelectedRows int selection) {
+ if (selection == ROWS_ALL) {
+ return DISMISS_ALL_NOTIFICATIONS_PANEL;
+ }
+ if (selection == ROWS_GENTLE) {
+ return DISMISS_SILENT_NOTIFICATIONS_PANEL;
+ }
+ if (NotificationStackScrollLayout.DEBUG) {
+ throw new IllegalArgumentException("Unexpected selection" + selection);
+ }
+ return INVALID;
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index 0cb658540f0d..ef2071ef090e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -46,6 +46,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
@@ -139,6 +140,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
private UserChangedListener mUserChangedListener;
private TestableNotificationEntryManager mEntryManager;
private int mOriginalInterruptionModelSetting;
+ private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
@Before
@@ -214,7 +216,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mFeatureFlags,
mock(NotifPipeline.class),
mEntryManager,
- mock(NotifCollection.class)
+ mock(NotifCollection.class),
+ mUiEventLoggerFake
);
verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
mUserChangedListener = userChangedCaptor.getValue();
@@ -506,6 +509,22 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
MetricsProto.MetricsEvent.TYPE_ACTION));
}
+ @Test
+ public void testClearNotifications_All() {
+ mStackScroller.clearNotifications(NotificationStackScrollLayout.ROWS_ALL, true);
+ assertEquals(1, mUiEventLoggerFake.numLogs());
+ assertEquals(NotificationStackScrollLayout.NotificationPanelEvent
+ .DISMISS_ALL_NOTIFICATIONS_PANEL.getId(), mUiEventLoggerFake.eventId(0));
+ }
+
+ @Test
+ public void testClearNotifications_Gentle() {
+ mStackScroller.clearNotifications(NotificationStackScrollLayout.ROWS_GENTLE, false);
+ assertEquals(1, mUiEventLoggerFake.numLogs());
+ assertEquals(NotificationStackScrollLayout.NotificationPanelEvent
+ .DISMISS_SILENT_NOTIFICATIONS_PANEL.getId(), mUiEventLoggerFake.eventId(0));
+ }
+
private void setBarStateForTest(int state) {
// Can't inject this through the listener or we end up on the actual implementation
// rather than the mock because the spy just coppied the anonymous inner /shruggie.
@@ -517,8 +536,4 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mEntryManager.addActiveNotificationForTest(e);
}
}
-
- private void addActiveNotificationsToManager(List<NotificationEntry> entries) {
- mEntryManager.setActiveNotificationList(entries);
- }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/EventsTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/EventsTest.java
index 701b2fab5f85..a853f1d84176 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/EventsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/EventsTest.java
@@ -102,9 +102,9 @@ public class EventsTest extends SysuiTestCase {
assertEquals(mExpectedMetrics[1], logs.remove().getCategory());
}
}
- Queue<UiEventLoggerFake.FakeUiEvent> events = mUiEventLogger.getLogs();
if (mUiEvent != null) {
- assertEquals(mUiEvent.getId(), events.remove().eventId);
+ assertEquals(1, mUiEventLogger.numLogs());
+ assertEquals(mUiEvent.getId(), mUiEventLogger.eventId(0));
}
}