diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 97a99203153da..a9d3f7e1bc324 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1576,7 +1576,6 @@ public class Notification implements Parcelable } else { sb.append("null"); } - // TODO(dsandler): defaults take precedence over local values, so reorder the branches below sb.append(" vibrate="); if ((this.defaults & DEFAULT_VIBRATE) != 0) { sb.append("default"); @@ -1620,15 +1619,35 @@ public class Notification implements Parcelable sb.append(this.mSortKey); } if (actions != null) { - sb.append(" "); + sb.append(" actions="); sb.append(actions.length); - sb.append(" action"); - if (actions.length > 1) sb.append("s"); + } + sb.append(" vis="); + sb.append(visibilityToString(this.visibility)); + if (this.publicVersion != null) { + sb.append(" publicVersion="); + sb.append(publicVersion.toString()); } sb.append(")"); return sb.toString(); } + /** + * {@hide} + */ + public static String visibilityToString(int vis) { + switch (vis) { + case VISIBILITY_PRIVATE: + return "PRIVATE"; + case VISIBILITY_PUBLIC: + return "PUBLIC"; + case VISIBILITY_SECRET: + return "SECRET"; + default: + return "UNKNOWN(" + String.valueOf(vis) + ")"; + } + } + /** {@hide} */ public void setUser(UserHandle user) { if (user.getIdentifier() == UserHandle.USER_ALL) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 4b6e598ec32ea..680d34614ccf4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1240,22 +1240,25 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (!notificationIsForCurrentProfiles(ent.notification)) continue; + final boolean hideSensitive = shouldHideSensitiveContents(ent.notification.getUserId()); final int vis = ent.notification.getNotification().visibility; - if (vis != Notification.VISIBILITY_SECRET) { - // when isLockscreenPublicMode() we show the public form of VISIBILITY_PRIVATE notifications - boolean showingPublic = isLockscreenPublicMode() - && vis == Notification.VISIBILITY_PRIVATE - && !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId()); - ent.row.setShowingPublic(showingPublic); - if (ent.autoRedacted && ent.legacy) { - if (showingPublic) { - ent.row.setShowingLegacyBackground(false); - } else { - ent.row.setShowingLegacyBackground(true); - } - } - toShow.add(ent.row); + + // when isLockscreenPublicMode() we suppress VISIBILITY_SECRET notifications + if (vis == Notification.VISIBILITY_SECRET && hideSensitive) { + continue; } + + // when isLockscreenPublicMode() we show the public form of VISIBILITY_PRIVATE notifications + boolean showingPublic = vis == Notification.VISIBILITY_PRIVATE && hideSensitive; + ent.row.setShowingPublic(showingPublic); + if (ent.autoRedacted && ent.legacy) { + if (showingPublic) { + ent.row.setShowingLegacyBackground(false); + } else { + ent.row.setShowingLegacyBackground(true); + } + } + toShow.add(ent.row); } ArrayList toRemove = new ArrayList(); @@ -1333,6 +1336,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, updateNotificationIcons(); } + /** + * Returns true if we're on a secure lockscreen and the user wants to hide "sensitive" + * notification data. If so, private notifications should show their (possibly + * auto-generated) publicVersion, and secret notifications should be totally invisible. + */ + private boolean shouldHideSensitiveContents(int userid) { + return isLockscreenPublicMode() && !userAllowsPrivateNotificationsInPublic(userid); + } + private void updateNotificationIcons() { final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); @@ -1353,10 +1365,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (!((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE) || showNotificationEvenIfUnprovisioned(ent.notification))) continue; if (!notificationIsForCurrentProfiles(ent.notification)) continue; - if (isLockscreenPublicMode() - && ent.notification.getNotification().visibility - == Notification.VISIBILITY_SECRET - && !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId())) { + if (ent.notification.getNotification().visibility == Notification.VISIBILITY_SECRET + && shouldHideSensitiveContents(ent.notification.getUserId())) { // in "public" mode (atop a secure keyguard), secret notifs are totally hidden continue; }