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

Commit 26afab22 authored by Patrick Williams's avatar Patrick Williams
Browse files

Add secure setting disable_secure_windows

Adds a setting that disables secure windows on debuggable builds. To disable secure windows, use

    adb shell settings put secure disable_secure_windows 1

and to re-enable secure windows, use

    adb shell settings delete secure disable_secure_windows.

The setting is persisted between device reboots.

Bug: 309153458
Test: manually tested that recordings and screenshots capture secure windows after running the command
Change-Id: Ied0f9a4ecfe481f9a00f8572f39dba5cf99303b9
parent c4c128e9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12395,6 +12395,13 @@ public final class Settings {
         */
        public static final String HIDE_PRIVATESPACE_ENTRY_POINT = "hide_privatespace_entry_point";
        /**
         * Whether or not secure windows should be disabled. This only works on debuggable builds.
         *
         * @hide
         */
        public static final String DISABLE_SECURE_WINDOWS = "disable_secure_windows";
        /** @hide */
        public static final int PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK = 0;
        /** @hide */
+1 −0
Original line number Diff line number Diff line
@@ -688,6 +688,7 @@ public class SettingsBackupTest {
                 Settings.Secure.DEVICE_PAIRED,
                 Settings.Secure.DIALER_DEFAULT_APPLICATION,
                 Settings.Secure.DISABLED_PRINT_SERVICES,
                 Settings.Secure.DISABLE_SECURE_WINDOWS,
                 Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS,
                 Settings.Secure.DOCKED_CLOCK_FACE,
                 Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
+39 −0
Original line number Diff line number Diff line
@@ -794,6 +794,8 @@ public class WindowManagerService extends IWindowManager.Stub
                Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE);
        private final Uri mImmersiveModeConfirmationsUri =
                Settings.Secure.getUriFor(Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS);
        private final Uri mDisableSecureWindowsUri =
                Settings.Secure.getUriFor(Settings.Secure.DISABLE_SECURE_WINDOWS);
        private final Uri mPolicyControlUri =
                Settings.Global.getUriFor(Settings.Global.POLICY_CONTROL);
        private final Uri mForceDesktopModeOnExternalDisplaysUri = Settings.Global.getUriFor(
@@ -822,6 +824,8 @@ public class WindowManagerService extends IWindowManager.Stub
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mImmersiveModeConfirmationsUri, false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mDisableSecureWindowsUri, false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mPolicyControlUri, false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(mForceDesktopModeOnExternalDisplaysUri, false, this,
                    UserHandle.USER_ALL);
@@ -876,6 +880,11 @@ public class WindowManagerService extends IWindowManager.Stub
                return;
            }

            if (mDisableSecureWindowsUri.equals(uri)) {
                updateDisableSecureWindows();
                return;
            }

            @UpdateAnimationScaleMode
            final int mode;
            if (mWindowAnimationScaleUri.equals(uri)) {
@@ -895,6 +904,7 @@ public class WindowManagerService extends IWindowManager.Stub
        void loadSettings() {
            updateSystemUiSettings(false /* handleChange */);
            updateMaximumObscuringOpacityForTouch();
            updateDisableSecureWindows();
        }

        void updateMaximumObscuringOpacityForTouch() {
@@ -977,6 +987,28 @@ public class WindowManagerService extends IWindowManager.Stub
                });
            }
        }

        void updateDisableSecureWindows() {
            if (!SystemProperties.getBoolean(SYSTEM_DEBUGGABLE, false)) {
                return;
            }

            final boolean disableSecureWindows;
            try {
                disableSecureWindows = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                        Settings.Secure.DISABLE_SECURE_WINDOWS, 0) != 0;
            } catch (Settings.SettingNotFoundException e) {
                return;
            }
            if (mDisableSecureWindows == disableSecureWindows) {
                return;
            }

            synchronized (mGlobalLock) {
                mDisableSecureWindows = disableSecureWindows;
                mRoot.refreshSecureSurfaceState();
            }
        }
    }

    PowerManager mPowerManager;
@@ -1115,6 +1147,8 @@ public class WindowManagerService extends IWindowManager.Stub

    private final ScreenRecordingCallbackController mScreenRecordingCallbackController;

    private volatile boolean mDisableSecureWindows = false;

    public static WindowManagerService main(final Context context, final InputManagerService im,
            final boolean showBootMsgs, WindowManagerPolicy policy,
            ActivityTaskManagerService atm) {
@@ -6897,6 +6931,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    pw.print(mLastFinishedFreezeSource);
                }
                pw.println();
        pw.print("  mDisableSecureWindows="); pw.println(mDisableSecureWindows);

        mInputManagerCallback.dump(pw, "  ");
        mSnapshotController.dump(pw, " ");
@@ -10068,4 +10103,8 @@ public class WindowManagerService extends IWindowManager.Stub
            mDragDropController.setGlobalDragListener(listener);
        }
    }

    boolean getDisableSecureWindows() {
        return mDisableSecureWindows;
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -1898,6 +1898,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    boolean isSecureLocked() {
        if (mWmService.getDisableSecureWindows()) {
            return false;
        }

        if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SECURE) != 0) {
            return true;
        }