frameworks/native: Add support for Secure Display
- Add secure UI layers to primary and remove other layers from
internal and external list for Secure Display usecase.
- Dont let secure UI layers to be captured on screen
Change-Id: Iebdad5c56247308604ee90928f6d6460a1f69279
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 51dcd3c..ff48cd2 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -832,6 +832,7 @@
#ifdef QCOM_BSP
setUsage(mReqUsage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY |
mReqUsage & GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY |
+ mReqUsage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY |
GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_OFTEN);
#else
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f962331..67ea13a 100755
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1487,6 +1487,18 @@
}
return false;
}
+
+bool Layer::isSecureDisplay() const
+{
+ const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
+ if (activeBuffer != 0) {
+ uint32_t usage = activeBuffer->getUsage();
+ if(usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY)
+ return true;
+ }
+ return false;
+}
+
#endif
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 0f2da28..c94ebea 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -277,6 +277,7 @@
#ifdef QCOM_BSP
virtual bool isExtOnly() const;
virtual bool isIntOnly() const;
+ virtual bool isSecureDisplay() const;
#endif
/*
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fd22039..026e22a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1756,18 +1756,25 @@
outDirtyRegion.clear();
bool bIgnoreLayers = false;
- int extOnlyLayerIndex = -1;
+ int indexLOI = -1;
size_t i = currentLayers.size();
#ifdef QCOM_BSP
while (i--) {
const sp<Layer>& layer = currentLayers[i];
// iterate through the layer list to find ext_only layers and store
// the index
- if ((dpy && layer->isExtOnly())) {
+ if (layer->isSecureDisplay()) {
bIgnoreLayers = true;
- extOnlyLayerIndex = i;
+ indexLOI = -1;
+ if(!dpy)
+ indexLOI = i;
break;
}
+
+ if (dpy && layer->isExtOnly()) {
+ bIgnoreLayers = true;
+ indexLOI = i;
+ }
}
i = currentLayers.size();
#endif
@@ -1781,7 +1788,9 @@
// Only add the layer marked as "external_only" to external list and
// only remove the layer marked as "external_only" from primary list
// and do not add the layer marked as "internal_only" to external list
- if((bIgnoreLayers && extOnlyLayerIndex != (int)i) ||
+ // Add secure UI layers to primary and remove other layers from internal
+ //and external list
+ if((bIgnoreLayers && indexLOI != (int)i) ||
(!dpy && layer->isExtOnly()) ||
(dpy && layer->isIntOnly())) {
// Ignore all other layers except the layers marked as ext_only
@@ -3474,6 +3483,12 @@
const Layer::State& state(layer->getDrawingState());
if (state.layerStack == hw->getLayerStack()) {
if (state.z >= minLayerZ && state.z <= maxLayerZ) {
+#ifdef QCOM_BSP
+ // dont render the secure Display Layer
+ if(layer->isSecureDisplay()) {
+ continue;
+ }
+#endif
if (layer->isVisible()) {
if (filtering) layer->setFiltering(true);
if(!layer->isProtected())