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

Commit 4fddc795 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Allow listeners to know about lockscreen notifs

Specifically, whether user and device policy manager settings
means that a notification should be hidden or redacted on
the lockscreen

Test: cts verifier
Fixes: 173090853
Change-Id: Ic09a2b05a1acce5d3d63732861bdc69b274a1eba
parent be257996
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42457,6 +42457,7 @@ package android.service.notification {
    method public CharSequence getImportanceExplanation();
    method public String getKey();
    method public long getLastAudiblyAlertedMillis();
    method public int getLockscreenVisibilityOverride();
    method public String getOverrideGroupKey();
    method public int getRank();
    method @NonNull public java.util.List<android.app.Notification.Action> getSmartActions();
@@ -42470,6 +42471,7 @@ package android.service.notification {
    field public static final int USER_SENTIMENT_NEGATIVE = -1; // 0xffffffff
    field public static final int USER_SENTIMENT_NEUTRAL = 0; // 0x0
    field public static final int USER_SENTIMENT_POSITIVE = 1; // 0x1
    field public static final int VISIBILITY_NO_OVERRIDE = -1000; // 0xfffffc18
  }
  public static class NotificationListenerService.RankingMap implements android.os.Parcelable {
+8 −7
Original line number Diff line number Diff line
@@ -1517,8 +1517,10 @@ public abstract class NotificationListenerService extends Service {
     */
    public static class Ranking {

        /** Value signifying that the user has not expressed a per-app visibility override value.
         * @hide */
        /**
         * Value signifying that the user and device policy manager have not expressed a lockscreen
         * visibility override for a notification.
         */
        public static final int VISIBILITY_NO_OVERRIDE = NotificationManager.VISIBILITY_NO_OVERRIDE;

        /**
@@ -1695,14 +1697,13 @@ public abstract class NotificationListenerService extends Service {
        }

        /**
         * Returns the user specified visibility for the package that posted
         * this notification, or
         * Returns the user or device policy manager specified visibility (see
         * {@link Notification#VISIBILITY_PRIVATE}, {@link Notification#VISIBILITY_PUBLIC},
         * {@link Notification#VISIBILITY_SECRET}) for this notification, or
         * {@link NotificationListenerService.Ranking#VISIBILITY_NO_OVERRIDE} if
         * no such preference has been expressed.
         * @hide
         */
        @UnsupportedAppUsage
        public int getVisibilityOverride() {
        public int getLockscreenVisibilityOverride() {
            return mVisibilityOverride;
        }

+3 −2
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ public class NotificationLockscreenUserManagerImpl implements
        }
        NotificationEntry visibleEntry = getEntryManager().getActiveNotificationUnfiltered(key);
        return isLockscreenPublicMode(mCurrentUserId) && visibleEntry != null
                && visibleEntry.getRanking().getVisibilityOverride() == VISIBILITY_SECRET;
                && visibleEntry.getRanking().getLockscreenVisibilityOverride() == VISIBILITY_SECRET;
    }

    public boolean shouldShowOnKeyguard(NotificationEntry entry) {
@@ -513,7 +513,8 @@ public class NotificationLockscreenUserManagerImpl implements
        }
        NotificationEntry entry = getEntryManager().getActiveNotificationUnfiltered(key);
        return entry != null
                && entry.getRanking().getVisibilityOverride() == Notification.VISIBILITY_PRIVATE;
                && entry.getRanking().getLockscreenVisibilityOverride() 
                == Notification.VISIBILITY_PRIVATE;
    }

    private void updateCurrentProfilesCache() {
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class KeyguardCoordinator implements Coordinator {
                // notifications to show in public mode
                if (mLockscreenUserManager.isLockscreenPublicMode(currUserId)
                        || mLockscreenUserManager.isLockscreenPublicMode(notifUserId)) {
                    if (entry.getRanking().getVisibilityOverride() == VISIBILITY_SECRET) {
                    if (entry.getRanking().getLockscreenVisibilityOverride() == VISIBILITY_SECRET) {
                        return true;
                    }

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class RankingBuilder {
        mKey = ranking.getKey();
        mRank = ranking.getRank();
        mMatchesInterruptionFilter = ranking.matchesInterruptionFilter();
        mVisibilityOverride = ranking.getVisibilityOverride();
        mVisibilityOverride = ranking.getLockscreenVisibilityOverride();
        mSuppressedVisualEffects = ranking.getSuppressedVisualEffects();
        mImportance = ranking.getImportance();
        mExplanation = ranking.getImportanceExplanation();
Loading