Merge "Enable DynamicPrivacy whenever notifications are visible." into tm-qpr-dev am: fd4f5f106d

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

Change-Id: I55cf004bdc5840ccc8b7555097dec5ae97b6546f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jeff DeCew
2022-06-22 13:47:38 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 13 deletions

View File

@@ -80,7 +80,7 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac
@VisibleForTesting @VisibleForTesting
boolean isDynamicPrivacyEnabled() { boolean isDynamicPrivacyEnabled() {
return !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( return mLockscreenUserManager.userAllowsNotificationsInPublic(
mLockscreenUserManager.getCurrentUserId()); mLockscreenUserManager.getCurrentUserId());
} }

View File

@@ -63,7 +63,7 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase {
mock(StatusBarKeyguardViewManager.class)); mock(StatusBarKeyguardViewManager.class));
mDynamicPrivacyController.addListener(mListener); mDynamicPrivacyController.addListener(mListener);
// Disable dynamic privacy by default // Disable dynamic privacy by default
allowPrivateNotificationsInPublic(true); allowNotificationsInPublic(false);
} }
@Test @Test
@@ -108,24 +108,21 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase {
@Test @Test
public void dynamicPrivacyOnlyWhenHidingPrivate() { public void dynamicPrivacyOnlyWhenHidingPrivate() {
// Verify that when only hiding notifications, this isn't enabled // Verify that when hiding notifications, this isn't enabled
allowPrivateNotificationsInPublic(true); allowNotificationsInPublic(false);
when(mLockScreenUserManager.shouldHideNotifications(any())).thenReturn( assertFalse("Dynamic privacy shouldn't be enabled when hiding notifications",
false);
assertFalse("Dynamic privacy shouldn't be enabled when only hiding notifications",
mDynamicPrivacyController.isDynamicPrivacyEnabled()); mDynamicPrivacyController.isDynamicPrivacyEnabled());
allowPrivateNotificationsInPublic(false); allowNotificationsInPublic(true);
assertTrue("Should be enabled when hiding notification contents", assertTrue("Should be enabled whenever notifications are visible",
mDynamicPrivacyController.isDynamicPrivacyEnabled()); mDynamicPrivacyController.isDynamicPrivacyEnabled());
} }
private void enableDynamicPrivacy() { private void enableDynamicPrivacy() {
allowPrivateNotificationsInPublic(false); allowNotificationsInPublic(true);
} }
private void allowPrivateNotificationsInPublic(boolean allow) { private void allowNotificationsInPublic(boolean allow) {
when(mLockScreenUserManager.userAllowsPrivateNotificationsInPublic(anyInt())).thenReturn( when(mLockScreenUserManager.userAllowsNotificationsInPublic(anyInt())).thenReturn(allow);
allow);
} }
@Test @Test