Remove cuttlefish dumpstate HAL

We can switch to the default implementation instead.

Bug: 152067221
Test: TreeHugger
Change-Id: I3465c6dea8d53dedbd13ed45de1fb954f102a19d
diff --git a/CleanSpec.mk b/CleanSpec.mk
index c25688c..34f1634 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -59,3 +59,6 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.keymaster@4.0-service.rc)
 
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.power@1.0-service.rc)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.dumpstate@1.1-service.cuttlefish)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.dumpstate@1.1-service.cuttlefish.rc)
diff --git a/guest/monitoring/dumpstate_ext/Android.bp b/guest/monitoring/dumpstate_ext/Android.bp
deleted file mode 100644
index e679dc4..0000000
--- a/guest/monitoring/dumpstate_ext/Android.bp
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Copyright (C) 2019 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.
-
-cc_binary {
-    name: "android.hardware.dumpstate@1.1-service.cuttlefish",
-    srcs: [
-        "dumpstate_device.cpp",
-        "service.cpp",
-    ],
-    shared_libs: [
-        "android.hardware.dumpstate@1.0",
-        "android.hardware.dumpstate@1.1",
-        "libbase",
-        "libcutils",
-        "libdumpstateutil",
-        "libhidlbase",
-        "liblog",
-        "libutils",
-    ],
-    cflags: [
-        "-DLOG_TAG=\"VSoC-dumpstate\"",
-    ],
-    relative_install_path: "hw",
-    init_rc: [
-        "android.hardware.dumpstate@1.1-service.cuttlefish.rc",
-    ],
-    defaults: ["cuttlefish_guest_only"]
-}
diff --git a/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.1-service.cuttlefish.rc b/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.1-service.cuttlefish.rc
deleted file mode 100644
index 3fb31e3..0000000
--- a/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.1-service.cuttlefish.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service dumpstate-1-1 /vendor/bin/hw/android.hardware.dumpstate@1.1-service.cuttlefish
-    class hal
-    user system
-    group system
diff --git a/guest/monitoring/dumpstate_ext/dumpstate_device.cpp b/guest/monitoring/dumpstate_ext/dumpstate_device.cpp
deleted file mode 100644
index f1d7a43..0000000
--- a/guest/monitoring/dumpstate_ext/dumpstate_device.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- * 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 "guest/monitoring/dumpstate_ext/dumpstate_device.h"
-
-#include <DumpstateUtil.h>
-#include <android-base/properties.h>
-#include <log/log.h>
-
-#define VERBOSE_LOGGING_PROPERTY "persist.vendor.verbose_logging_enabled"
-
-using android::os::dumpstate::DumpFileToFd;
-
-namespace android {
-namespace hardware {
-namespace dumpstate {
-namespace V1_1 {
-namespace implementation {
-
-// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
-Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
-  // Ignore return value, just return an empty status.
-  dumpstateBoard_1_1(handle, DumpstateMode::DEFAULT, 30 * 1000 /* timeoutMillis */);
-  return Void();
-}
-
-// Methods from ::android::hardware::dumpstate::V1_1::IDumpstateDevice follow.
-Return<DumpstateStatus> DumpstateDevice::dumpstateBoard_1_1(const hidl_handle& handle,
-                                                            DumpstateMode mode,
-                                                            uint64_t /* timeoutMillis */) {
-  if (handle == nullptr || handle->numFds < 1) {
-    ALOGE("No FDs\n");
-    return DumpstateStatus::ILLEGAL_ARGUMENT;
-  }
-
-  int fd = handle->data[0];
-  if (fd < 0) {
-    ALOGE("Invalid FD: %d\n", fd);
-    return DumpstateStatus::ILLEGAL_ARGUMENT;
-  }
-
-  bool isModeValid = false;
-  for (const auto dumpstateMode : hidl_enum_range<DumpstateMode>()) {
-    isModeValid |= (dumpstateMode == mode);
-  }
-  if (!isModeValid) {
-    ALOGE("Invalid mode: %d\n", mode);
-    return DumpstateStatus::ILLEGAL_ARGUMENT;
-  }
-
-  if (mode == DumpstateMode::WEAR) {
-    // We aren't a Wear device. Mostly just for variety in our return values for testing purposes.
-    ALOGE("Unsupported mode: %d\n", mode);
-    return DumpstateStatus::UNSUPPORTED_MODE;
-  }
-
-  if (mode == DumpstateMode::PROTO) {
-    // We don't support dumping a protobuf yet.
-    ALOGE("Unsupported mode: %d\n", mode);
-    return DumpstateStatus::UNSUPPORTED_MODE;
-  }
-
-  DumpFileToFd(fd, "GCE INITIAL METADATA", "/initial.metadata");
-
-  // Do not include any of the user's private information before checking if verbose logging is
-  // enabled.
-  return DumpstateStatus::OK;
-}
-
-Return<void> DumpstateDevice::setVerboseLoggingEnabled(bool enable) {
-  ::android::base::SetProperty(VERBOSE_LOGGING_PROPERTY, enable ? "true" : "false");
-  return Void();
-}
-
-Return<bool> DumpstateDevice::getVerboseLoggingEnabled() {
-  return ::android::base::GetBoolProperty(VERBOSE_LOGGING_PROPERTY, false);
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace dumpstate
-}  // namespace hardware
-}  // namespace android
diff --git a/guest/monitoring/dumpstate_ext/dumpstate_device.h b/guest/monitoring/dumpstate_ext/dumpstate_device.h
deleted file mode 100644
index e7c5fea..0000000
--- a/guest/monitoring/dumpstate_ext/dumpstate_device.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.
- * 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.
- */
-#pragma once
-
-#include <android/hardware/dumpstate/1.1/IDumpstateDevice.h>
-#include <android/hardware/dumpstate/1.1/types.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace dumpstate {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::sp;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_handle;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::dumpstate::V1_1::DumpstateMode;
-using ::android::hardware::dumpstate::V1_1::DumpstateStatus;
-using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
-
-struct DumpstateDevice : public IDumpstateDevice {
-  // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
-  Return<void> dumpstateBoard(const hidl_handle& h) override;
-
-  // Methods from ::android::hardware::dumpstate::V1_1::IDumpstateDevice follow.
-  Return<DumpstateStatus> dumpstateBoard_1_1(const hidl_handle& h,
-                                             DumpstateMode mode,
-                                             uint64_t timeoutMillis) override;
-  Return<void> setVerboseLoggingEnabled(bool enable) override;
-  Return<bool> getVerboseLoggingEnabled() override;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace dumpstate
-}  // namespace hardware
-}  // namespace android
diff --git a/guest/monitoring/dumpstate_ext/service.cpp b/guest/monitoring/dumpstate_ext/service.cpp
deleted file mode 100644
index d8f339c..0000000
--- a/guest/monitoring/dumpstate_ext/service.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- * 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 <hidl/HidlSupport.h>
-#include <hidl/HidlTransportSupport.h>
-
-#include "guest/monitoring/dumpstate_ext/dumpstate_device.h"
-
-using ::android::OK;
-using ::android::hardware::configureRpcThreadpool;
-using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
-using ::android::hardware::dumpstate::V1_1::implementation::DumpstateDevice;
-using ::android::hardware::joinRpcThreadpool;
-using ::android::sp;
-
-int main() {
-  sp<IDumpstateDevice> dumpstate = new DumpstateDevice;
-  // This method MUST be called before interacting with any HIDL interfaces.
-  configureRpcThreadpool(1, true);
-  if (dumpstate->registerAsService() != OK) {
-    ALOGE("Could not register service.");
-    return 1;
-  }
-  joinRpcThreadpool();
-}
diff --git a/shared/config/manifest.xml b/shared/config/manifest.xml
index fd4d1af..1dfdb98 100644
--- a/shared/config/manifest.xml
+++ b/shared/config/manifest.xml
@@ -107,15 +107,6 @@
         </interface>
     </hal>
     -->
-    <hal format="hidl">
-        <name>android.hardware.dumpstate</name>
-        <transport>hwbinder</transport>
-        <version>1.1</version>
-        <interface>
-            <name>IDumpstateDevice</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
     <!-- TODO (b/130074193): -->
     <hal format="hidl">
         <name>android.hardware.graphics.allocator</name>
diff --git a/shared/device.mk b/shared/device.mk
index cc867b3..c8d4316 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -279,7 +279,7 @@
 # Dumpstate HAL
 #
 PRODUCT_PACKAGES += \
-    android.hardware.dumpstate@1.1-service.cuttlefish
+    android.hardware.dumpstate@1.1-service.example
 
 #
 # Camera
diff --git a/shared/sepolicy/vendor/file_contexts b/shared/sepolicy/vendor/file_contexts
index e04ebbf..888a7f6 100644
--- a/shared/sepolicy/vendor/file_contexts
+++ b/shared/sepolicy/vendor/file_contexts
@@ -62,7 +62,6 @@
 /vendor/bin/hw/android\.hardware\.drm@[0-9]+\.[0-9]+-service-lazy\.clearkey  u:object_r:hal_drm_clearkey_exec:s0
 /vendor/bin/hw/android\.hardware\.drm@[0-9]+\.[0-9]+-service\.widevine  u:object_r:hal_drm_widevine_exec:s0
 /vendor/bin/hw/android\.hardware\.drm@[0-9]+\.[0-9]+-service-lazy\.widevine  u:object_r:hal_drm_widevine_exec:s0
-/vendor/bin/hw/android\.hardware\.dumpstate@1\.1-service\.cuttlefish  u:object_r:hal_dumpstate_impl_exec:s0
 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software  u:object_r:hal_gatekeeper_default_exec:s0
 /vendor/bin/hw/android\.hardware\.health\.storage@1\.0-service\.cuttlefish u:object_r:hal_health_storage_default_exec:s0
 /vendor/bin/hw/android\.hardware\.lights-service\.example u:object_r:hal_light_default_exec:s0
diff --git a/shared/sepolicy/vendor/hal_dumpstate_impl.te b/shared/sepolicy/vendor/hal_dumpstate_impl.te
deleted file mode 100644
index 84c0339..0000000
--- a/shared/sepolicy/vendor/hal_dumpstate_impl.te
+++ /dev/null
@@ -1,9 +0,0 @@
-type hal_dumpstate_impl, domain;
-type hal_dumpstate_impl_exec, exec_type, vendor_file_type, file_type;
-type hal_dumpstate_prop, property_type;
-
-hal_server_domain(hal_dumpstate_impl, hal_dumpstate)
-
-init_daemon_domain(hal_dumpstate_impl)
-
-set_prop(hal_dumpstate_impl, hal_dumpstate_prop)
diff --git a/shared/sepolicy/vendor/property_contexts b/shared/sepolicy/vendor/property_contexts
index d137d65..12abbe1 100644
--- a/shared/sepolicy/vendor/property_contexts
+++ b/shared/sepolicy/vendor/property_contexts
@@ -1,6 +1,5 @@
 bt.rootcanal_mac_address  u:object_r:hal_bluetooth_sim_prop:s0
 bt.rootcanal_test_console  u:object_r:hal_bluetooth_sim_prop:s0
-persist.vendor.verbose_logging_enabled  u:object_r:hal_dumpstate_prop:s0
 qemu.sf.back_camera_caps  u:object_r:hal_camera_prop:s0
 qemu.sf.front_camera_caps  u:object_r:hal_camera_prop:s0
 qemu.sf.fake_camera  u:object_r:hal_camera_prop:s0