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

Commit 7d02b3be authored by Matt Pietal's avatar Matt Pietal
Browse files

Use secure setting for secure windows on keyguard

Instead of relying on the isDebuggable() method, standardize
on the new secure setting.

Fixes: 375675418
Test: atest NotificationShadeWindowViewControllerImplTest
Flag: EXEMPT bugfix
Change-Id: Ib8deed58f53f44477027c92a079034275de927b5
parent bb291681
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.platform.test.flag.junit.FlagsParameterization;
import android.provider.Settings;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.view.WindowManager;
@@ -70,6 +71,7 @@ import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.settings.FakeSettings;

import com.google.common.util.concurrent.MoreExecutors;

@@ -111,6 +113,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    @Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;
    @Captor private ArgumentCaptor<StatusBarStateController.StateListener> mStateListener;

    private FakeSettings mSecureSettings;
    private final Executor mMainExecutor = MoreExecutors.directExecutor();
    private final Executor mBackgroundExecutor = MoreExecutors.directExecutor();
    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);
@@ -131,6 +134,10 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        mSecureSettings = new FakeSettings();
        mSecureSettings.putInt(Settings.Secure.DISABLE_SECURE_WINDOWS, 0);

        // Preferred refresh rate is equal to the first displayMode's refresh rate
        mPreferredRefreshRate = mContext.getDisplay().getSystemSupportedModes()[0].getRefreshRate();
        overrideResource(
@@ -164,12 +171,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                () -> mSelectedUserInteractor,
                mUserTracker,
                mKosmos.getNotificationShadeWindowModel(),
                mKosmos::getCommunalInteractor) {
                    @Override
                    protected boolean isDebuggable() {
                        return false;
                    }
            };
                mSecureSettings,
                mKosmos::getCommunalInteractor);
        mNotificationShadeWindowController.setScrimsVisibilityListener((visibility) -> {});
        mNotificationShadeWindowController.fetchWindowRootView();

@@ -350,6 +353,19 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                .isTrue();
    }

    @Test
    public void setKeyguardShowingWithSecureWindowsDisabled_disablesSecureFlag() {
        mSecureSettings.putInt(Settings.Secure.DISABLE_SECURE_WINDOWS, 1);
        mNotificationShadeWindowController.setBouncerShowing(true);

        verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
        assertThat((mLayoutParameters.getValue().flags & FLAG_SECURE) == 0).isTrue();
        assertThat(
                (mLayoutParameters.getValue().inputFeatures & INPUT_FEATURE_SENSITIVE_FOR_PRIVACY)
                        != 0)
                .isTrue();
    }

    @Test
    public void setKeyguardNotShowing_disablesSecureFlag() {
        mNotificationShadeWindowController.setBouncerShowing(false);
+12 −4
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.view.Display;
import android.view.IWindow;
@@ -73,6 +74,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.settings.SecureSettings;

import dagger.Lazy;

@@ -130,6 +132,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    private final SysuiColorExtractor mColorExtractor;
    private final NotificationShadeWindowModel mNotificationShadeWindowModel;
    private final SecureSettings mSecureSettings;
    /**
     * Layout params would be aggregated and dispatched all at once if this is > 0.
     *
@@ -163,6 +166,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
            Lazy<SelectedUserInteractor> userInteractor,
            UserTracker userTracker,
            NotificationShadeWindowModel notificationShadeWindowModel,
            SecureSettings secureSettings,
            Lazy<CommunalInteractor> communalInteractor) {
        mContext = context;
        mWindowRootViewComponentFactory = windowRootViewComponentFactory;
@@ -178,6 +182,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        mBackgroundExecutor = backgroundExecutor;
        mColorExtractor = colorExtractor;
        mNotificationShadeWindowModel = notificationShadeWindowModel;
        mSecureSettings = secureSettings;
        // prefix with {slow} to make sure this dumps at the END of the critical section.
        dumpManager.registerCriticalDumpable("{slow}NotificationShadeWindowControllerImpl", this);
        mAuthController = authController;
@@ -400,7 +405,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
                    (long) mLpChanged.preferredMaxDisplayRefreshRate);
        }

        if (state.bouncerShowing && !isDebuggable()) {
        if (state.bouncerShowing && !isSecureWindowsDisabled()) {
            mLpChanged.flags |= LayoutParams.FLAG_SECURE;
        } else {
            mLpChanged.flags &= ~LayoutParams.FLAG_SECURE;
@@ -413,8 +418,11 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        }
    }

    protected boolean isDebuggable() {
        return Build.IS_DEBUGGABLE;
    private boolean isSecureWindowsDisabled() {
        return mSecureSettings.getIntForUser(
            Settings.Secure.DISABLE_SECURE_WINDOWS,
            0,
            UserHandle.USER_CURRENT) == 1;
    }

    private void adjustScreenOrientation(NotificationShadeWindowState state) {
+1 −0
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
                () -> mSelectedUserInteractor,
                mUserTracker,
                mKosmos.getNotificationShadeWindowModel(),
                mSecureSettings,
                mKosmos::getCommunalInteractor);
        mFeatureFlags = new FakeFeatureFlags();
        mSetFlagsRule.disableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR);
+2 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ import com.android.systemui.statusbar.policy.data.repository.FakeDeviceProvision
import com.android.systemui.user.domain.interactor.SelectedUserInteractor;
import com.android.systemui.util.FakeEventLog;
import com.android.systemui.util.settings.FakeGlobalSettings;
import com.android.systemui.util.settings.FakeSettings;
import com.android.systemui.util.settings.SystemSettings;
import com.android.systemui.util.time.SystemClock;
import com.android.wm.shell.Flags;
@@ -442,6 +443,7 @@ public class BubblesTest extends SysuiTestCase {
                () -> mSelectedUserInteractor,
                mUserTracker,
                mNotificationShadeWindowModel,
                new FakeSettings(),
                mKosmos::getCommunalInteractor
        );
        mNotificationShadeWindowController.fetchWindowRootView();