Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17dde617 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

BlastBufferQueue: Handle queue to window composer queries

When queuing protected buffers, libstagefright queries
ANativeWindow to check if the ANativeWindow sends buffers
directly to SurfaceFlinger. This check works by verifying
the IGBP matches one of the tracked IGBPs in SurfaceFlinger.

This does not apply to blast layers since SurfaceFlinger does
not create IGBPs and there may not be any IGBP used to
submit buffers. To fix this for the blast adapter, we query the
blast buffer queue producer to see if it queues to
SurfaceFlinger.

Bug: b/175904021, b/168917217

Test: atest BlastBufferQueueTest
Test: Play protected content via Google Play on AndroidTV

Change-Id: Id1affce09742c6b438c7499b525615b8bd294b9a
parent 0e94797b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -600,6 +600,14 @@ public:
        return BufferQueueProducer::connect(new AsyncProducerListener(listener), api,
                                            producerControlledByApp, output);
    }

    int query(int what, int* value) override {
        if (what == NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER) {
            *value = 1;
            return NO_ERROR;
        }
        return BufferQueueProducer::query(what, value);
    }
};

// Similar to BufferQueue::createBufferQueue but creates an adapter specific bufferqueue producer.
+4 −0
Original line number Diff line number Diff line
@@ -985,6 +985,10 @@ int Surface::query(int what, int* value) const {
                }
                break;
            case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
                status_t err = mGraphicBufferProducer->query(what, value);
                if (err == NO_ERROR) {
                    return NO_ERROR;
                }
                if (composerService()->authenticateSurfaceTexture(
                        mGraphicBufferProducer)) {
                    *value = 1;
+13 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <gui/FrameTimestamps.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/IProducerListener.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/SyncScreenCaptureListener.h>
#include <private/gui/ComposerService.h>
@@ -515,6 +516,18 @@ TEST_F(BLASTBufferQueueTest, CustomProducerListener) {
    adapter.waitForCallbacks();
}

TEST_F(BLASTBufferQueueTest, QueryNativeWindowQueuesToWindowComposer) {
    BLASTBufferQueueHelper adapter(mSurfaceControl, mDisplayWidth, mDisplayHeight);

    sp<android::Surface> surface = new Surface(adapter.getIGraphicBufferProducer());
    ANativeWindow* nativeWindow = (ANativeWindow*)(surface.get());
    int queuesToNativeWindow = 0;
    int err = nativeWindow->query(nativeWindow, NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
                                  &queuesToNativeWindow);
    ASSERT_EQ(NO_ERROR, err);
    ASSERT_EQ(queuesToNativeWindow, 1);
}

class BLASTBufferQueueTransformTest : public BLASTBufferQueueTest {
public:
    void test(uint32_t tr) {