Add blocking helper logging
The added logging events are: blocking helper view displayed or
dismissed, any button click within the view, undo clicks and
system suggests of blocking helper.
* Move some of the getLogMaker logic of server's NotificationRecord
class to the common StatusBarNotification class.
* Use the StatusBarNotification.getLogMaker to produce blocking helper
logging.
* Add logging in the NotificationInfo for interaction and display of
the blocking helper view.
* Add logging in the NotificationBlockingHelperManager for system
suggests of blocking helper.
Bug: 112482290
Test: unittests and manual - viewed produced logs.
Change-Id: I3a5267d55faba21f6668d35ff8aa12deb0dc5921
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java
index 607d96d..6df72fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationBlockingHelperManager.java
@@ -20,11 +20,13 @@
.USER_SENTIMENT_NEGATIVE;
import android.content.Context;
+import android.metrics.LogMaker;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.Dependency;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -58,6 +60,8 @@
*/
private boolean mIsShadeExpanded;
+ private MetricsLogger mMetricsLogger = new MetricsLogger();
+
@Inject
public NotificationBlockingHelperManager(Context context) {
mContext = context;
@@ -100,6 +104,11 @@
mBlockingHelperRow = row;
mBlockingHelperRow.setBlockingHelperShowing(true);
+ // Log triggering of blocking helper by the system. This log line
+ // should be emitted before the "display" log line.
+ mMetricsLogger.write(
+ getLogMaker().setSubtype(MetricsEvent.BLOCKING_HELPER_TRIGGERED_BY_SYSTEM));
+
// We don't care about the touch origin (x, y) since we're opening guts without any
// explicit user interaction.
manager.openGuts(mBlockingHelperRow, 0, 0, menuRow.getLongpressMenuItem(mContext));
@@ -153,6 +162,13 @@
|| mNonBlockablePkgs.contains(makeChannelKey(packageName, channelName));
}
+ private LogMaker getLogMaker() {
+ return mBlockingHelperRow.getStatusBarNotification()
+ .getLogMaker()
+ .setCategory(MetricsEvent.NOTIFICATION_ITEM)
+ .setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER);
+ }
+
// Format must stay in sync with frameworks/base/core/res/res/values/config.xml
// config_nonBlockableNotificationPackages
private String makeChannelKey(String pkg, String channel) {
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 b1eab80..5253e38 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
@@ -123,11 +123,15 @@
private OnClickListener mOnKeepShowing = v -> {
mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING;
closeControls(v);
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_STAY_SILENT));
};
private OnClickListener mOnToggleSilent = v -> {
Runnable saveImportance = () -> {
swapContent(ACTION_TOGGLE_SILENT, true /* animate */);
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_ALERT_ME));
};
if (mCheckSaveListener != null) {
mCheckSaveListener.checkSave(saveImportance, mSbn);
@@ -139,6 +143,8 @@
private OnClickListener mOnStopOrMinimizeNotifications = v -> {
Runnable saveImportance = () -> {
swapContent(ACTION_BLOCK, true /* animate */);
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_BLOCKED));
};
if (mCheckSaveListener != null) {
mCheckSaveListener.checkSave(saveImportance, mSbn);
@@ -153,6 +159,8 @@
logBlockingHelperCounter(NotificationCounters.BLOCKING_HELPER_UNDO);
mMetricsLogger.write(importanceChangeLogMaker().setType(MetricsEvent.TYPE_DISMISS));
swapContent(ACTION_UNDO, true /* animate */);
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_CLICK_UNDO));
};
public NotificationInfo(Context context, AttributeSet attrs) {
@@ -251,6 +259,9 @@
bindHeader();
bindPrompt();
bindButtons();
+
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_DISPLAY));
}
private void bindHeader() throws RemoteException {
@@ -588,6 +599,8 @@
confirmation.setAlpha(1f);
header.setVisibility(VISIBLE);
header.setAlpha(1f);
+ mMetricsLogger.write(getLogMaker().setType(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
+ .setSubtype(MetricsEvent.BLOCKING_HELPER_DISMISS));
}
@Override
@@ -733,4 +746,8 @@
}
}
}
+
+ private LogMaker getLogMaker() {
+ return mSbn.getLogMaker().setCategory(MetricsEvent.NOTIFICATION_ITEM);
+ }
}