From 132c9f5140c53c24ce6b41f7c8c94d93773194c2 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 31 Jul 2017 17:02:30 -0700 Subject: [PATCH] Inform SurfaceFlinger of which Surface is the RoundedCorners overlay. We need to omit it from screenshots, and screen mirroring, so SurfaceFlinger will have to have some knowledge. Eventually we'd like to do this by having everything else have a parent, and mirroring and screenshotting will operate on that parent. Since we aren't comfortable doing that for DR though, here's a quick and dirty hack to tide us over with low risk. Bug: 63311708 Test: screencap, screenrecord, android.view.cts.SurfaceViewSyncTest Change-Id: I2b43be00567ee19cf27aeef344e5415f4a69297f --- core/java/android/view/SurfaceControl.java | 9 +++++++++ core/java/android/view/WindowManager.java | 7 ++++--- .../src/com/android/systemui/RoundedCorners.java | 2 +- .../com/android/server/wm/AccessibilityController.java | 4 ++-- .../java/com/android/server/wm/WindowStateAnimator.java | 5 +++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 22329f4e772b0..44c88e1468795 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -271,6 +271,15 @@ public class SurfaceControl { */ public static final int POWER_MODE_DOZE_SUSPEND = 3; + /** + * A value for windowType used to indicate that the window should be omitted from screenshots + * and display mirroring. A temporary workaround until we express such things with + * the hierarchy. + * TODO: b/64227542 + * @hide + */ + public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731; + /** * Create a surface with a name. *

diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index faf3e1258929a..d60ba16dbad64 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1405,11 +1405,12 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_TASK_SNAPSHOT = 0x00080000; /** - * Flag to indicate that this window should be ignored when determining what parts of the - * screen can be magnified. + * Indicates that this window is the rounded corners overlay present on some + * devices this means that it will be excluded from: screenshots, + * screen magnification, and mirroring. * @hide */ - public static final int PRIVATE_FLAG_NO_MAGNIFICATION_REGION_EFFECT = 0x00100000; + public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000; /** * Control flags that are private to the platform. diff --git a/packages/SystemUI/src/com/android/systemui/RoundedCorners.java b/packages/SystemUI/src/com/android/systemui/RoundedCorners.java index 74a150551c15f..2bec2c7850ec9 100644 --- a/packages/SystemUI/src/com/android/systemui/RoundedCorners.java +++ b/packages/SystemUI/src/com/android/systemui/RoundedCorners.java @@ -121,7 +121,7 @@ public class RoundedCorners extends SystemUI implements Tunable { , PixelFormat.TRANSLUCENT); lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS - | WindowManager.LayoutParams.PRIVATE_FLAG_NO_MAGNIFICATION_REGION_EFFECT; + | WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; lp.setTitle("RoundedOverlay"); lp.gravity = Gravity.TOP; return lp; diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 78f21956f5489..805250ad96d4f 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -17,7 +17,7 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; -import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MAGNIFICATION_REGION_EFFECT; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; @@ -539,7 +539,7 @@ final class AccessibilityController { WindowState windowState = visibleWindows.valueAt(i); if ((windowState.mAttrs.type == TYPE_MAGNIFICATION_OVERLAY) || ((windowState.mAttrs.privateFlags - & PRIVATE_FLAG_NO_MAGNIFICATION_REGION_EFFECT) != 0)) { + & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0)) { continue; } diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 23b515e3c5c98..c610ca3818976 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -20,6 +20,7 @@ import static android.app.ActivityManager.StackId; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; import static android.view.WindowManager.LayoutParams.FLAG_SCALED; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; @@ -631,6 +632,10 @@ class WindowStateAnimator { return mSurfaceController; } + if ((mWin.mAttrs.privateFlags & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0) { + windowType = SurfaceControl.WINDOW_TYPE_DONT_SCREENSHOT; + } + w.setHasSurface(false); if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG,