From f0681b34dffc1510cbd9c3da5c3a7e695553fa8d Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 23 Oct 2012 17:35:57 -0700 Subject: Secure windows, secure surface views and secure displays. Add new API to determine whether a display is secure. Add new API to make a SurfaceView secure. Clarify documentation. Bug: 7368436 Change-Id: I7068c34c910e43b4bc72e43fa0dded59a25f0fe2 --- core/java/android/view/SurfaceView.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'core/java/android/view/SurfaceView.java') diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 0d16dd31b0bc..9008521e3b1d 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -385,7 +385,27 @@ public class SurfaceView extends View { mLayout.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } } - + + /** + * Control whether the surface view's content should be treated as secure, + * preventing it from appearing in screenshots or from being viewed on + * non-secure displays. + * + *

Note that this must be set before the surface view's containing + * window is attached to the window manager. + * + *

See {@link android.view.Display#FLAG_SECURE} for details. + * + * @param isSecure True if the surface view is secure. + */ + public void setSecure(boolean isSecure) { + if (isSecure) { + mLayout.flags |= WindowManager.LayoutParams.FLAG_SECURE; + } else { + mLayout.flags &= ~WindowManager.LayoutParams.FLAG_SECURE; + } + } + /** * Hack to allow special layering of windows. The type is one of the * types in WindowManager.LayoutParams. This is a hack so: -- cgit v1.2.3