All consumers now take an IGraphicBufferConsumer instead of a BufferQueue

this means they only have access to the consumer end of
the interface. we had a lot of code that assumed consumers
where holding a BufferQueue (i.e.: both ends), so most of
this change is untangling in fix that

Bug: 9265647
Change-Id: Ic2e2596ee14c7535f51bf26d9a897a0fc036d22c
diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h
index 9370e81..52edf17 100644
--- a/include/gui/BufferItemConsumer.h
+++ b/include/gui/BufferItemConsumer.h
@@ -87,8 +87,6 @@
     status_t releaseBuffer(const BufferItem &item,
             const sp<Fence>& releaseFence = Fence::NO_FENCE);
 
-    sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
-
     // setDefaultBufferSize is used to set the size of buffers returned by
     // requestBuffers when a with and height of zero is requested.
     status_t setDefaultBufferSize(uint32_t w, uint32_t h);
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 1fbfc2b..7e404fe 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -78,10 +78,6 @@
     BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
     virtual ~BufferQueue();
 
-    // dump our state in a String
-    virtual void dump(String8& result) const;
-    virtual void dump(String8& result, const char* prefix) const;
-
     /*
      * IGraphicBufferProducer interface
      */
@@ -302,6 +298,9 @@
     // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
     virtual status_t setTransformHint(uint32_t hint);
 
+    // dump our state in a String
+    virtual void dump(String8& result, const char* prefix) const;
+
 
 private:
     // freeBufferLocked frees the GraphicBuffer and sync resources for the
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index daad757..fb21185 100644
--- a/include/gui/ConsumerBase.h
+++ b/include/gui/ConsumerBase.h
@@ -66,10 +66,6 @@
     // log messages.
     void setName(const String8& name);
 
-    // getBufferQueue returns the BufferQueue object to which this
-    // ConsumerBase is connected.
-    sp<BufferQueue> getBufferQueue() const;
-
     // dump writes the current state to a string. Child classes should add
     // their state to the dump by overriding the dumpLocked method, which is
     // called by these methods after locking the mutex.
@@ -85,12 +81,11 @@
     void operator=(const ConsumerBase&);
 
 protected:
-
     // ConsumerBase constructs a new ConsumerBase object to consume image
-    // buffers from the given BufferQueue.
+    // buffers from the given IGraphicBufferConsumer.
     // The controlledByApp flag indicates that this consumer is under the application's
     // control.
-    ConsumerBase(const sp<BufferQueue> &bufferQueue, bool controlledByApp = false);
+    ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false);
 
     // onLastStrongRef gets called by RefBase just before the dtor of the most
     // derived class.  It is used to clean up the buffers so that ConsumerBase
@@ -104,7 +99,7 @@
     // from the derived class.
     virtual void onLastStrongRef(const void* id);
 
-    // Implementation of the BufferQueue::ConsumerListener interface.  These
+    // Implementation of the IConsumerListener interface.  These
     // calls are used to notify the ConsumerBase of asynchronous events in the
     // BufferQueue.  These methods should not need to be overridden by derived
     // classes, but if they are overridden the ConsumerBase implementation
@@ -155,7 +150,7 @@
     // initialization that must take place the first time a buffer is assigned
     // to a slot.  If it is overridden the derived class's implementation must
     // call ConsumerBase::acquireBufferLocked.
-    virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item,
+    virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item,
         nsecs_t presentWhen);
 
     // releaseBufferLocked relinquishes control over a buffer, returning that
@@ -226,7 +221,7 @@
 
     // The ConsumerBase has-a BufferQueue and is responsible for creating this object
     // if none is supplied
-    sp<BufferQueue> mBufferQueue;
+    sp<IGraphicBufferConsumer> mConsumer;
 
     // mMutex is the mutex used to prevent concurrent access to the member
     // variables of ConsumerBase objects. It must be locked whenever the
diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h
index 2890350..9290676 100644
--- a/include/gui/CpuConsumer.h
+++ b/include/gui/CpuConsumer.h
@@ -66,7 +66,7 @@
 
     // Create a new CPU consumer. The maxLockedBuffers parameter specifies
     // how many buffers can be locked for user access at the same time.
-    CpuConsumer(const sp<BufferQueue>& bq,
+    CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
             uint32_t maxLockedBuffers, bool controlledByApp = false);
 
     virtual ~CpuConsumer();
@@ -104,8 +104,6 @@
     // lockNextBuffer.
     status_t unlockBuffer(const LockedBuffer &nativeBuffer);
 
-    sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
-
   private:
     // Maximum number of buffers that can be locked at a time
     uint32_t mMaxLockedBuffers;
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h
index ac4a832..4c9aa87 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -32,10 +32,6 @@
 #include <utils/Vector.h>
 #include <utils/threads.h>
 
-#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
-#define ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID \
-                                         "mFrameAvailableListener"
-
 namespace android {
 // ----------------------------------------------------------------------------
 
@@ -85,7 +81,7 @@
     // purely to allow a GLConsumer to be transferred from one consumer
     // context to another. If such a transfer is not needed there is no
     // requirement that either of these methods be called.
-    GLConsumer(const sp<BufferQueue>& bq,
+    GLConsumer(const sp<IGraphicBufferConsumer>& bq,
             GLuint tex, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES,
             bool useFenceSync = true, bool isControlledByApp = false);
 
@@ -194,12 +190,6 @@
     status_t setConsumerUsageBits(uint32_t usage);
     status_t setTransformHint(uint32_t hint);
 
-    // getBufferQueue returns the BufferQueue object to which this
-    // GLConsumer is connected.
-    sp<BufferQueue> getBufferQueue() const {
-        return mBufferQueue;
-    }
-
     // detachFromContext detaches the GLConsumer from the calling thread's
     // current OpenGL ES context.  This context must be the same as the context
     // that was current for previous calls to updateTexImage.
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 82b50c8..2ad302f 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -188,6 +188,9 @@
     // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
     virtual status_t setTransformHint(uint32_t hint) = 0;
 
+    // dump state into a string
+    virtual void dump(String8& result, const char* prefix) const = 0;
+
 public:
     DECLARE_META_INTERFACE(GraphicBufferConsumer);
 };
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index 6bf5b47..643d7cf 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -165,6 +165,7 @@
 
 private:
     mutable sp<CpuConsumer> mCpuConsumer;
+    mutable sp<BufferQueue> mBufferQueue;
     CpuConsumer::LockedBuffer mBuffer;
     bool mHaveBuffer;