Merge "Statsd log of dismiss all notifications event." into rvc-dev am: ed05940533
Change-Id: I970a8e8d6fa25ceb54211a7ee11a8990d800150e
This commit is contained in:
@@ -20,7 +20,7 @@ import com.android.internal.logging.InstanceId;
|
|||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fake logger that queues up logged events for inspection.
|
* 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;
|
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
|
@Override
|
||||||
public void log(UiEventEnum event) {
|
public void log(UiEventEnum event) {
|
||||||
@@ -67,7 +80,7 @@ public class UiEventLoggerFake implements UiEventLogger {
|
|||||||
public void log(UiEventEnum event, int uid, String packageName) {
|
public void log(UiEventEnum event, int uid, String packageName) {
|
||||||
final int eventId = event.getId();
|
final int eventId = event.getId();
|
||||||
if (eventId > 0) {
|
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) {
|
InstanceId instance) {
|
||||||
final int eventId = event.getId();
|
final int eventId = event.getId();
|
||||||
if (eventId > 0) {
|
if (eventId > 0) {
|
||||||
mLogs.offer(new FakeUiEvent(eventId, uid, packageName, instance));
|
mLogs.add(new FakeUiEvent(eventId, uid, packageName, instance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import android.os.Handler;
|
|||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
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.R;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dagger.qualifiers.UiBackground;
|
import com.android.systemui.dagger.qualifiers.UiBackground;
|
||||||
@@ -155,6 +157,13 @@ public interface NotificationsModule {
|
|||||||
expansionStateLogger);
|
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} */
|
/** Provides an instance of {@link NotificationBlockingHelperManager} */
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ import android.widget.ScrollView;
|
|||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.graphics.ColorUtils;
|
import com.android.internal.graphics.ColorUtils;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
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.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.statusbar.IStatusBarService;
|
import com.android.internal.statusbar.IStatusBarService;
|
||||||
import com.android.internal.statusbar.NotificationVisibility;
|
import com.android.internal.statusbar.NotificationVisibility;
|
||||||
@@ -502,6 +504,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
protected final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||||
|
protected final UiEventLogger mUiEventLogger;
|
||||||
private final NotificationRemoteInputManager mRemoteInputManager =
|
private final NotificationRemoteInputManager mRemoteInputManager =
|
||||||
Dependency.get(NotificationRemoteInputManager.class);
|
Dependency.get(NotificationRemoteInputManager.class);
|
||||||
private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
|
private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
|
||||||
@@ -547,7 +550,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
FeatureFlags featureFlags,
|
FeatureFlags featureFlags,
|
||||||
NotifPipeline notifPipeline,
|
NotifPipeline notifPipeline,
|
||||||
NotificationEntryManager entryManager,
|
NotificationEntryManager entryManager,
|
||||||
NotifCollection notifCollection
|
NotifCollection notifCollection,
|
||||||
|
UiEventLogger uiEventLogger
|
||||||
) {
|
) {
|
||||||
super(context, attrs, 0, 0);
|
super(context, attrs, 0, 0);
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
@@ -649,6 +653,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
mDynamicPrivacyController = dynamicPrivacyController;
|
mDynamicPrivacyController = dynamicPrivacyController;
|
||||||
mStatusbarStateController = statusBarStateController;
|
mStatusbarStateController = statusBarStateController;
|
||||||
initializeForegroundServiceSection(fgsFeatureController);
|
initializeForegroundServiceSection(fgsFeatureController);
|
||||||
|
mUiEventLogger = uiEventLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeForegroundServiceSection(
|
private void initializeForegroundServiceSection(
|
||||||
@@ -5524,7 +5529,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
private void clearNotifications(
|
@VisibleForTesting
|
||||||
|
void clearNotifications(
|
||||||
@SelectedRows int selection,
|
@SelectedRows int selection,
|
||||||
boolean closeShade) {
|
boolean closeShade) {
|
||||||
// animate-swipe all dismissable notifications, then animate the shade closed
|
// 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 (viewsToRemove.isEmpty()) {
|
||||||
if (closeShade) {
|
if (closeShade) {
|
||||||
Dependency.get(ShadeController.class).animateCollapsePanels(
|
Dependency.get(ShadeController.class).animateCollapsePanels(
|
||||||
@@ -6737,4 +6746,35 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
public static final int ROWS_HIGH_PRIORITY = 1;
|
public static final int ROWS_HIGH_PRIORITY = 1;
|
||||||
/** Only rows where entry.isHighPriority() is false. */
|
/** Only rows where entry.isHighPriority() is false. */
|
||||||
public static final int ROWS_GENTLE = 2;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
|
import com.android.internal.logging.testing.UiEventLoggerFake;
|
||||||
import com.android.systemui.ExpandHelper;
|
import com.android.systemui.ExpandHelper;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
@@ -139,6 +140,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
private UserChangedListener mUserChangedListener;
|
private UserChangedListener mUserChangedListener;
|
||||||
private TestableNotificationEntryManager mEntryManager;
|
private TestableNotificationEntryManager mEntryManager;
|
||||||
private int mOriginalInterruptionModelSetting;
|
private int mOriginalInterruptionModelSetting;
|
||||||
|
private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -214,7 +216,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
mFeatureFlags,
|
mFeatureFlags,
|
||||||
mock(NotifPipeline.class),
|
mock(NotifPipeline.class),
|
||||||
mEntryManager,
|
mEntryManager,
|
||||||
mock(NotifCollection.class)
|
mock(NotifCollection.class),
|
||||||
|
mUiEventLoggerFake
|
||||||
);
|
);
|
||||||
verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
|
verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
|
||||||
mUserChangedListener = userChangedCaptor.getValue();
|
mUserChangedListener = userChangedCaptor.getValue();
|
||||||
@@ -506,6 +509,22 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
MetricsProto.MetricsEvent.TYPE_ACTION));
|
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) {
|
private void setBarStateForTest(int state) {
|
||||||
// Can't inject this through the listener or we end up on the actual implementation
|
// 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.
|
// 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);
|
mEntryManager.addActiveNotificationForTest(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addActiveNotificationsToManager(List<NotificationEntry> entries) {
|
|
||||||
mEntryManager.setActiveNotificationList(entries);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ public class EventsTest extends SysuiTestCase {
|
|||||||
assertEquals(mExpectedMetrics[1], logs.remove().getCategory());
|
assertEquals(mExpectedMetrics[1], logs.remove().getCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Queue<UiEventLoggerFake.FakeUiEvent> events = mUiEventLogger.getLogs();
|
|
||||||
if (mUiEvent != null) {
|
if (mUiEvent != null) {
|
||||||
assertEquals(mUiEvent.getId(), events.remove().eventId);
|
assertEquals(1, mUiEventLogger.numLogs());
|
||||||
|
assertEquals(mUiEvent.getId(), mUiEventLogger.eventId(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user