Move VR HWC HAL impl to vr/hardware_composer and cleanup deps

VR HWC is no longer built into VR WM, but in VR HWC, so update its
location. Also cleanup dead code.

Bug: 36051907
Test: Compiled
Change-Id: I15763234fa93bf3b95b8df6461428fe65fd5f611
diff --git a/services/vr/hardware_composer/Android.bp b/services/vr/hardware_composer/Android.bp
index b94d333..25bb30b 100644
--- a/services/vr/hardware_composer/Android.bp
+++ b/services/vr/hardware_composer/Android.bp
@@ -1,3 +1,51 @@
+cc_library_shared {
+  name: "libvr_hwc-hal",
+
+  srcs: [
+    "impl/vr_hwc.cpp",
+    "impl/vr_composer_client.cpp",
+  ],
+
+  static_libs: [
+    "libhwcomposer-client",
+    "libdisplay",
+    "libbufferhubqueue",
+    "libbufferhub",
+    "libpdx_default_transport",
+  ],
+
+  shared_libs: [
+    "android.frameworks.vr.composer@1.0",
+    "android.hardware.graphics.composer@2.1",
+    "libbase",
+    "libcutils",
+    "libfmq",
+    "libhardware",
+    "libhidlbase",
+    "libhidltransport",
+    "liblog",
+    "libsync",
+    "libui",
+    "libutils",
+  ],
+
+  export_static_lib_headers: [
+    "libhwcomposer-client",
+  ],
+
+  export_shared_lib_headers: [
+    "android.frameworks.vr.composer@1.0",
+    "android.hardware.graphics.composer@2.1",
+  ],
+
+  export_include_dirs: ["."],
+
+  cflags: [
+    "-DLOG_TAG=\"vr_hwc\"",
+  ],
+
+}
+
 cc_library_static {
   name: "libvr_hwc-binder",
   srcs: [
@@ -12,11 +60,12 @@
     export_aidl_headers: true,
   },
   export_include_dirs: ["aidl"],
+
   shared_libs: [
     "libbinder",
     "libui",
     "libutils",
-    "libvrhwc",
+    "libvr_hwc-hal",
   ],
 }
 
@@ -34,10 +83,10 @@
     "liblog",
     "libui",
     "libutils",
-    "libvrhwc",
+    "libvr_hwc-hal",
   ],
   export_shared_lib_headers: [
-    "libvrhwc",
+    "libvr_hwc-hal",
   ],
   cflags: [
     "-DLOG_TAG=\"vr_hwc\"",
@@ -65,7 +114,7 @@
     "libhwbinder",
     "libui",
     "libutils",
-    "libvrhwc",
+    "libvr_hwc-hal",
   ],
   cflags: [
     "-DLOG_TAG=\"vr_hwc\"",
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp b/services/vr/hardware_composer/impl/vr_composer_client.cpp
similarity index 97%
rename from services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp
rename to services/vr/hardware_composer/impl/vr_composer_client.cpp
index e0bdf1c..ae54e56 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp
+++ b/services/vr/hardware_composer/impl/vr_composer_client.cpp
@@ -19,8 +19,8 @@
 #include <hardware/gralloc1.h>
 #include <log/log.h>
 
-#include "vr_hwc.h"
-#include "vr_composer_client.h"
+#include "impl/vr_hwc.h"
+#include "impl/vr_composer_client.h"
 
 namespace android {
 namespace dvr {
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_client.h b/services/vr/hardware_composer/impl/vr_composer_client.h
similarity index 90%
rename from services/vr/vr_window_manager/composer/impl/vr_composer_client.h
rename to services/vr/hardware_composer/impl/vr_composer_client.h
index 8d601ab..1236be9 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_client.h
+++ b/services/vr/hardware_composer/impl/vr_composer_client.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
+#ifndef ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
+#define ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
 
 #include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
 #include <ComposerClient.h>
@@ -68,4 +68,4 @@
 } // namespace dvr
 } // namespace android
 
-#endif  // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
+#endif  // ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
diff --git a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
similarity index 99%
rename from services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
rename to services/vr/hardware_composer/impl/vr_hwc.cpp
index f5d88f2..29983a7 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -13,14 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "vr_hwc.h"
+#include "impl/vr_hwc.h"
 
+#include <private/dvr/display_client.h>
 #include <ui/Fence.h>
 
 #include <mutex>
 
-#include <private/dvr/display_client.h>
-
 #include "vr_composer_client.h"
 
 using namespace android::hardware::graphics::common::V1_0;
diff --git a/services/vr/vr_window_manager/composer/impl/vr_hwc.h b/services/vr/hardware_composer/impl/vr_hwc.h
similarity index 98%
rename from services/vr/vr_window_manager/composer/impl/vr_hwc.h
rename to services/vr/hardware_composer/impl/vr_hwc.h
index 609d925..df04208 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_hwc.h
+++ b/services/vr/hardware_composer/impl/vr_hwc.h
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
+#ifndef ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
+#define ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
 
 #include <android-base/unique_fd.h>
 #include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
@@ -319,4 +319,4 @@
 }  // namespace dvr
 }  // namespace android
 
