diff options
author | 2024-03-26 18:41:06 +0000 | |
---|---|---|
committer | 2024-05-07 17:04:53 +0000 | |
commit | 80fd68a08911b984fcfee6ad1960f9ff3bb6274d (patch) | |
tree | 979d0470f6443fa12707ea239ac708a394fdeabe /libs/input/SpriteController.cpp | |
parent | 4058c39493498d4628b6693f0091b80eab78ac54 (diff) |
Hide touch indicators on mirrored displays if a secure window is present
Utilise ISurfaceComposerClient::eSkipScreenshot to remove the tap
indicators from mirrored displays when a secure window is present.
End-to-end test will be added in an upcoming CL.
Test: manual test & atest PointerChoreographerTest PointerControllerTest
Bug: 325252005
Change-Id: I72a77b1a1b2c02a5e94f05e67d0cd39588086c81
Diffstat (limited to 'libs/input/SpriteController.cpp')
-rw-r--r-- | libs/input/SpriteController.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index a63453d655e2..0baa9291f54d 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -129,7 +129,7 @@ void SpriteController::doUpdateSprites() { update.state.surfaceVisible = false; update.state.surfaceControl = obtainSurface(update.state.surfaceWidth, update.state.surfaceHeight, - update.state.displayId); + update.state.displayId, update.state.skipScreenshot); if (update.state.surfaceControl != NULL) { update.surfaceChanged = surfaceChanged = true; } @@ -209,7 +209,7 @@ void SpriteController::doUpdateSprites() { (update.state.dirty & (DIRTY_ALPHA | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER | DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID | DIRTY_ICON_STYLE | - DIRTY_DRAW_DROP_SHADOW))))) { + DIRTY_DRAW_DROP_SHADOW | DIRTY_SKIP_SCREENSHOT))))) { needApplyTransaction = true; if (wantSurfaceVisibleAndDrawn @@ -260,6 +260,14 @@ void SpriteController::doUpdateSprites() { t.setLayer(update.state.surfaceControl, surfaceLayer); } + if (wantSurfaceVisibleAndDrawn && + (becomingVisible || (update.state.dirty & DIRTY_SKIP_SCREENSHOT))) { + int32_t flags = + update.state.skipScreenshot ? ISurfaceComposerClient::eSkipScreenshot : 0; + t.setFlags(update.state.surfaceControl, flags, + ISurfaceComposerClient::eSkipScreenshot); + } + if (becomingVisible) { t.show(update.state.surfaceControl); @@ -332,8 +340,8 @@ void SpriteController::ensureSurfaceComposerClient() { } } -sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height, - int32_t displayId) { +sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height, int32_t displayId, + bool hideOnMirrored) { ensureSurfaceComposerClient(); const sp<SurfaceControl> parent = mParentSurfaceProvider(displayId); @@ -341,11 +349,13 @@ sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height ALOGE("Failed to get the parent surface for pointers on display %d", displayId); } + int32_t createFlags = ISurfaceComposerClient::eHidden | ISurfaceComposerClient::eCursorWindow; + if (hideOnMirrored) { + createFlags |= ISurfaceComposerClient::eSkipScreenshot; + } const sp<SurfaceControl> surfaceControl = mSurfaceComposerClient->createSurface(String8("Sprite"), width, height, - PIXEL_FORMAT_RGBA_8888, - ISurfaceComposerClient::eHidden | - ISurfaceComposerClient::eCursorWindow, + PIXEL_FORMAT_RGBA_8888, createFlags, parent ? parent->getHandle() : nullptr); if (surfaceControl == nullptr || !surfaceControl->isValid()) { ALOGE("Error creating sprite surface."); @@ -474,6 +484,15 @@ void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) { } } +void SpriteController::SpriteImpl::setSkipScreenshot(bool skip) { + AutoMutex _l(mController.mLock); + + if (mLocked.state.skipScreenshot != skip) { + mLocked.state.skipScreenshot = skip; + invalidateLocked(DIRTY_SKIP_SCREENSHOT); + } +} + void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) { bool wasDirty = mLocked.state.dirty; mLocked.state.dirty |= dirty; |