am f4e77806: am e7dc5140: am 9b557a25: Merge "Actually show secret notifications sometimes." into lmp-dev

* commit 'f4e778064b8bfbba3c5a7411f538c8321460d0a6':
  Actually show secret notifications sometimes.
This commit is contained in:
Dan Sandler
2014-07-18 19:05:34 +00:00
committed by Android Git Automerger
2 changed files with 51 additions and 22 deletions

View File

@@ -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) {

View File

@@ -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<View> toRemove = new ArrayList<View>();
@@ -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;
}