From 0026f65e2a56440af00510dc9a5d7b3e8183059e Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 8 May 2020 11:35:11 -0700 Subject: [PATCH] Account for DPM state when checking FLAG_SECURE - If the profile has disable screen capture enabled on their work profile, then DPM service will directly set the secure state on the surfaces, but the window flags aren't updated. Callers need to check the cache state to also ensure that they report the right secure state when taking a snapshot and when rotating. Bug: 156104186 Test: Open a work profile app with screen capture disabled and ensure the task snapshot dump state reflects the secure state Change-Id: I7cc6d525c818346846d27bdfad1961b464dfb46d --- .../core/java/com/android/server/wm/ActivityRecord.java | 6 +++--- .../core/java/com/android/server/wm/DisplayContent.java | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 850b6576bc894..f33e2eb6d5784 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -97,7 +97,6 @@ import static android.view.Display.INVALID_DISPLAY; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; -import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; @@ -4311,8 +4310,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * screenshot. */ boolean shouldUseAppThemeSnapshot() { - return mDisablePreviewScreenshots || forAllWindows(w -> (w.mAttrs.flags & FLAG_SECURE) != 0, - true /* topToBottom */); + return mDisablePreviewScreenshots || forAllWindows(w -> { + return mWmService.isSecureLocked(w); + }, true /* topToBottom */); } /** diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 5dd8e28a8a330..0f09752b6f34f 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -54,7 +54,6 @@ import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; -import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; @@ -3705,8 +3704,7 @@ class DisplayContent extends WindowContainer w.isOnScreen() && (w.mAttrs.flags & FLAG_SECURE) != 0); + final WindowState win = getWindow(w -> w.isOnScreen() && mWmService.isSecureLocked(w)); return win != null; }