diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 45488ff8d..f09d558e8 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -217,6 +217,9 @@ int BufferQueue::query(int what, int* outValue) case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: value = (mQueue.size() >= 2); break; + case NATIVE_WINDOW_CONSUMER_USAGE_BITS: + value = mConsumerUsageBits; + break; default: return BAD_VALUE; } diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 953f6f91d..bcdbedbaa 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -132,4 +133,21 @@ TEST_F(SurfaceTest, ConcreteTypeIsSurface) { EXPECT_EQ(NATIVE_WINDOW_SURFACE, result); } +TEST_F(SurfaceTest, QueryConsumerUsage) { + const int TEST_USAGE_FLAGS = + GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER; + sp bq = new BufferQueue(); + sp c = new BufferItemConsumer(bq, + TEST_USAGE_FLAGS); + sp s = new Surface(c->getProducerInterface()); + + sp anw(s); + + int flags = -1; + int err = anw->query(anw.get(), NATIVE_WINDOW_CONSUMER_USAGE_BITS, &flags); + + ASSERT_EQ(NO_ERROR, err); + ASSERT_EQ(TEST_USAGE_FLAGS, flags); +} + }