diff options
author | Julia Tuttle <juliatuttle@google.com> | 2022-09-22 17:56:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-09-22 17:56:55 +0000 |
commit | ecc34caee329c7ab483bc44f2946771c2770fb58 (patch) | |
tree | 1e7c0a6d75bf8c9dc6e1f208e5560d0ddf1649f9 | |
parent | 1140d5bb61c182951d42711c7197f816da271739 (diff) | |
parent | 3ce74461e94b479b3712079475d7eff458337e7b (diff) | |
download | base-ecc34caee329c7ab483bc44f2946771c2770fb58.tar.gz |
Merge "New Pipeline: hide VISIBILITY_SECRET notifications on lock screen" into tm-dev
2 files changed, 52 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt index 0b6b929cd93c..c956a2ea1836 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProvider.kt @@ -1,6 +1,7 @@ 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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java index 541749b49474..d59cc54dfe98 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/KeyguardNotificationVisibilityProviderTest.java @@ -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; @@ -449,6 +450,54 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase { } @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 // but it's part of a group (has a parent) |