am 5ff5a84e: allow "system" screenshots even when the secure flag is set

* commit '5ff5a84e4829bad9eb44cc9a32d8579ca089051b':
  allow "system" screenshots even when the secure flag is set
This commit is contained in:
Mathias Agopian 2013-08-13 16:03:51 -07:00 committed by Android Git Automerger
commit 0aaa19271b

View File

@ -2662,6 +2662,18 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
if (CC_UNLIKELY(producer == 0)) if (CC_UNLIKELY(producer == 0))
return BAD_VALUE; return BAD_VALUE;
// if we have secure windows on this display, never allow the screen capture
// unless the producer interface is local (i.e.: we can take a screenshot for
// ourselves).
if (!producer->asBinder()->localBinder()) {
Mutex::Autolock _l(mStateLock);
sp<const DisplayDevice> hw(getDisplayDevice(display));
if (hw->getSecureLayerVisible()) {
ALOGW("FB is protected: PERMISSION_DENIED");
return PERMISSION_DENIED;
}
}
class MessageCaptureScreen : public MessageBase { class MessageCaptureScreen : public MessageBase {
SurfaceFlinger* flinger; SurfaceFlinger* flinger;
sp<IBinder> display; sp<IBinder> display;
@ -2786,12 +2798,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(
const uint32_t hw_w = hw->getWidth(); const uint32_t hw_w = hw->getWidth();
const uint32_t hw_h = hw->getHeight(); const uint32_t hw_h = hw->getHeight();
// 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 ((reqWidth > hw_w) || (reqHeight > hw_h)) { if ((reqWidth > hw_w) || (reqHeight > hw_h)) {
ALOGE("size mismatch (%d, %d) > (%d, %d)", ALOGE("size mismatch (%d, %d) > (%d, %d)",
reqWidth, reqHeight, hw_w, hw_h); reqWidth, reqHeight, hw_w, hw_h);