diff options
| -rw-r--r-- | core/java/android/app/Notification.java | 126 | ||||
| -rw-r--r-- | services/core/java/com/android/server/notification/NotificationRecord.java | 7 |
2 files changed, 125 insertions, 8 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 01a3be432299..436221f3ef2c 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -3792,10 +3792,10 @@ public class Notification implements Parcelable if (this.tickerText != null) { sb.append(" tick"); } - sb.append(" defaults=0x"); - sb.append(Integer.toHexString(this.defaults)); - sb.append(" flags=0x"); - sb.append(Integer.toHexString(this.flags)); + sb.append(" defaults="); + sb.append(defaultsToString(this.defaults)); + sb.append(" flags="); + sb.append(flagsToString(this.flags)); sb.append(String.format(" color=0x%08x", this.color)); if (this.category != null) { sb.append(" category="); @@ -3864,6 +3864,124 @@ public class Notification implements Parcelable } /** + * {@hide} + */ + public static String flagsToString(@NotificationFlags int flags) { + final List<String> flagStrings = new ArrayList<String>(); + if ((flags & FLAG_SHOW_LIGHTS) != 0) { + flagStrings.add("SHOW_LIGHTS"); + flags &= ~FLAG_SHOW_LIGHTS; + } + if ((flags & FLAG_ONGOING_EVENT) != 0) { + flagStrings.add("ONGOING_EVENT"); + flags &= ~FLAG_ONGOING_EVENT; + } + if ((flags & FLAG_INSISTENT) != 0) { + flagStrings.add("INSISTENT"); + flags &= ~FLAG_INSISTENT; + } + if ((flags & FLAG_ONLY_ALERT_ONCE) != 0) { + flagStrings.add("ONLY_ALERT_ONCE"); + flags &= ~FLAG_ONLY_ALERT_ONCE; + } + if ((flags & FLAG_AUTO_CANCEL) != 0) { + flagStrings.add("AUTO_CANCEL"); + flags &= ~FLAG_AUTO_CANCEL; + } + if ((flags & FLAG_NO_CLEAR) != 0) { + flagStrings.add("NO_CLEAR"); + flags &= ~FLAG_NO_CLEAR; + } + if ((flags & FLAG_FOREGROUND_SERVICE) != 0) { + flagStrings.add("FOREGROUND_SERVICE"); + flags &= ~FLAG_FOREGROUND_SERVICE; + } + if ((flags & FLAG_HIGH_PRIORITY) != 0) { + flagStrings.add("HIGH_PRIORITY"); + flags &= ~FLAG_HIGH_PRIORITY; + } + if ((flags & FLAG_LOCAL_ONLY) != 0) { + flagStrings.add("LOCAL_ONLY"); + flags &= ~FLAG_LOCAL_ONLY; + } + if ((flags & FLAG_GROUP_SUMMARY) != 0) { + flagStrings.add("GROUP_SUMMARY"); + flags &= ~FLAG_GROUP_SUMMARY; + } + if ((flags & FLAG_AUTOGROUP_SUMMARY) != 0) { + flagStrings.add("AUTOGROUP_SUMMARY"); + flags &= ~FLAG_AUTOGROUP_SUMMARY; + } + if ((flags & FLAG_CAN_COLORIZE) != 0) { + flagStrings.add("CAN_COLORIZE"); + flags &= ~FLAG_CAN_COLORIZE; + } + if ((flags & FLAG_BUBBLE) != 0) { + flagStrings.add("BUBBLE"); + flags &= ~FLAG_BUBBLE; + } + if ((flags & FLAG_NO_DISMISS) != 0) { + flagStrings.add("NO_DISMISS"); + flags &= ~FLAG_NO_DISMISS; + } + if ((flags & FLAG_FSI_REQUESTED_BUT_DENIED) != 0) { + flagStrings.add("FSI_REQUESTED_BUT_DENIED"); + flags &= ~FLAG_FSI_REQUESTED_BUT_DENIED; + } + if ((flags & FLAG_USER_INITIATED_JOB) != 0) { + flagStrings.add("USER_INITIATED_JOB"); + flags &= ~FLAG_USER_INITIATED_JOB; + } + if (Flags.lifetimeExtensionRefactor()) { + if ((flags & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY) != 0) { + flagStrings.add("LIFETIME_EXTENDED_BY_DIRECT_REPLY"); + flags &= ~FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY; + } + } + + if (flagStrings.isEmpty()) { + return "0"; + } + + if (flags != 0) { + flagStrings.add(String.format("UNKNOWN(0x%08x)", flags)); + } + + return String.join("|", flagStrings); + } + + /** @hide */ + public static String defaultsToString(int defaults) { + final List<String> defaultStrings = new ArrayList<String>(); + if ((defaults & DEFAULT_ALL) == DEFAULT_ALL) { + defaultStrings.add("ALL"); + defaults &= ~DEFAULT_ALL; + } + if ((defaults & DEFAULT_SOUND) != 0) { + defaultStrings.add("SOUND"); + defaults &= ~DEFAULT_SOUND; + } + if ((defaults & DEFAULT_VIBRATE) != 0) { + defaultStrings.add("VIBRATE"); + defaults &= ~DEFAULT_VIBRATE; + } + if ((defaults & DEFAULT_LIGHTS) != 0) { + defaultStrings.add("LIGHTS"); + defaults &= ~DEFAULT_LIGHTS; + } + + if (defaultStrings.isEmpty()) { + return "0"; + } + + if (defaults != 0) { + defaultStrings.add(String.format("UNKNOWN(0x%08x)", defaults)); + } + + return String.join("|", defaultStrings); + } + + /** * @hide */ public boolean hasCompletedProgress() { diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java index e75d0a3285e7..38c95f771601 100644 --- a/services/core/java/com/android/server/notification/NotificationRecord.java +++ b/services/core/java/com/android/server/notification/NotificationRecord.java @@ -502,8 +502,8 @@ public final class NotificationRecord { pw.println(prefix + "uid=" + getSbn().getUid() + " userId=" + getSbn().getUserId()); pw.println(prefix + "opPkg=" + getSbn().getOpPkg()); pw.println(prefix + "icon=" + notification.getSmallIcon()); - pw.println(prefix + "flags=0x" + Integer.toHexString(notification.flags)); - pw.println(prefix + "originalFlags=0x" + Integer.toHexString(mOriginalFlags)); + pw.println(prefix + "flags=" + Notification.flagsToString(notification.flags)); + pw.println(prefix + "originalFlags=" + Notification.flagsToString(mOriginalFlags)); pw.println(prefix + "pri=" + notification.priority); pw.println(prefix + "key=" + getSbn().getKey()); pw.println(prefix + "seen=" + mStats.hasSeen()); @@ -538,8 +538,7 @@ public final class NotificationRecord { pw.println(prefix + "mInterruptionTimeMs=" + mInterruptionTimeMs); pw.println(prefix + "mSuppressedVisualEffects= " + mSuppressedVisualEffects); if (mPreChannelsNotification) { - pw.println(prefix + String.format("defaults=0x%08x flags=0x%08x", - notification.defaults, notification.flags)); + pw.println(prefix + "defaults=" + Notification.defaultsToString(notification.defaults)); pw.println(prefix + "n.sound=" + notification.sound); pw.println(prefix + "n.audioStreamType=" + notification.audioStreamType); pw.println(prefix + "n.audioAttributes=" + notification.audioAttributes); |