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

@@ -49,11 +49,11 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.ContrastColorUtil;
import com.android.settings.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -70,8 +70,11 @@ public class NotificationSbnAdapter extends
private boolean mInNightMode;
private @UserIdInt int mCurrentUser;
private List<Integer> mEnabledProfiles = new ArrayList<>();
private boolean mIsSnoozed;
private UiEventLogger mUiEventLogger;
public NotificationSbnAdapter(Context context, PackageManager pm, UserManager um) {
public NotificationSbnAdapter(Context context, PackageManager pm, UserManager um,
boolean isSnoozed, UiEventLogger uiEventLogger) {
mContext = context;
mPm = pm;
mUserBadgeCache = new HashMap<>();
@@ -89,6 +92,9 @@ public class NotificationSbnAdapter extends
}
}
setHasStableIds(true);
// If true, this is the panel for snoozed notifs, otherwise the one for dismissed notifs.
mIsSnoozed = isSnoozed;
mUiEventLogger = uiEventLogger;
}
@Override
@@ -116,8 +122,9 @@ public class NotificationSbnAdapter extends
mUserBadgeCache.put(userId, profile);
}
holder.setProfileBadge(mUserBadgeCache.get(userId));
holder.addOnClick(sbn.getPackageName(), sbn.getUserId(),
sbn.getNotification().contentIntent);
holder.addOnClick(position, sbn.getPackageName(), sbn.getUid(), sbn.getUserId(),
sbn.getNotification().contentIntent, sbn.getInstanceId(), mIsSnoozed,
mUiEventLogger);
holder.itemView.setOnLongClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(EXTRA_APP_PACKAGE, sbn.getPackageName())