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

This commit is contained in:
Jeff DeCew
2022-06-22 13:29:46 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 13 deletions

View File

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

View File

@@ -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