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

Commit 1b71878e authored by Dan Sandler's avatar Dan Sandler
Browse files

Actually show secret notifications sometimes.

Factor out the "should we be hiding sensitive data"
predicate so we get it right everywhere.

Show visibility stuff in Notification.toString().

Bug: 16307122
Change-Id: Ifd16d073c4595add2ac3582ffc0d0179e55246e5
parent e7d1f16f
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -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) {
+27 −17
Original line number Diff line number Diff line
@@ -1240,12 +1240,16 @@ 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 suppress VISIBILITY_SECRET notifications
            if (vis == Notification.VISIBILITY_SECRET && hideSensitive) {
                continue;
            }

            // when isLockscreenPublicMode() we show the public form of VISIBILITY_PRIVATE notifications
                boolean showingPublic = isLockscreenPublicMode()
                        && vis == Notification.VISIBILITY_PRIVATE
                        && !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId());
            boolean showingPublic = vis == Notification.VISIBILITY_PRIVATE && hideSensitive;
            ent.row.setShowingPublic(showingPublic);
            if (ent.autoRedacted && ent.legacy) {
                if (showingPublic) {
@@ -1256,7 +1260,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            }
            toShow.add(ent.row);
        }
        }

        ArrayList<View> toRemove = new ArrayList<View>();
        for (int i=0; i< mStackScroller.getChildCount(); i++) {
@@ -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;
            }