Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java +5 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.systemui.statusbar.notification; import android.annotation.Nullable; import android.util.ArraySet; import androidx.annotation.VisibleForTesting; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.NotificationLockscreenUserManager; Loading Loading @@ -76,8 +78,9 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac } } private boolean isDynamicPrivacyEnabled() { return !mLockscreenUserManager.shouldHideNotifications( @VisibleForTesting boolean isDynamicPrivacyEnabled() { return !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( mLockscreenUserManager.getCurrentUserId()); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; Loading Loading @@ -60,13 +62,15 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { mDynamicPrivacyController.setStatusBarKeyguardViewManager( mock(StatusBarKeyguardViewManager.class)); mDynamicPrivacyController.addListener(mListener); // Disable dynamic privacy by default allowPrivateNotificationsInPublic(true); } @Test public void testDynamicFalseWhenCannotSkipBouncer() { enableDynamicPrivacy(); when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false); Assert.assertFalse("can't skip bouncer but is dynamically unlocked", assertFalse("can't skip bouncer but is dynamically unlocked", mDynamicPrivacyController.isDynamicallyUnlocked()); } Loading Loading @@ -102,9 +106,26 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { verify(mListener).onDynamicPrivacyChanged(); } private void enableDynamicPrivacy() { @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", mDynamicPrivacyController.isDynamicPrivacyEnabled()); allowPrivateNotificationsInPublic(false); assertTrue("Should be enabled when hiding notification contents", mDynamicPrivacyController.isDynamicPrivacyEnabled()); } private void enableDynamicPrivacy() { allowPrivateNotificationsInPublic(false); } private void allowPrivateNotificationsInPublic(boolean allow) { when(mLockScreenUserManager.userAllowsPrivateNotificationsInPublic(anyInt())).thenReturn( allow); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/DynamicPrivacyController.java +5 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.systemui.statusbar.notification; import android.annotation.Nullable; import android.util.ArraySet; import androidx.annotation.VisibleForTesting; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.NotificationLockscreenUserManager; Loading Loading @@ -76,8 +78,9 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac } } private boolean isDynamicPrivacyEnabled() { return !mLockscreenUserManager.shouldHideNotifications( @VisibleForTesting boolean isDynamicPrivacyEnabled() { return !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( mLockscreenUserManager.getCurrentUserId()); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/DynamicPrivacyControllerTest.java +23 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; Loading Loading @@ -60,13 +62,15 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { mDynamicPrivacyController.setStatusBarKeyguardViewManager( mock(StatusBarKeyguardViewManager.class)); mDynamicPrivacyController.addListener(mListener); // Disable dynamic privacy by default allowPrivateNotificationsInPublic(true); } @Test public void testDynamicFalseWhenCannotSkipBouncer() { enableDynamicPrivacy(); when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false); Assert.assertFalse("can't skip bouncer but is dynamically unlocked", assertFalse("can't skip bouncer but is dynamically unlocked", mDynamicPrivacyController.isDynamicallyUnlocked()); } Loading Loading @@ -102,9 +106,26 @@ public class DynamicPrivacyControllerTest extends SysuiTestCase { verify(mListener).onDynamicPrivacyChanged(); } private void enableDynamicPrivacy() { @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", mDynamicPrivacyController.isDynamicPrivacyEnabled()); allowPrivateNotificationsInPublic(false); assertTrue("Should be enabled when hiding notification contents", mDynamicPrivacyController.isDynamicPrivacyEnabled()); } private void enableDynamicPrivacy() { allowPrivateNotificationsInPublic(false); } private void allowPrivateNotificationsInPublic(boolean allow) { when(mLockScreenUserManager.userAllowsPrivateNotificationsInPublic(anyInt())).thenReturn( allow); } @Test Loading