From 4bd8cfdac7a63af6fddc02d0e920fe28769b17ff Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 3 Jun 2022 11:56:49 -0400 Subject: [PATCH] Enable DynamicPrivacy whenever notifications are visible. The old logic here was that dynamic privacy would only be tracked when the user-wide setting for "hide sensitive" was active, but because individual notification channels can always be redacted, this meant that face auth (since bypass is the most visible use of this class) would not reveal individually redacted notifications on devices that otherwise did not redact. Fixes: 234757752 Test: atest DynamicPrivacyControllerTest Merged-In: If286f3453031135a828340a32e2221028d456b47 Change-Id: If286f3453031135a828340a32e2221028d456b47 (cherry picked from commit 5e7f40a9edcb9944a3b1d7b3d9ec86715788898b) --- .../DynamicPrivacyController.java | 2 +- .../DynamicPrivacyControllerTest.java | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java index a0ccd5726c755..1be4c04ef8047 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java @@ -80,7 +80,7 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac @VisibleForTesting boolean isDynamicPrivacyEnabled() { - return !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( + return mLockscreenUserManager.userAllowsNotificationsInPublic( mLockscreenUserManager.getCurrentUserId()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java index 7d06abf5cd671..3fc0c8176f2f1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java @@ -63,7 +63,7 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { mock(StatusBarKeyguardViewManager.class)); mDynamicPrivacyController.addListener(mListener); // Disable dynamic privacy by default - allowPrivateNotificationsInPublic(true); + allowNotificationsInPublic(false); } @Test @@ -108,24 +108,21 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { @Test public void dynamicPrivacyOnlyWhenHidingPrivate() { - // Verify that when only hiding notifications, this isn't enabled - allowPrivateNotificationsInPublic(true); - when(mLockScreenUserManager.shouldHideNotifications(any())).thenReturn( - false); - assertFalse("Dynamic privacy shouldn't be enabled when only hiding notifications", + // Verify that when hiding notifications, this isn't enabled + allowNotificationsInPublic(false); + assertFalse("Dynamic privacy shouldn't be enabled when hiding notifications", mDynamicPrivacyController.isDynamicPrivacyEnabled()); - allowPrivateNotificationsInPublic(false); - assertTrue("Should be enabled when hiding notification contents", + allowNotificationsInPublic(true); + assertTrue("Should be enabled whenever notifications are visible", mDynamicPrivacyController.isDynamicPrivacyEnabled()); } private void enableDynamicPrivacy() { - allowPrivateNotificationsInPublic(false); + allowNotificationsInPublic(true); } - private void allowPrivateNotificationsInPublic(boolean allow) { - when(mLockScreenUserManager.userAllowsPrivateNotificationsInPublic(anyInt())).thenReturn( - allow); + private void allowNotificationsInPublic(boolean allow) { + when(mLockScreenUserManager.userAllowsNotificationsInPublic(anyInt())).thenReturn(allow); } @Test