]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/platform-hardware-interfaces.git/commitdiff
health: expand debug info.
authorYifan Hong <elsk@google.com>
Wed, 4 Apr 2018 22:28:19 +0000 (15:28 -0700)
committerYifan Hong <elsk@google.com>
Wed, 4 Apr 2018 22:32:53 +0000 (22:32 +0000)
Test: lshal -m android.hardware.health@2.0::IHealth/default
Test: lshal -m android.hardware.health@2.0::IHealth/backup

Bug: 74057048
Change-Id: Iaca0a7fd32209522d7d759342b98d6e6898595ac

health/2.0/default/Health.cpp

index 7a3e6504089f24820a1c63d4529098a638987ee6..6d3be9923baa8559fe905d78dddb9f19843a1896 100644 (file)
@@ -16,6 +16,7 @@
 #define LOG_TAG "android.hardware.health@2.0-impl"
 #include <android-base/logging.h>
 
+#include <android-base/file.h>
 #include <health2/Health.h>
 
 #include <hal_conversion.h>
@@ -189,6 +190,17 @@ Return<void> Health::debug(const hidl_handle& handle, const hidl_vec<hidl_string
     if (handle != nullptr && handle->numFds >= 1) {
         int fd = handle->data[0];
         battery_monitor_->dumpState(fd);
+
+        getHealthInfo([fd](auto res, const auto& info) {
+            android::base::WriteStringToFd("\ngetHealthInfo -> ", fd);
+            if (res == Result::SUCCESS) {
+                android::base::WriteStringToFd(toString(info), fd);
+            } else {
+                android::base::WriteStringToFd(toString(res), fd);
+            }
+            android::base::WriteStringToFd("\n", fd);
+        });
+
         fsync(fd);
     }
     return Void();