summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Patrick Williams <pdwilliams@google.com> 2024-03-12 10:02:18 -0500
committer Patrick Williams <pdwilliams@google.com> 2024-03-19 15:17:28 -0500
commit26afab2296d517189aa92ec4331ee92046edd53f (patch)
treea1a77680d4956758cb8ee5fd91b247692b3fda8b
parentc4c128e9b9e9b8db0e909b58b0332c3a4970b04e (diff)
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
-rw-r--r--core/java/android/provider/Settings.java7
-rw-r--r--packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java1
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java39
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java4
4 files changed, 51 insertions, 0 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e26dc73f7172..6917d69943d5 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -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 */
diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index 6eb2dd043c94..8cafe5faaa09 100644
--- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -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,
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 2934574acc03..c70c528f0031 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -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;
+ }
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c0cf97d6d4ae..ca8f7909220d 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -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;
}