Move IGraphicBufferProducer to graphics/bufferqueue.

Test: With CtsMediaTestCases.apk installed,
adb shell am instrument -e size small -w
'android.media.cts/android.support.test.runner.AndroidJUnitRunner'

Bug: 35442034
Change-Id: Ia1ef0eb069fcd97f7afcf42bf3bb16c8c6a752c4
diff --git a/graphics/Android.bp b/graphics/Android.bp
index eaa47ae..f4f7db4 100644
--- a/graphics/Android.bp
+++ b/graphics/Android.bp
@@ -3,6 +3,7 @@
     "allocator/2.0",
     "allocator/2.0/default",
     "allocator/2.0/vts/functional",
+    "bufferqueue/1.0",
     "common/1.0",
     "composer/2.1",
     "composer/2.1/default",
diff --git a/graphics/bufferqueue/1.0/Android.bp b/graphics/bufferqueue/1.0/Android.bp
new file mode 100644
index 0000000..4ba764f
--- /dev/null
+++ b/graphics/bufferqueue/1.0/Android.bp
@@ -0,0 +1,70 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+    name: "android.hardware.graphics.bufferqueue@1.0_hal",
+    srcs: [
+        "IGraphicBufferProducer.hal",
+        "IProducerListener.hal",
+    ],
+}
+
+genrule {
+    name: "android.hardware.graphics.bufferqueue@1.0_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.graphics.bufferqueue@1.0",
+    srcs: [
+        ":android.hardware.graphics.bufferqueue@1.0_hal",
+    ],
+    out: [
+        "android/hardware/graphics/bufferqueue/1.0/GraphicBufferProducerAll.cpp",
+        "android/hardware/graphics/bufferqueue/1.0/ProducerListenerAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.graphics.bufferqueue@1.0_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.graphics.bufferqueue@1.0",
+    srcs: [
+        ":android.hardware.graphics.bufferqueue@1.0_hal",
+    ],
+    out: [
+        "android/hardware/graphics/bufferqueue/1.0/IGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/IHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BnHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BpHwGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/BsGraphicBufferProducer.h",
+        "android/hardware/graphics/bufferqueue/1.0/IProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/IHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BnHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BpHwProducerListener.h",
+        "android/hardware/graphics/bufferqueue/1.0/BsProducerListener.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.graphics.bufferqueue@1.0",
+    generated_sources: ["android.hardware.graphics.bufferqueue@1.0_genc++"],
+    generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.graphics.bufferqueue@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.graphics.common@1.0",
+        "android.hardware.media@1.0",
+        "android.hidl.base@1.0",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.graphics.common@1.0",
+        "android.hardware.media@1.0",
+        "android.hidl.base@1.0",
+    ],
+}
diff --git a/media/omx/1.0/IOmxBufferProducer.hal b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
similarity index 95%
rename from media/omx/1.0/IOmxBufferProducer.hal
rename to graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
index 7e2172b..c59a16c 100644
--- a/media/omx/1.0/IOmxBufferProducer.hal
+++ b/graphics/bufferqueue/1.0/IGraphicBufferProducer.hal
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2017 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,20 +14,29 @@
  * limitations under the License.
  */
 
-package android.hardware.media.omx@1.0;
+package android.hardware.graphics.bufferqueue@1.0;
+
+import android.hardware.media@1.0::Fence;
+import android.hardware.media@1.0::AnwBuffer;
+import android.hardware.media@1.0::Rect;
+import android.hardware.media@1.0::Region;
 
 import android.hardware.graphics.common@1.0::Dataspace;
 import android.hardware.graphics.common@1.0::PixelFormat;
 
-import android.hardware.media@1.0::types;
-import IOmxProducerListener;
+import IProducerListener;
 
 /**
  * Ref: frameworks/native/include/gui/IGraphicBufferProducer.h:
  *      IGraphicBufferProducer
  * This is a wrapper/wrapped HAL interface for the actual binder interface.
  */
-interface IOmxBufferProducer {
+interface IGraphicBufferProducer {
+
+    /**
+     * Type for return values of functions in IGraphicBufferProducer.
+     */
+    typedef int32_t Status;
 
     /**
      * Ref: frameworks/native/include/ui/FenceTime.h: FenceTime::Snapshot
@@ -142,7 +151,7 @@
 
     /**
      * requestBuffer requests a new buffer for the given index. The server (i.e.
-     * the IOmxBufferProducer implementation) assigns the newly created
+     * the IProducerListener implementation) assigns the newly created
      * buffer to the given slot index, and the client is expected to mirror the
      * slot->buffer mapping so that it's not necessary to transfer an
      * AnwBuffer for every dequeue operation.
@@ -466,12 +475,12 @@
         );
 
     /**
-     * connect attempts to connect a client API to the IOmxBufferProducer.
-     * This must be called before any other IOmxBufferProducer methods are
+     * connect attempts to connect a client API to the IGraphicBufferProducer.
+     * This must be called before any other IGraphicBufferProducer methods are
      * called except for getAllocator. A consumer must be already connected.
      *
      * This method will fail if the connect was previously called on the
-     * IOmxBufferProducer and no corresponding disconnect call was made.
+     * IGraphicBufferProducer and no corresponding disconnect call was made.
      *
      * The listener is an optional binder callback object that can be used if
      * the producer wants to be notified when the consumer releases a buffer
@@ -506,7 +515,7 @@
      * should be treated as opaque fatal unrecoverable errors.
      */
     connect(
-            IOmxProducerListener listener,
+            IProducerListener listener,
             int32_t api,
             bool producerControlledByApp
         ) generates (
@@ -516,8 +525,8 @@
 
     /**
      * disconnect attempts to disconnect a client API from the
-     * IOmxBufferProducer.  Calling this method will cause any subsequent
-     * calls to other IOmxBufferProducer methods to fail except for
+     * IGraphicBufferProducer.  Calling this method will cause any subsequent
+     * calls to other IGraphicBufferProducer methods to fail except for
      * getAllocator and connect.  Successfully calling connect after this will
      * allow the other methods to succeed again.
      *
@@ -526,7 +535,7 @@
      * Alternatively if mode is AllLocal, then the API value is ignored, and any API
      * connected from the same PID calling disconnect will be disconnected.
      *
-     * Disconnecting from an abandoned IOmxBufferProducer is legal and
+     * Disconnecting from an abandoned IGraphicBufferProducer is legal and
      * is considered a no-op.
      *
      * Return of a value other than NO_ERROR means an error has occurred:
@@ -543,7 +552,7 @@
         );
 
     /**
-     * Attaches a sideband buffer stream to the IOmxBufferProducer.
+     * Attaches a sideband buffer stream to the IGraphicBufferProducer.
      *
      * A sideband stream is a device-specific mechanism for passing buffers
      * from the producer to the consumer without using dequeueBuffer/
diff --git a/media/omx/1.0/IOmxProducerListener.hal b/graphics/bufferqueue/1.0/IProducerListener.hal
similarity index 91%
rename from media/omx/1.0/IOmxProducerListener.hal
rename to graphics/bufferqueue/1.0/IProducerListener.hal
index 7fde93b..206a500 100644
--- a/media/omx/1.0/IOmxProducerListener.hal
+++ b/graphics/bufferqueue/1.0/IProducerListener.hal
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package android.hardware.media.omx@1.0;
+package android.hardware.graphics.bufferqueue@1.0;
 
 /**
  * Ref: frameworks/native/include/gui/IProducerListener.h: IProducerListener
  * This is a wrapper/wrapped HAL interface for the actual binder interface.
  */
-interface IOmxProducerListener {
+interface IProducerListener {
     oneway onBufferReleased();
     needsReleaseNotify() generates (bool result);
 };
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index 85d15ae..81dd617 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -6,11 +6,9 @@
         "types.hal",
         "IGraphicBufferSource.hal",
         "IOmx.hal",
-        "IOmxBufferProducer.hal",
         "IOmxBufferSource.hal",
         "IOmxNode.hal",
         "IOmxObserver.hal",
-        "IOmxProducerListener.hal",
     ],
 }
 
@@ -25,11 +23,9 @@
         "android/hardware/media/omx/1.0/types.cpp",
         "android/hardware/media/omx/1.0/GraphicBufferSourceAll.cpp",
         "android/hardware/media/omx/1.0/OmxAll.cpp",
-        "android/hardware/media/omx/1.0/OmxBufferProducerAll.cpp",
         "android/hardware/media/omx/1.0/OmxBufferSourceAll.cpp",
         "android/hardware/media/omx/1.0/OmxNodeAll.cpp",
         "android/hardware/media/omx/1.0/OmxObserverAll.cpp",
-        "android/hardware/media/omx/1.0/OmxProducerListenerAll.cpp",
     ],
 }
 
@@ -52,11 +48,6 @@
         "android/hardware/media/omx/1.0/BnHwOmx.h",
         "android/hardware/media/omx/1.0/BpHwOmx.h",
         "android/hardware/media/omx/1.0/BsOmx.h",
-        "android/hardware/media/omx/1.0/IOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/IHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BnHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BpHwOmxBufferProducer.h",
-        "android/hardware/media/omx/1.0/BsOmxBufferProducer.h",
         "android/hardware/media/omx/1.0/IOmxBufferSource.h",
         "android/hardware/media/omx/1.0/IHwOmxBufferSource.h",
         "android/hardware/media/omx/1.0/BnHwOmxBufferSource.h",
@@ -72,11 +63,6 @@
         "android/hardware/media/omx/1.0/BnHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BpHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BsOmxObserver.h",
-        "android/hardware/media/omx/1.0/IOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/IHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BnHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BpHwOmxProducerListener.h",
-        "android/hardware/media/omx/1.0/BsOmxProducerListener.h",
     ],
 }
 
@@ -92,6 +78,7 @@
         "liblog",
         "libutils",
         "libcutils",
+        "android.hardware.graphics.bufferqueue@1.0",
         "android.hardware.graphics.common@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
@@ -101,6 +88,7 @@
         "libhidltransport",
         "libhwbinder",
         "libutils",
+        "android.hardware.graphics.bufferqueue@1.0",
         "android.hardware.graphics.common@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
diff --git a/media/omx/1.0/IOmx.hal b/media/omx/1.0/IOmx.hal
index acb1aae..78d4b32 100644
--- a/media/omx/1.0/IOmx.hal
+++ b/media/omx/1.0/IOmx.hal
@@ -16,11 +16,11 @@
 
 package android.hardware.media.omx@1.0;
 
+import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer;
 import android.hardware.media@1.0::types;
 
 import IOmxNode;
 import IOmxObserver;
-import IOmxBufferProducer;
 import IGraphicBufferSource;
 
 /**
@@ -76,7 +76,7 @@
     createInputSurface(
         ) generates (
             Status status,
-            IOmxBufferProducer producer,
+            IGraphicBufferProducer producer,
             IGraphicBufferSource source
         );
 };