-#endif  // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
+#endif  // ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
diff --git a/services/vr/vr_window_manager/Android.bp b/services/vr/vr_window_manager/Android.bp
index 669426b..d7ddba1 100644
--- a/services/vr/vr_window_manager/Android.bp
+++ b/services/vr/vr_window_manager/Android.bp
@@ -12,8 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-subdirs = [ "composer", ]
-
 native_src = [
     "application.cpp",
     "controller_mesh.cpp",
@@ -49,7 +47,6 @@
 shared_libs = [
     "android.frameworks.vr.composer@1.0",
     "android.hardware.graphics.composer@2.1",
-    "libvrhwc",
     "libbase",
     "libbinder",
     "libinput",
@@ -66,6 +63,7 @@
     "libhidlbase",
     "libhidltransport",
     "liblog",
+    "libvr_hwc-hal",
 ]
 
 cc_binary {
diff --git a/services/vr/vr_window_manager/composer/Android.bp b/services/vr/vr_window_manager/composer/Android.bp
deleted file mode 100644
index 1998749..0000000
--- a/services/vr/vr_window_manager/composer/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-cc_library_shared {
-  name: "libvrhwc",
-
-  srcs: [
-    "impl/vr_composer_view.cpp",
-    "impl/vr_hwc.cpp",
-    "impl/vr_composer_client.cpp",
-  ],
-
-  static_libs: [
-    "libhwcomposer-client",
-    "libdisplay",
-    "libbufferhubqueue",
-    "libbufferhub",
-    "libpdx_default_transport",
-  ],
-
-  shared_libs: [
-    "android.frameworks.vr.composer@1.0",
-    "android.hardware.graphics.composer@2.1",
-    "libbase",
-    "libcutils",
-    "libfmq",
-    "libhardware",
-    "libhidlbase",
-    "libhidltransport",
-    "liblog",
-    "libsync",
-    "libui",
-    "libutils",
-  ],
-
-  export_static_lib_headers: [
-    "libhwcomposer-client",
-  ],
-
-  export_shared_lib_headers: [
-    "android.frameworks.vr.composer@1.0",
-    "android.hardware.graphics.composer@2.1",
-  ],
-
-  export_include_dirs: ["."],
-
-  cflags: [
-    "-DLOG_TAG=\"vrhwc\"",
-  ],
-}
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp b/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp
deleted file mode 100644
index 299e8f1..0000000
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "vr_composer_view.h"
-
-namespace android {
-namespace dvr {
-
-VrComposerView::VrComposerView(
-    std::unique_ptr<VrComposerView::Callback> callback)
-    : composer_view_(nullptr), callback_(std::move(callback)) {}
-
-VrComposerView::~VrComposerView() {
-  composer_view_->UnregisterObserver(this);
-}
-
-void VrComposerView::Initialize(ComposerView* composer_view) {
-  composer_view_ = composer_view;
-  composer_view_->RegisterObserver(this);
-}
-
-base::unique_fd VrComposerView::OnNewFrame(const ComposerView::Frame& frame) {
-  std::lock_guard<std::mutex> guard(mutex_);
-  if (!callback_.get())
-    return base::unique_fd();
-
-  return callback_->OnNewFrame(frame);
-}
-
-}  // namespace dvr
-}  // namespace android
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_view.h b/services/vr/vr_window_manager/composer/impl/vr_composer_view.h
deleted file mode 100644
index 8c5ee1f..0000000
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_view.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
-
-#include <memory>
-
-#include "vr_hwc.h"
-
-namespace android {
-namespace dvr {
-
-class VrComposerView : public ComposerView::Observer {
- public:
-  class Callback {
-   public:
-    virtual ~Callback() = default;
-    virtual base::unique_fd OnNewFrame(const ComposerView::Frame& frame) = 0;
-  };
-
-  VrComposerView(std::unique_ptr<Callback> callback);
-  ~VrComposerView() override;
-
-  void Initialize(ComposerView* composer_view);
-
-  // ComposerView::Observer
-  base::unique_fd OnNewFrame(const ComposerView::Frame& frame) override;
-
- private:
-  ComposerView* composer_view_;
-  std::unique_ptr<Callback> callback_;
-  std::mutex mutex_;
-};
-
-}  // namespace dvr
-}  // namespace android
-
-#endif  // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
diff --git a/services/vr/vr_window_manager/composer_view/Android.bp_disable b/services/vr/vr_window_manager/composer_view/Android.bp_disable
deleted file mode 100644
index 1658154..0000000
--- a/services/vr/vr_window_manager/composer_view/Android.bp_disable
+++ /dev/null
@@ -1,29 +0,0 @@
-cc_binary {
-  name: "vr_composer_view",
-
-  srcs: ["vr_composer_view.cpp"],
-
-  static_libs: [
-    "libhwcomposer-client",
-  ],
-
-  shared_libs: [
-    "android.dvr.composer@1.0",
-    "android.hardware.graphics.composer@2.1",
-    "libbase",
-    "libbinder",
-    "libhardware",
-    "libhwbinder",
-    "liblog",
-    "libutils",
-    "libvrhwc",
-  ],
-
-  cflags: [
-    "-DLOG_TAG=\"vr_composer_view\"",
-  ],
-
-  init_rc: [
-    "vr_composer_view.rc",
-  ],
-}
diff --git a/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp b/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp
deleted file mode 100644
index 54dff3d..0000000
--- a/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <binder/ProcessState.h>
-#include <hwbinder/IPCThreadState.h>
-#include <impl/vr_composer_view.h>
-#include <impl/vr_hwc.h>
-
-using namespace android;
-using namespace android::dvr;
-
-int main(int, char**) {
-  android::ProcessState::self()->startThreadPool();
-
-  const char instance[] = "vr_hwcomposer";
-  sp<IComposer> service = HIDL_FETCH_IComposer(instance);
-  LOG_ALWAYS_FATAL_IF(!service.get(), "Failed to get service");
-  LOG_ALWAYS_FATAL_IF(service->isRemote(), "Service is remote");
-
-  LOG_ALWAYS_FATAL_IF(service->registerAsService(instance) != ::android::OK,
-                      "Failed to register service");
-
-  sp<IVrComposerView> composer_view = HIDL_FETCH_IVrComposerView(
-      "DaydreamDisplay");
-  LOG_ALWAYS_FATAL_IF(!composer_view.get(),
-                      "Failed to get vr_composer_view service");
-  LOG_ALWAYS_FATAL_IF(composer_view->isRemote(),
-                      "vr_composer_view service is remote");
-
-  composer_view->registerAsService("DaydreamDisplay");
-
-  GetVrComposerViewFromIVrComposerView(composer_view.get())->Initialize(
-      GetComposerViewFromIComposer(service.get()));
-
-  android::hardware::ProcessState::self()->startThreadPool();
-  android::hardware::IPCThreadState::self()->joinThreadPool();
-
-  return 0;
-}
diff --git a/services/vr/vr_window_manager/composer_view/vr_composer_view.rc b/services/vr/vr_window_manager/composer_view/vr_composer_view.rc
deleted file mode 100644
index bd9982b..0000000
--- a/services/vr/vr_window_manager/composer_view/vr_composer_view.rc
+++ /dev/null
@@ -1,5 +0,0 @@
-service vr_composer_view /system/bin/vr_composer_view
-  class core
-  user system
-  group system graphics
-  writepid /dev/cpuset/system/tasks
diff --git a/services/vr/vr_window_manager/hwc_callback.h b/services/vr/vr_window_manager/hwc_callback.h
index 4269430..259c4ac 100644
--- a/services/vr/vr_window_manager/hwc_callback.h
+++ b/services/vr/vr_window_manager/hwc_callback.h
@@ -3,15 +3,13 @@
 
 #include <android/dvr/BnVrComposerCallback.h>
 #include <android-base/unique_fd.h>
+#include <impl/vr_hwc.h>
 
 #include <deque>
 #include <functional>
 #include <mutex>
 #include <vector>
 
-#include "impl/vr_composer_view.h"
-#include "impl/vr_hwc.h"
-
 namespace android {
 
 class Fence;
diff --git a/services/vr/vr_window_manager/surface_flinger_view.cpp b/services/vr/vr_window_manager/surface_flinger_view.cpp
index aef23a1..b41de03 100644
--- a/services/vr/vr_window_manager/surface_flinger_view.cpp
+++ b/services/vr/vr_window_manager/surface_flinger_view.cpp
@@ -2,7 +2,6 @@
 
 #include <android/dvr/IVrComposer.h>
 #include <binder/IServiceManager.h>
-#include <impl/vr_composer_view.h>
 #include <private/dvr/native_buffer.h>
 
 #include "hwc_callback.h"
diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp
index 9d7afe3..dd2cba7 100644
--- a/services/vr/vr_window_manager/vr_window_manager.cpp
+++ b/services/vr/vr_window_manager/vr_window_manager.cpp
@@ -2,7 +2,6 @@
 #include <binder/IServiceManager.h>
 #include <binder/ProcessState.h>
 #include <hwbinder/IPCThreadState.h>
-#include <impl/vr_composer_view.h>
 #include <impl/vr_hwc.h>
 
 #include "shell_view.h"