Fastboot: Use AServiceManager_waitForService instead of AServiceManager_getService
AServiceManager_getService waits unncessarily waits for 5 seconds if service is not available. Use isDeclared() and waitForService() instead. Bug: 261759425 Test: build and flash Change-Id: I20a5f422ca0c26c6e9e183e6636b30a2f19e76d3 Signed-off-by: Sandeep Dhavale <dhavale@google.com>
This commit is contained in:
parent
aeee1c6231
commit
63928c310e
1 changed files with 8 additions and 5 deletions
|
@ -70,11 +70,14 @@ std::shared_ptr<aidl::android::hardware::fastboot::IFastboot> get_fastboot_servi
|
|||
using HidlFastboot = android::hardware::fastboot::V1_1::IFastboot;
|
||||
using aidl::android::hardware::fastboot::FastbootShim;
|
||||
auto service_name = IFastboot::descriptor + "/default"s;
|
||||
ndk::SpAIBinder binder(AServiceManager_getService(service_name.c_str()));
|
||||
std::shared_ptr<IFastboot> fastboot = IFastboot::fromBinder(binder);
|
||||
if (fastboot != nullptr) {
|
||||
LOG(INFO) << "Using AIDL fastboot service";
|
||||
return fastboot;
|
||||
if (AServiceManager_isDeclared(service_name.c_str())) {
|
||||
ndk::SpAIBinder binder(AServiceManager_waitForService(service_name.c_str()));
|
||||
std::shared_ptr<IFastboot> fastboot = IFastboot::fromBinder(binder);
|
||||
if (fastboot != nullptr) {
|
||||
LOG(INFO) << "Found and using AIDL fastboot service";
|
||||
return fastboot;
|
||||
}
|
||||
LOG(WARNING) << "AIDL fastboot service is declared, but it cannot be retrieved.";
|
||||
}
|
||||
LOG(INFO) << "Unable to get AIDL fastboot service, trying HIDL...";
|
||||
android::sp<HidlFastboot> hidl_fastboot = HidlFastboot::getService();
|
||||
|
|
Loading…
Reference in a new issue