Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 221212c6 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Add logging required to diagnose the multi-entry issues

Bug: 230540148
Bug: 227254780
Test: atest StatusBarNotificationActivityStarterTest
Change-Id: I2d39596f46dce196503c51e37b7eb28f805b9ee4
parent 1b025f37
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.notification;

import android.content.Intent;
import android.service.notification.StatusBarNotification;
import android.view.View;

import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -29,7 +28,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
 */
public interface NotificationActivityStarter {
    /** Called when the user clicks on the surface of a notification. */
    void onNotificationClicked(StatusBarNotification sbn, ExpandableNotificationRow row);
    void onNotificationClicked(NotificationEntry entry, ExpandableNotificationRow row);

    /** Called when the user clicks on a button in the notification guts which fires an intent. */
    void startNotificationGutsIntent(Intent intent, int appUid,
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public final class NotificationClicker implements View.OnClickListener {
            mBubblesOptional.get().collapseStack();
        }

        mNotificationActivityStarter.onNotificationClicked(entry.getSbn(), row);
        mNotificationActivityStarter.onNotificationClicked(entry, row);
    }

    private boolean isMenuVisible(ExpandableNotificationRow row) {
+5 −5
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class NotificationClickerLogger @Inject constructor(
) {
    fun logOnClick(entry: NotificationEntry) {
        buffer.log(TAG, LogLevel.DEBUG, {
            str1 = entry.key
            str1 = entry.logKey
            str2 = entry.ranking.channel.id
        }, {
            "CLICK $str1 (channel=$str2)"
@@ -36,7 +36,7 @@ class NotificationClickerLogger @Inject constructor(

    fun logMenuVisible(entry: NotificationEntry) {
        buffer.log(TAG, LogLevel.DEBUG, {
            str1 = entry.key
            str1 = entry.logKey
        }, {
            "Ignoring click on $str1; menu is visible"
        })
@@ -44,7 +44,7 @@ class NotificationClickerLogger @Inject constructor(

    fun logParentMenuVisible(entry: NotificationEntry) {
        buffer.log(TAG, LogLevel.DEBUG, {
            str1 = entry.key
            str1 = entry.logKey
        }, {
            "Ignoring click on $str1; parent menu is visible"
        })
@@ -52,7 +52,7 @@ class NotificationClickerLogger @Inject constructor(

    fun logChildrenExpanded(entry: NotificationEntry) {
        buffer.log(TAG, LogLevel.DEBUG, {
            str1 = entry.key
            str1 = entry.logKey
        }, {
            "Ignoring click on $str1; children are expanded"
        })
@@ -60,7 +60,7 @@ class NotificationClickerLogger @Inject constructor(

    fun logGutsExposed(entry: NotificationEntry) {
        buffer.log(TAG, LogLevel.DEBUG, {
            str1 = entry.key
            str1 = entry.logKey
        }, {
            "Ignoring click on $str1; guts are exposed"
        })
+10 −3
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@ import android.widget.ImageView;

import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.util.Compile;

/**
 * A util class for various reusable functions
@@ -74,13 +75,19 @@ public class NotificationUtils {
        return (int) (dimensionPixelSize * factor);
    }

    private static final boolean INCLUDE_HASH_CODE_IN_LIST_ENTRY_LOG_KEY = false;

    /** Get the notification key, reformatted for logging, for the (optional) entry */
    public static String logKey(NotificationEntry entry) {
    public static String logKey(ListEntry entry) {
        if (entry == null) {
            return "null";
        }
        if (Compile.IS_DEBUG && INCLUDE_HASH_CODE_IN_LIST_ENTRY_LOG_KEY) {
            return logKey(entry.getKey()) + "@" + Integer.toHexString(entry.hashCode());
        } else {
            return logKey(entry.getKey());
        }
    }

    /** Removes newlines from the notification key to prettify apps that have these in the tag */
    public static String logKey(String key) {
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar.notification

import android.service.notification.StatusBarNotification
import com.android.systemui.statusbar.notification.collection.ListEntry

/** Get the notification key, reformatted for logging, for the (optional) entry  */
val ListEntry?.logKey: String?
    get() = this?.let { NotificationUtils.logKey(it) }

/** Get the notification key, reformatted for logging, for the (optional) sbn  */
val StatusBarNotification?.logKey: String?
    get() = this?.key?.let { NotificationUtils.logKey(it) }

/** Removes newlines from the notification key to prettify apps that have these in the tag  */
fun logKey(key: String?): String? = NotificationUtils.logKey(key)
 No newline at end of file
Loading