Upgrade cuttlefish IDumpstateDevice to 1.1.

This is just an in-place upgrade without modifying existing behavior.

Bug: 143183758
Bug: 143184495
Test: make aosp_cf_x86_phone-userdebug && atest VtsHalDumpstateV1_1TargetTest
Change-Id: I815bc75b2a28b81ee961dbdb70f8fcd38ef30913
Merged-In: I815bc75b2a28b81ee961dbdb70f8fcd38ef30913
(cherry picked from commit 1abd4e907fadd17bcd57b7d37e83ae0285e29808)
diff --git a/guest/monitoring/dumpstate_ext/Android.bp b/guest/monitoring/dumpstate_ext/Android.bp
index ba3320c..e679dc4 100644
--- a/guest/monitoring/dumpstate_ext/Android.bp
+++ b/guest/monitoring/dumpstate_ext/Android.bp
@@ -14,13 +14,14 @@
 // limitations under the License.
 
 cc_binary {
-    name: "android.hardware.dumpstate@1.0-service.cuttlefish",
+    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",
@@ -33,7 +34,7 @@
     ],
     relative_install_path: "hw",
     init_rc: [
-        "android.hardware.dumpstate@1.0-service.cuttlefish.rc",
+        "android.hardware.dumpstate@1.1-service.cuttlefish.rc",
     ],
     defaults: ["cuttlefish_guest_only"]
 }
diff --git a/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.0-service.cuttlefish.rc b/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.0-service.cuttlefish.rc
deleted file mode 100644
index ad68f35..0000000
--- a/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.0-service.cuttlefish.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service dumpstate-1-0 /vendor/bin/hw/android.hardware.dumpstate@1.0-service.cuttlefish
-    class hal
-    user system
-    group system
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
new file mode 100644
index 0000000..3fb31e3
--- /dev/null
+++ b/guest/monitoring/dumpstate_ext/android.hardware.dumpstate@1.1-service.cuttlefish.rc
@@ -0,0 +1,4 @@
+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
index d8481c7..48bc9d2 100644
--- a/guest/monitoring/dumpstate_ext/dumpstate_device.cpp
+++ b/guest/monitoring/dumpstate_ext/dumpstate_device.cpp
@@ -15,19 +15,26 @@
  */
 #include "guest/monitoring/dumpstate_ext/dumpstate_device.h"
 
-#include <log/log.h>
 #include <DumpstateUtil.h>
+#include <log/log.h>
 
 using android::os::dumpstate::DumpFileToFd;
 
 namespace android {
 namespace hardware {
 namespace dumpstate {
-namespace V1_0 {
+namespace V1_1 {
 namespace implementation {
 
 // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
 Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
+  return dumpstateBoard_1_1(handle, DumpstateMode::DEFAULT, 30 * 1000 /* timeoutMillis */);
+}
+
+// Methods from ::android::hardware::dumpstate::V1_1::IDumpstateDevice follow.
+Return<void> DumpstateDevice::dumpstateBoard_1_1(const hidl_handle& handle,
+                                                 DumpstateMode mode,
+                                                 uint64_t /* timeoutMillis */) {
   if (handle == nullptr || handle->numFds < 1) {
     ALOGE("no FDs\n");
     return Void();
@@ -39,13 +46,23 @@
     return Void();
   }
 
+  if (mode < DumpstateMode::FULL || mode > DumpstateMode::DEFAULT) {
+    ALOGE("Invalid mode: %d\n", mode);
+    return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
+  }
+
   DumpFileToFd(fd, "GCE INITIAL METADATA", "/initial.metadata");
 
   return Void();
 }
 
+Return<bool> DumpstateDevice::setDeviceLoggingEnabled(bool /* enable */) {
+  // Unsupported operation.
+  return false;
+}
+
 }  // namespace implementation
-}  // namespace V1_0
+}  // 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
index 581a96b..2f6990d 100644
--- a/guest/monitoring/dumpstate_ext/dumpstate_device.h
+++ b/guest/monitoring/dumpstate_ext/dumpstate_device.h
@@ -15,19 +15,21 @@
  */
 #pragma once
 
-#include <android/hardware/dumpstate/1.0/IDumpstateDevice.h>
+#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_0 {
+namespace V1_1 {
 namespace implementation {
 
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
+using ::android::hardware::dumpstate::V1_1::DumpstateMode;
+using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
 using ::android::hardware::hidl_array;
 using ::android::hardware::hidl_handle;
 using ::android::hardware::hidl_string;
@@ -37,10 +39,15 @@
 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<void> dumpstateBoard_1_1(const hidl_handle& h, DumpstateMode mode,
+                                  uint64_t timeoutMillis) override;
+  Return<bool> setDeviceLoggingEnabled(bool enable) override;
 };
 
 }  // namespace implementation
-}  // namespace V1_0
+}  // 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
index 67eebe5..d8f339c 100644
--- a/guest/monitoring/dumpstate_ext/service.cpp
+++ b/guest/monitoring/dumpstate_ext/service.cpp
@@ -20,8 +20,8 @@
 
 using ::android::OK;
 using ::android::hardware::configureRpcThreadpool;
-using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
-using ::android::hardware::dumpstate::V1_0::implementation::DumpstateDevice;
+using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
+using ::android::hardware::dumpstate::V1_1::implementation::DumpstateDevice;
 using ::android::hardware::joinRpcThreadpool;
 using ::android::sp;
 
diff --git a/shared/config/manifest.xml b/shared/config/manifest.xml
index cde4e44..d695a73 100644
--- a/shared/config/manifest.xml
+++ b/shared/config/manifest.xml
@@ -137,7 +137,7 @@
     <hal format="hidl">
         <name>android.hardware.dumpstate</name>
         <transport>hwbinder</transport>
-        <version>1.0</version>
+        <version>1.1</version>
         <interface>
             <name>IDumpstateDevice</name>
             <instance>default</instance>
diff --git a/shared/device.mk b/shared/device.mk
index 955232a..222d02b 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -227,7 +227,7 @@
 # Dumpstate HAL
 #
 PRODUCT_PACKAGES += \
-    android.hardware.dumpstate@1.0-service.cuttlefish
+    android.hardware.dumpstate@1.1-service.cuttlefish
 
 #
 # Camera
diff --git a/shared/sepolicy/vendor/file_contexts b/shared/sepolicy/vendor/file_contexts
index a5ed5b7..4abfa19 100644
--- a/shared/sepolicy/vendor/file_contexts
+++ b/shared/sepolicy/vendor/file_contexts
@@ -60,7 +60,7 @@
 /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\.0-service\.cuttlefish  u:object_r:hal_dumpstate_impl_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\.neuralnetworks@1\.3-service-sample-.*   u:object_r:hal_neuralnetworks_sample_exec:s0