diff options
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 43 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowStateAnimator.java | 8 |
2 files changed, 33 insertions, 18 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index d55c25fc1a4f..c698b926e233 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -316,11 +316,19 @@ public final class SurfaceControl implements Parcelable { public static final int HIDDEN = 0x00000004; /** - * Surface creation flag: The surface contains secure content, special - * measures will be taken to disallow the surface's content to be copied - * from another process. In particular, screenshots and VNC servers will - * be disabled, but other measures can take place, for instance the - * surface might not be hardware accelerated. + * Surface creation flag: Skip this layer and its children when taking a screenshot. This + * also includes mirroring and screen recording, so the layers with flag SKIP_SCREENSHOT + * will not be included on non primary displays. + * @hide + */ + public static final int SKIP_SCREENSHOT = 0x00000040; + + /** + * Surface creation flag: Special measures will be taken to disallow the surface's content to + * be copied. In particular, screenshots and secondary, non-secure displays will render black + * content instead of the surface content. + * + * @see #createDisplay(String, boolean) * @hide */ public static final int SECURE = 0x00000080; @@ -482,15 +490,6 @@ public final class SurfaceControl implements Parcelable { public static final int POWER_MODE_ON_SUSPEND = 4; /** - * 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; - - /** * internal representation of how to interpret pixel value, used only to convert to ColorSpace. */ private static final int INTERNAL_DATASPACE_SRGB = 142671872; @@ -3287,6 +3286,22 @@ public final class SurfaceControl implements Parcelable { return this; } + /** + * Adds or removes the flag SKIP_SCREENSHOT of the surface. Setting the flag is equivalent + * to creating the Surface with the {@link #SKIP_SCREENSHOT} flag. + * + * @hide + */ + public Transaction setSkipScreenshot(SurfaceControl sc, boolean skipScrenshot) { + checkPreconditions(sc); + if (skipScrenshot) { + nativeSetFlags(mNativeObject, sc.mNativeObject, SKIP_SCREENSHOT, SKIP_SCREENSHOT); + } else { + nativeSetFlags(mNativeObject, sc.mNativeObject, 0, SKIP_SCREENSHOT); + } + return this; + } + /** * Merge the other transaction into this transaction, clearing the * other transaction as if it had been applied. diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 5e814005a5e2..029c158814b3 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -441,10 +441,6 @@ 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) { @@ -462,6 +458,10 @@ class WindowStateAnimator { flags |= SurfaceControl.SECURE; } + if ((mWin.mAttrs.privateFlags & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0) { + flags |= SurfaceControl.SKIP_SCREENSHOT; + } + calculateSurfaceBounds(w, attrs, mTmpSize); final int width = mTmpSize.width(); final int height = mTmpSize.height(); |