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

Commit 304a52c8 authored by Julia Tuttle's avatar Julia Tuttle Committed by Automerger Merge Worker
Browse files

Merge "New Pipeline: hide VISIBILITY_SECRET notifications on lock screen" into...

Merge "New Pipeline: hide VISIBILITY_SECRET notifications on lock screen" into tm-dev am: ecc34cae

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19755224



Change-Id: I52009eb83857640105fff11b4c559b33479fbc29
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5a7e9eb7 ecc34cae
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
package com.android.systemui.statusbar.notification.interruption

import android.app.Notification
import android.app.Notification.VISIBILITY_SECRET
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -172,6 +173,8 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
        !lockscreenUserManager.shouldShowLockscreenNotifications() -> true
        // User settings do not allow this notification on the lockscreen, so hide it.
        userSettingsDisallowNotification(entry) -> true
        // Entry is explicitly marked SECRET, so hide it.
        entry.sbn.notification.visibility == VISIBILITY_SECRET -> true
        // if entry is silent, apply custom logic to see if should hide
        shouldHideIfEntrySilent(entry) -> true
        else -> false
+49 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.interruption;

import static android.app.Notification.VISIBILITY_PRIVATE;
import static android.app.Notification.VISIBILITY_PUBLIC;
import static android.app.Notification.VISIBILITY_SECRET;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
@@ -448,6 +449,54 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void notificationVisibilityPublic() {
        // GIVEN a VISIBILITY_PUBLIC notification
        NotificationEntryBuilder entryBuilder = new NotificationEntryBuilder()
                .setUser(new UserHandle(NOTIF_USER_ID));
        entryBuilder.modifyNotification(mContext)
                .setVisibility(VISIBILITY_PUBLIC);
        mEntry = entryBuilder.build();

        // WHEN we're in an 'unfiltered-keyguard-showing' state
        setupUnfilteredState(mEntry);

        // THEN don't hide the entry based on visibility.
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void notificationVisibilityPrivate() {
        // GIVEN a VISIBILITY_PRIVATE notification
        NotificationEntryBuilder entryBuilder = new NotificationEntryBuilder()
                .setUser(new UserHandle(NOTIF_USER_ID));
        entryBuilder.modifyNotification(mContext)
                .setVisibility(VISIBILITY_PRIVATE);
        mEntry = entryBuilder.build();

        // WHEN we're in an 'unfiltered-keyguard-showing' state
        setupUnfilteredState(mEntry);

        // THEN don't hide the entry based on visibility. (Redaction is handled elsewhere.)
        assertFalse(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void notificationVisibilitySecret() {
        // GIVEN a VISIBILITY_SECRET notification
        NotificationEntryBuilder entryBuilder = new NotificationEntryBuilder()
                .setUser(new UserHandle(NOTIF_USER_ID));
        entryBuilder.modifyNotification(mContext)
                .setVisibility(VISIBILITY_SECRET);
        mEntry = entryBuilder.build();

        // WHEN we're in an 'unfiltered-keyguard-showing' state
        setupUnfilteredState(mEntry);

        // THEN hide the entry based on visibility.
        assertTrue(mKeyguardNotificationVisibilityProvider.shouldHideNotification(mEntry));
    }

    @Test
    public void summaryExceedsThresholdToShow() {
        // GIVEN the notification doesn't exceed the threshold to show on the lockscreen