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

Commit e3fb0607 authored by Selim Cinek's avatar Selim Cinek Committed by Automerger Merge Worker
Browse files

Merge "Fixed the logic when dynamic privacy is enabled" into sc-dev am: 5b53fb4f am: c7ec339e

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

Change-Id: I3decdc9a0d4a0d0a1260c3f916aa224f1b6eac62
parents fd7460a0 c7ec339e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;
@@ -76,8 +78,9 @@ public class DynamicPrivacyController implements KeyguardStateController.Callbac
        }
    }

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

+23 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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());
    }

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