Statsd UiEvent logging for notification history.

Events logged:
Notif history on/off/open/close
Notif click (recent/snoozed/older)
Notif delete (older)
Notif package history open/close

Additional background: There are 3 notif history sections: snoozed
notifs, recently dismissed notifs, and older notifs. In the snoozed &
recent sections we still know the notif SBN, so actions on those
events are logged with instance ID. The older-notifs section is
grouped by package, and we no longer know the instance ID.

This change depends on change 11692386 in frameworks/base, which adds
UiEventLogger support for the RankingSelected atom.

Bug: 155061525
Test: Manual (statsd testdrive)
Change-Id: If267fca97c40c1bbd8dfa785814c85927ab36c91
This commit is contained in:
Will Brockman
2020-06-01 11:33:21 -04:00
parent db6309cae2
commit 7f43530a15
4 changed files with 109 additions and 17 deletions

View File

@@ -20,7 +20,6 @@ import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Slog;
@@ -34,6 +33,8 @@ import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.UiEventLogger;
import com.android.settings.R;
public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
@@ -91,13 +92,22 @@ public class NotificationSbnViewHolder extends RecyclerView.ViewHolder {
mDivider.setVisibility(visible ? View.VISIBLE : View.GONE);
}
void addOnClick(String pkg, int userId, PendingIntent pi) {
void addOnClick(int position, String pkg, int uid, int userId, PendingIntent pi,
InstanceId instanceId,
boolean isSnoozed, UiEventLogger uiEventLogger) {
Intent appIntent = itemView.getContext().getPackageManager()
.getLaunchIntentForPackage(pkg);
boolean isPendingIntentValid = pi != null && PendingIntent.getActivity(
itemView.getContext(), 0, pi.getIntent(), PendingIntent.FLAG_NO_CREATE) != null;
if (isPendingIntentValid || appIntent != null) {
itemView.setOnClickListener(v -> {
uiEventLogger.logWithInstanceIdAndPosition(
isSnoozed
? NotificationHistoryActivity.NotificationHistoryEvent
.NOTIFICATION_HISTORY_SNOOZED_ITEM_CLICK
: NotificationHistoryActivity.NotificationHistoryEvent
.NOTIFICATION_HISTORY_RECENT_ITEM_CLICK,
uid, pkg, instanceId, position);
if (pi != null) {
try {
pi.send();