From 2a7418d24e7f41a93837b95330af288e0560c7c6 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Thu, 3 Sep 2020 17:49:16 -0500 Subject: [PATCH] Log persisted bubbles Bug: 167729787 Test: adb shell cmd stats print-logs Change-Id: I07b470212684e1d186f9f4da9d5e6ee3291cfef5 --- .../systemui/bubbles/BubbleController.java | 3 +++ .../android/systemui/bubbles/BubbleData.java | 11 +++++++- .../systemui/bubbles/BubbleLogger.java | 5 +++- .../systemui/bubbles/BubbleLoggerImpl.java | 25 +++++-------------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 4b4e275e5cbd6..734d691f9aaf0 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -458,6 +458,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi mSavedBubbleKeysPerUser = new SparseSetArray<>(); mCurrentUserId = mNotifUserManager.getCurrentUserId(); + mBubbleData.setCurrentUserId(mCurrentUserId); + mNotifUserManager.addUserChangedListener( new NotificationLockscreenUserManager.UserChangedListener() { @Override @@ -466,6 +468,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi mBubbleData.dismissAll(DISMISS_USER_CHANGED); BubbleController.this.restoreBubbles(newUserId); mCurrentUserId = newUserId; + mBubbleData.setCurrentUserId(newUserId); } }); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index a747db680b2ea..bab18ec053ee2 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -35,6 +35,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.R; import com.android.systemui.bubbles.BubbleController.DismissReason; import com.android.systemui.dagger.SysUISingleton; +import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -61,6 +62,8 @@ public class BubbleData { private BubbleLoggerImpl mLogger = new BubbleLoggerImpl(); + private int mCurrentUserId; + private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleData" : TAG_BUBBLES; private static final Comparator BUBBLES_BY_SORT_KEY_DESCENDING = @@ -617,6 +620,10 @@ public class BubbleData { mStateChange.selectionChanged = true; } + void setCurrentUserId(int uid) { + mCurrentUserId = uid; + } + /** * Logs the bubble UI event. * @@ -634,7 +641,9 @@ public class BubbleData { if (provider == null) { mLogger.logStackUiChanged(packageName, action, bubbleCount, normalX, normalY); } else if (provider.getKey().equals(BubbleOverflow.KEY)) { - mLogger.logShowOverflow(packageName, action, bubbleCount, normalX, normalY); + if (action == SysUiStatsLog.BUBBLE_UICHANGED__ACTION__EXPANDED) { + mLogger.logShowOverflow(packageName, mCurrentUserId); + } } else { mLogger.logBubbleUiChanged((Bubble) provider, packageName, action, bubbleCount, normalX, normalY, bubbleIndex); diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java index 1e6eb8c5c89bf..86ba8c5c7192c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLogger.java @@ -53,7 +53,10 @@ public interface BubbleLogger extends UiEventLogger { BUBBLE_OVERFLOW_REMOVE_BACK_TO_STACK(489), @UiEvent(doc = "User blocked notification from bubbling, remove bubble from overflow.") - BUBBLE_OVERFLOW_REMOVE_BLOCKED(490); + BUBBLE_OVERFLOW_REMOVE_BLOCKED(490), + + @UiEvent(doc = "User selected the overflow.") + BUBBLE_OVERFLOW_SELECTED(600); private final int mId; diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java index d702cc4e0062b..2d90c8626a0e0 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleLoggerImpl.java @@ -16,6 +16,8 @@ package com.android.systemui.bubbles; +import android.os.UserHandle; + import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.shared.system.SysUiStatsLog; @@ -31,11 +33,7 @@ public class BubbleLoggerImpl extends UiEventLoggerImpl implements BubbleLogger * @param e UI event */ public void log(Bubble b, UiEventEnum e) { - if (b.getInstanceId() == null) { - // Added from persistence -- TODO log this with specific event? - return; - } - logWithInstanceId(e, b.getAppUid(), b.getPackageName(), b.getInstanceId()); + super.log(e, b.getUser().getIdentifier(), b.getPackageName()); } /** @@ -82,20 +80,9 @@ public class BubbleLoggerImpl extends UiEventLoggerImpl implements BubbleLogger false /* isAppForeground (unused) */); } - void logShowOverflow(String packageName, int action, int bubbleCount, float normalX, - float normalY) { - SysUiStatsLog.write(SysUiStatsLog.BUBBLE_UI_CHANGED, - packageName, - BubbleOverflow.KEY /* notification channel */, - 0 /* notification ID */, - 0 /* bubble position */, - bubbleCount, - action, - normalX, - normalY, - false /* unread bubble */, - false /* on-going bubble */, - false /* isAppForeground (unused) */); + void logShowOverflow(String packageName, int currentUserId) { + super.log(BubbleLogger.Event.BUBBLE_OVERFLOW_SELECTED, currentUserId, + packageName); } void logBubbleUiChanged(Bubble bubble, String packageName, int action, int bubbleCount,