Skip to content

Commit

Permalink
frameworks/native: Add support for Secure Display
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Ramkumar Radhakrishnan authored and Whitehawkx committed Dec 21, 2013
1 parent 6cbff65 commit aa52da5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
12 changes: 12 additions & 0 deletions services/surfaceflinger/Layer.cpp
Expand Up @@ -1283,6 +1283,18 @@ bool Layer::isIntOnly() const
}
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
// ---------------------------------------------------------------------------
}; // namespace android
Expand Down
1 change: 1 addition & 0 deletions services/surfaceflinger/Layer.h
Expand Up @@ -261,6 +261,7 @@ class Layer : public SurfaceFlingerConsumer::FrameAvailableListener {
#ifdef QCOM_BSP
virtual bool isExtOnly() const;
virtual bool isIntOnly() const;
virtual bool isSecureDisplay() const;
#endif

/*
Expand Down
23 changes: 19 additions & 4 deletions services/surfaceflinger/SurfaceFlinger.cpp
Expand Up @@ -1592,18 +1592,25 @@ void SurfaceFlinger::computeVisibleRegions(size_t dpy,

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
Expand All @@ -1617,7 +1624,9 @@ void SurfaceFlinger::computeVisibleRegions(size_t dpy,
// 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
Expand Down Expand Up @@ -3088,6 +3097,12 @@ void SurfaceFlinger::renderScreenImplLocked(
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);
layer->draw(hw);
Expand Down

0 comments on commit aa52da5

Please sign in to comment.