Update dumpstate HAL to V1.1

This is a manual porting from ag/10344396.
Replace the usage of "persist.vendor.verbose_logging_enabled" since we are not using
this property for Whitechapel.
Use the default property "persist.dumpstate.verbose_logging.enabled" instead.

Test: atest VtsHalDumpstateV1_1TargetTest pass
Bug: 186539439
Change-Id: I3f0d35647c0748d360b12d3be078d514f99d23d5
This commit is contained in:
Alex Hong 2021-05-03 23:07:00 +08:00
parent c1c9613145
commit ad5196c2c2
8 changed files with 64 additions and 21 deletions

View file

@ -59,7 +59,7 @@ using android::os::dumpstate::RunCommandToFd;
namespace android {
namespace hardware {
namespace dumpstate {
namespace V1_0 {
namespace V1_1 {
namespace implementation {
#define GPS_LOG_PREFIX "gl-"
@ -71,6 +71,8 @@ namespace implementation {
typedef std::chrono::time_point<std::chrono::steady_clock> timepoint_t;
const char kVerboseLoggingProperty[] = "persist.dumpstate.verbose_logging.enabled";
void DumpstateDevice::dumpLogs(int fd, std::string srcDir, std::string destDir, int maxFileNum,
const char *logPrefix) {
struct dirent **dirent_list = NULL;
@ -923,15 +925,36 @@ void DumpstateDevice::dumpModem(int fd, int fdModem)
// 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,
const DumpstateMode mode,
const uint64_t timeoutMillis) {
// Unused arguments.
(void) timeoutMillis;
if (handle == nullptr || handle->numFds < 1) {
ALOGE("no FDs\n");
return Void();
return DumpstateStatus::ILLEGAL_ARGUMENT;
}
int fd = handle->data[0];
if (fd < 0) {
ALOGE("invalid FD: %d\n", handle->data[0]);
return Void();
return DumpstateStatus::ILLEGAL_ARGUMENT;
}
if (mode == DumpstateMode::WEAR) {
// We aren't a Wear device.
ALOGE("Unsupported mode: %d\n", mode);
return DumpstateStatus::UNSUPPORTED_MODE;
} else if (mode < DumpstateMode::FULL || mode > DumpstateMode::PROTO) {
ALOGE("Invalid mode: %d\n", mode);
return DumpstateStatus::ILLEGAL_ARGUMENT;
}
dumpTextSection(fd, kAllSections);
@ -963,9 +986,18 @@ Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle &handle) {
"/vendor/firmware/logstrs.bin"});
}
return DumpstateStatus::OK;
}
Return<void> DumpstateDevice::setVerboseLoggingEnabled(const bool enable) {
::android::base::SetProperty(kVerboseLoggingProperty, enable ? "true" : "false");
return Void();
}
Return<bool> DumpstateDevice::getVerboseLoggingEnabled() {
return ::android::base::GetBoolProperty(kVerboseLoggingProperty, false);
}
// Since HALs that support the debug() interface are automatically invoked during
// bugreport generation and we don't want to generate a second copy of the same
// data that will go into dumpstate_board.txt, this function will only do
@ -993,7 +1025,7 @@ Return<void> DumpstateDevice::debug(const hidl_handle &handle, const hidl_vec<hi
} // namespace implementation
} // namespace V1_0
} // namespace V1_1
} // namespace dumpstate
} // namespace hardware
} // namespace android