diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java index cc74e1a329ed8..8512a0bd8088e 100644 --- a/core/java/android/service/notification/StatusBarNotification.java +++ b/core/java/android/service/notification/StatusBarNotification.java @@ -292,9 +292,9 @@ public class StatusBarNotification implements Parcelable { return uid; } - /** The package that posted the notification. - *
- * Might be different from {@link #getPackageName()} if the app owning the notification has + /** + * The package that posted the notification. + *
Might be different from {@link #getPackageName()} if the app owning the notification has * a {@link NotificationManager#setNotificationDelegate(String) notification delegate}. */ public @NonNull String getOpPkg() { diff --git a/core/proto/android/service/notification.proto b/core/proto/android/service/notification.proto index c08d7cafd9cc1..4ef26dd592401 100644 --- a/core/proto/android/service/notification.proto +++ b/core/proto/android/service/notification.proto @@ -66,6 +66,10 @@ message NotificationRecordProto { optional bool can_show_light = 8; optional string group_key = 9 [ (.android.privacy).dest = DEST_EXPLICIT ]; optional sint32 importance = 10; + // The package the notification was posted for. + optional string package = 11; + // The package that posted the notification. It might not be the same as package. + optional string delegate_package = 12; } message ListenersDisablingEffectsProto { diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java index d9ab132951663..de9312041c41f 100644 --- a/services/core/java/com/android/server/notification/NotificationRecord.java +++ b/services/core/java/com/android/server/notification/NotificationRecord.java @@ -438,6 +438,8 @@ public final class NotificationRecord { if (getAudioAttributes() != null) { getAudioAttributes().writeToProto(proto, NotificationRecordProto.AUDIO_ATTRIBUTES); } + proto.write(NotificationRecordProto.PACKAGE, sbn.getPackageName()); + proto.write(NotificationRecordProto.DELEGATE_PACKAGE, sbn.getOpPkg()); proto.end(token); } @@ -458,6 +460,7 @@ public final class NotificationRecord { pw.println(prefix + this); prefix = prefix + " "; pw.println(prefix + "uid=" + sbn.getUid() + " userId=" + sbn.getUserId()); + pw.println(prefix + "opPkg=" + sbn.getOpPkg()); pw.println(prefix + "icon=" + iconStr); pw.println(prefix + "flags=0x" + Integer.toHexString(notification.flags)); pw.println(prefix + "pri=" + notification.priority);