From ef7b9c7eac036cc1230c64821039d18f8cbd2c1c Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 10 Aug 2012 15:22:19 -0700 Subject: [PATCH] screenshots could stop working after camera was used once a secure window is put on screen the display would retain its "secure" flag forever, preventing screenshots from being taken. Bug: 6933967 Change-Id: I5be8355145ca7d580d84552311642f8fa912fe6a --- services/surfaceflinger/DisplayDevice.cpp | 1 + services/surfaceflinger/SurfaceFlinger.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index e3655f8e0..cdc8a9f4f 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -244,6 +244,7 @@ void DisplayDevice::makeCurrent(const sp& hw, EGLContext ct void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp >& layers) { mVisibleLayersSortedByZ = layers; + mSecureLayerVisible = false; size_t count = layers.size(); for (size_t i=0 ; iisSecure()) { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e7923be9a..ac3fb90f8 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2095,6 +2095,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, // only one display supported for now if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) { + ALOGE("invalid display %d", dpy); return BAD_VALUE; } @@ -2109,10 +2110,12 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, // if we have secure windows on this display, never allow the screen capture if (hw->getSecureLayerVisible()) { + ALOGW("FB is protected: PERMISSION_DENIED"); return PERMISSION_DENIED; } if ((sw > hw_w) || (sh > hw_h)) { + ALOGE("size mismatch (%d, %d) > (%d, %d)", sw, sh, hw_w, hw_h); return BAD_VALUE; } @@ -2121,8 +2124,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, const size_t size = sw * sh * 4; const bool filtering = sw != hw_w || sh != hw_h; - //ALOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d", - // sw, sh, minLayerZ, maxLayerZ); +// ALOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d", +// sw, sh, minLayerZ, maxLayerZ); // make sure to clear all GL error flags while ( glGetError() != GL_NO_ERROR ) ; @@ -2209,7 +2212,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, hw->compositionComplete(); - // ALOGD("screenshot: result = %s", result<0 ? strerror(result) : "OK"); +// ALOGD("screenshot: result = %s", result<0 ? strerror(result) : "OK"); return result; }