getService: re-request HALs after timeout am: 0771d8a8b8 am: 2fbe92d87e
am: 6178821eff
Change-Id: I3616bef0e53ca703afe3c54a06df6ffd65679913
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 01f83bd..31decc7 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -563,7 +563,7 @@
return Void();
}
- void wait() {
+ void wait(bool timeout) {
using std::literals::chrono_literals::operator""s;
if (!mRegisteredForNotifications) {
@@ -574,7 +574,7 @@
}
std::unique_lock<std::mutex> lock(mMutex);
- while(true) {
+ do {
mCondition.wait_for(lock, 1s, [this]{
return mRegistered;
});
@@ -583,9 +583,8 @@
break;
}
- LOG(WARNING) << "Waited one second for " << mInterfaceName << "/" << mInstanceName
- << ". Waiting another...";
- }
+ LOG(WARNING) << "Waited one second for " << mInterfaceName << "/" << mInstanceName;
+ } while (!timeout);
}
// Be careful when using this; after calling reset(), you must always try to retrieve
@@ -626,7 +625,7 @@
void waitForHwService(
const std::string &interface, const std::string &instanceName) {
sp<Waiter> waiter = new Waiter(interface, instanceName, defaultServiceManager1_1());
- waiter->wait();
+ waiter->wait(false /* timeout */);
waiter->done();
}
@@ -736,7 +735,7 @@
if (waiter != nullptr) {
ALOGI("getService: Trying again for %s/%s...", descriptor.c_str(), instance.c_str());
- waiter->wait();
+ waiter->wait(true /* timeout */);
}
}
diff --git a/transport/include/hidl/ServiceManagement.h b/transport/include/hidl/ServiceManagement.h
index 4df156b..968c385 100644
--- a/transport/include/hidl/ServiceManagement.h
+++ b/transport/include/hidl/ServiceManagement.h
@@ -43,6 +43,7 @@
const std::string &interfaceName,
const std::string &instanceName);
+// Will not attempt to start a lazy HAL
// e.x.: android.hardware.foo@1.0::IFoo, default
void waitForHwService(const std::string &interface, const std::string &instanceName);