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

Commit 2083deb8 authored by Dan Sandler's avatar Dan Sandler Committed by Android (Google) Code Review
Browse files

Merge "Actually show secret notifications sometimes." into lmp-dev

parents 891f5b26 1b71878e
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;
            }