Merge "Use waitForService in rkp_factory_extraction_tool" into main am: 996710c4e3 am: 26c2712a40

Original change: https://android-review.googlesource.com/c/platform/system/security/+/3079564

Change-Id: I8e7bbf280e9b0d158a7e91f6c062ef2d89c2e378
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2024-05-17 11:26:31 +00:00 committed by Automerger Merge Worker
commit 0efecbb9a4

View file

@ -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) {