Bonito: fix DumpstateMode validation.
The PROTO mode was added after initial HAL upgrade and is causing VTS
failures due to the way the DumpstateMode param is being validated.
Bug: 150873571
Test: atest VtsHalDumpstateV1_1TargetTest, verify PROTO tests pass now
Change-Id: I13f2f24dab8e2828d6ddb4902efe6f979e89e89d
(cherry picked from commit 971ccd403813fb2faf5c21f7b6e0a9ffe39d6b2f)
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index 9895289..9f616df 100755
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -21,6 +21,7 @@
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
+#include <hidl/HidlSupport.h>
#include <log/log.h>
#include <pthread.h>
#include <string.h>
@@ -359,13 +360,20 @@
return DumpstateStatus::ILLEGAL_ARGUMENT;
}
- if (mode == DumpstateMode::WEAR) {
+ bool isModeValid = false;
+ for (const auto dumpstateMode : hidl_enum_range<DumpstateMode>()) {
+ if (mode == dumpstateMode) {
+ isModeValid = true;
+ break;
+ }
+ }
+ if (!isModeValid) {
+ ALOGE("Invalid mode: %d\n", mode);
+ return DumpstateStatus::ILLEGAL_ARGUMENT;
+ } else 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::DEFAULT) {
- ALOGE("Invalid mode: %d\n", mode);
- return DumpstateStatus::ILLEGAL_ARGUMENT;
}
RunCommandToFd(fd, "Notify modem", {"/vendor/bin/modem_svc", "-s"}, CommandOptions::WithTimeout(1).Build());