Migrate from aidl to manual implementation

Since aidl does not support uint32_t as there is no unsigned int in
Java, after discussion we decided to stop using aidl as there are many
low-level flags implemented as unsigned int in current system, and it
will be more effort to fit them into aidl than write the boiler plate
by ourselves.

Test: "atest buffer_hub_binder_service-test" passed.
Bug: 117559794
Change-Id: I81c799e9507d686e92e34544c9b48b91c7a37157
diff --git a/services/vr/bufferhubd/Android.bp b/services/vr/bufferhubd/Android.bp
index fc8ad80..ae955fb 100644
--- a/services/vr/bufferhubd/Android.bp
+++ b/services/vr/bufferhubd/Android.bp
@@ -28,13 +28,13 @@
 cc_library_static {
     name: "libbufferhubd",
     srcs: [
-        "binder/android/dvr/IBufferHub.aidl",
         "buffer_channel.cpp",
         "buffer_hub.cpp",
         "buffer_hub_binder.cpp",
         "buffer_node.cpp",
         "consumer_channel.cpp",
         "consumer_queue_channel.cpp",
+        "IBufferHub.cpp",
         "producer_channel.cpp",
         "producer_queue_channel.cpp",
     ],
@@ -49,11 +49,6 @@
     static_libs: [
         "libbufferhub",
     ],
-    aidl: {
-        local_include_dirs: ["binder"],
-        include_dirs: ["frameworks/native/aidl/binder"],
-        export_aidl_headers: true,
-    },
 }
 
 cc_binary {
diff --git a/services/vr/bufferhubd/IBufferHub.cpp b/services/vr/bufferhubd/IBufferHub.cpp
new file mode 100644
index 0000000..9d5b91a
--- /dev/null
+++ b/services/vr/bufferhubd/IBufferHub.cpp
@@ -0,0 +1,20 @@
+#include <log/log.h>
+#include <private/dvr/IBufferHub.h>
+
+namespace android {
+namespace dvr {
+
+IMPLEMENT_META_INTERFACE(BufferHub, "android.dvr.IBufferHub");
+
+status_t BnBufferHub::onTransact(uint32_t code, const Parcel& data,
+                                 Parcel* reply, uint32_t flags) {
+  switch (code) {
+    default:
+      // Should not reach
+      ALOGE("onTransact(): unknown code %u received!", code);
+      return BBinder::onTransact(code, data, reply, flags);
+  }
+}
+
+}  // namespace dvr
+}  // namespace android
\ No newline at end of file
diff --git a/services/vr/bufferhubd/binder/android/dvr/IBufferHub.aidl b/services/vr/bufferhubd/binder/android/dvr/IBufferHub.aidl
deleted file mode 100644
index 6a86adc..0000000
--- a/services/vr/bufferhubd/binder/android/dvr/IBufferHub.aidl
+++ /dev/null
@@ -1,5 +0,0 @@
-package android.dvr;
-
-/** {@hide} */
-interface IBufferHub {
-}
\ No newline at end of file
diff --git a/services/vr/bufferhubd/include/private/dvr/IBufferHub.h b/services/vr/bufferhubd/include/private/dvr/IBufferHub.h
new file mode 100644
index 0000000..266ae88
--- /dev/null
+++ b/services/vr/bufferhubd/include/private/dvr/IBufferHub.h
@@ -0,0 +1,30 @@
+#ifndef ANDROID_DVR_IBUFFERHUB_H
+#define ANDROID_DVR_IBUFFERHUB_H
+
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+
+namespace android {
+namespace dvr {
+
+class IBufferHub : public IInterface {
+ public:
+  DECLARE_META_INTERFACE(BufferHub);
+};
+
+class BnBufferHub : public BnInterface<IBufferHub> {
+ public:
+  virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply,
+                              uint32_t flags = 0);
+};
+
+class BpBufferHub : public BpInterface<IBufferHub> {
+ public:
+  explicit BpBufferHub(const sp<IBinder>& impl)
+      : BpInterface<IBufferHub>(impl) {}
+};
+
+}  // namespace dvr
+}  // namespace android
+
+#endif
\ No newline at end of file
diff --git a/services/vr/bufferhubd/include/private/dvr/buffer_hub_binder.h b/services/vr/bufferhubd/include/private/dvr/buffer_hub_binder.h
index 672a348..e266ff8 100644
--- a/services/vr/bufferhubd/include/private/dvr/buffer_hub_binder.h
+++ b/services/vr/bufferhubd/include/private/dvr/buffer_hub_binder.h
@@ -2,10 +2,9 @@
 #define ANDROID_DVR_BUFFER_HUB_BINDER_H
 
 #include <binder/BinderService.h>
+#include <private/dvr/IBufferHub.h>
 #include <private/dvr/buffer_hub.h>
 
-#include "android/dvr/BnBufferHub.h"
-
 namespace android {
 namespace dvr {