Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bd8cfda authored by Jeff DeCew's avatar Jeff DeCew
Browse files

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 5e7f40a9)
parent 721da615
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac

    @VisibleForTesting
    boolean isDynamicPrivacyEnabled() {
        return !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(
        return mLockscreenUserManager.userAllowsNotificationsInPublic(
                mLockscreenUserManager.getCurrentUserId());
    }

+9 −12
Original line number Diff line number Diff line
@@ -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