idlcli: Support AIDL Vibrator
Test: Manual Invocation
Change-Id: Ic9c1152e26e4185cb81f6a96bb7afa6377b854ef
Signed-off-by: Harpreet \"Eli\" Sangha <eliptus@google.com>
diff --git a/cmds/idlcli/vibrator/CommandSetExternalControl.cpp b/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
index 5fb1fac..5bc827e 100644
--- a/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
+++ b/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
@@ -48,15 +48,24 @@
}
Status doMain(Args && /*args*/) override {
- auto ret = halCall(&V1_3::IVibrator::setExternalControl, mEnable);
+ std::string statusStr;
+ Status ret;
- if (!ret.isOk()) {
+ if (auto hal = getHal<aidl::IVibrator>()) {
+ auto status = hal->call(&aidl::IVibrator::setExternalControl, mEnable);
+ statusStr = status.toString8();
+ ret = status.isOk() ? OK : ERROR;
+ } else if (auto hal = getHal<V1_3::IVibrator>()) {
+ auto status = hal->call(&V1_3::IVibrator::setExternalControl, mEnable);
+ statusStr = toString(status);
+ ret = status.isOk() && status == V1_0::Status::OK ? OK : ERROR;
+ } else {
return UNAVAILABLE;
}
- std::cout << "Status: " << toString(ret) << std::endl;
+ std::cout << "Status: " << statusStr << std::endl;
- return ret == V1_0::Status::OK ? OK : ERROR;
+ return ret;
}
bool mEnable;