Use waitForService in rkp_factory_extraction_tool
The original getService doesn't start the AVF HAL if it is not already running. waitForService is used here with a timeout of 10 seconds as it starts a service lazily. Bug: 339118043 Test: m rkp_factory_extraction_tool Change-Id: I942f4c5e1aae8b529895a51f19b525033609d0aa
This commit is contained in:
parent
134da755b0
commit
c1b568a0e9
1 changed files with 8 additions and 1 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <remote_prov/remote_prov_utils.h>
|
||||
#include <sys/random.h>
|
||||
|
||||
#include <future>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -91,7 +92,13 @@ void getCsrForIRpc(const char* descriptor, const char* name, IRemotelyProvisione
|
|||
// for every IRemotelyProvisionedComponent.
|
||||
void getCsrForInstance(const char* name, void* /*context*/) {
|
||||
auto fullName = getFullServiceName(IRemotelyProvisionedComponent::descriptor, name);
|
||||
AIBinder* rkpAiBinder = AServiceManager_getService(fullName.c_str());
|
||||
std::future<AIBinder*> wait_for_service_func =
|
||||
std::async(std::launch::async, AServiceManager_waitForService, fullName.c_str());
|
||||
if (wait_for_service_func.wait_for(std::chrono::seconds(10)) == std::future_status::timeout) {
|
||||
std::cerr << "Wait for service timed out after 10 seconds: " << fullName;
|
||||
exit(-1);
|
||||
}
|
||||
AIBinder* rkpAiBinder = wait_for_service_func.get();
|
||||
::ndk::SpAIBinder rkp_binder(rkpAiBinder);
|
||||
auto rkp_service = IRemotelyProvisionedComponent::fromBinder(rkp_binder);
|
||||
if (!rkp_service) {
|
||||
|
|
Loading…
Reference in a new issue