diff options
Diffstat (limited to 'services/surfaceflinger/tests/LayerTransaction_test.cpp')
-rw-r--r-- | services/surfaceflinger/tests/LayerTransaction_test.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/services/surfaceflinger/tests/LayerTransaction_test.cpp b/services/surfaceflinger/tests/LayerTransaction_test.cpp index ef992d6a40..97cba63192 100644 --- a/services/surfaceflinger/tests/LayerTransaction_test.cpp +++ b/services/surfaceflinger/tests/LayerTransaction_test.cpp @@ -18,6 +18,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" +#include <private/android_filesystem_config.h> #include <thread> #include "LayerTransactionTest.h" @@ -25,6 +26,43 @@ namespace android { using android::hardware::graphics::common::V1_1::BufferUsage; +TEST_F(LayerTransactionTest, SetFlagsSecureEUidSystem) { + sp<SurfaceControl> layer; + ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); + ASSERT_NO_FATAL_FAILURE(fillBufferQueueLayerColor(layer, Color::RED, 32, 32)); + + sp<ISurfaceComposer> composer = ComposerService::getComposerService(); + sp<GraphicBuffer> outBuffer; + Transaction() + .setFlags(layer, layer_state_t::eLayerSecure, layer_state_t::eLayerSecure) + .apply(true); + ASSERT_EQ(PERMISSION_DENIED, + composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, false)); + + UIDFaker f(AID_SYSTEM); + + // By default the system can capture screenshots with secure layers but they + // will be blacked out + ASSERT_EQ(NO_ERROR, composer->captureScreen(mDisplay, &outBuffer, Rect(), 0, 0, false)); + + { + SCOPED_TRACE("as system"); + auto shot = screenshot(); + shot->expectColor(Rect(0, 0, 32, 32), Color::BLACK); + } + + // Here we pass captureSecureLayers = true and since we are AID_SYSTEM we should be able + // to receive them...we are expected to take care with the results. + bool outCapturedSecureLayers; + ASSERT_EQ(NO_ERROR, + composer->captureScreen(mDisplay, &outBuffer, outCapturedSecureLayers, + ui::Dataspace::V0_SRGB, ui::PixelFormat::RGBA_8888, Rect(), 0, + 0, false, ui::ROTATION_0, true)); + ASSERT_EQ(true, outCapturedSecureLayers); + ScreenCapture sc(outBuffer); + sc.expectColor(Rect(0, 0, 32, 32), Color::RED); +} + TEST_F(LayerTransactionTest, SetTransformToDisplayInverse_BufferState) { sp<SurfaceControl> layer; ASSERT_NO_FATAL_FAILURE( @@ -50,7 +88,7 @@ TEST_F(LayerTransactionTest, ReparentToSelf) { sp<SurfaceControl> layer; ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); ASSERT_NO_FATAL_FAILURE(fillBufferQueueLayerColor(layer, Color::RED, 32, 32)); - Transaction().reparent(layer, layer).apply(); + Transaction().reparent(layer, layer->getHandle()).apply(); { // We expect the transaction to be silently dropped, but for SurfaceFlinger @@ -80,9 +118,10 @@ TEST_F(LayerTransactionTest, DISABLED_BufferQueueLayerMergeDamageRegionWhenDropp sp<SurfaceControl> layer; ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", width, height)); const auto producer = layer->getIGraphicBufferProducer(); - const sp<IProducerListener> stubListener(new StubProducerListener); + const sp<IProducerListener> dummyListener(new DummyProducerListener); IGraphicBufferProducer::QueueBufferOutput queueBufferOutput; - ASSERT_EQ(OK, producer->connect(stubListener, NATIVE_WINDOW_API_CPU, true, &queueBufferOutput)); + ASSERT_EQ(OK, + producer->connect(dummyListener, NATIVE_WINDOW_API_CPU, true, &queueBufferOutput)); std::map<int, sp<GraphicBuffer>> slotMap; auto slotToBuffer = [&](int slot, sp<GraphicBuffer>* buf) { |