Skip to content

Commit

Permalink
Check AServiceManager_isDeclared before AServiceManager_getService
Browse files Browse the repository at this point in the history
Call AServiceManager_isDeclared before calling AServiceManager_getService
to avoid the waiting time when aidl service is not available.

Bug: 286969060
Test: run VtsHalGatekeeperTarget
(cherry picked from https://android-review.googlesource.com/q/commit:32e1c70f275991ec7fe4d4a2d6e3eeba2a172540)
Merged-In: I7d652a546cb810a601338a68950f01d065aea7a5
Change-Id: I7d652a546cb810a601338a68950f01d065aea7a5
  • Loading branch information
subrahmanyaman committed Jun 21, 2023
1 parent 45ff1af commit 73b983a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gatekeeperd/gatekeeperd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ class GateKeeperProxy : public BnGateKeeperService {
public:
GateKeeperProxy() {
clear_state_if_needed_done = false;
hw_device = IGatekeeper::getService();
::ndk::SpAIBinder ks2Binder(AServiceManager_getService(gatekeeperServiceName));
aidl_hw_device = AidlIGatekeeper::fromBinder(ks2Binder);
if (AServiceManager_isDeclared(gatekeeperServiceName)) {
::ndk::SpAIBinder ks2Binder(AServiceManager_waitForService(gatekeeperServiceName));
aidl_hw_device = AidlIGatekeeper::fromBinder(ks2Binder);
}
if (!aidl_hw_device) {
hw_device = IGatekeeper::getService();
}
is_running_gsi = android::base::GetBoolProperty(android::gsi::kGsiBootedProp, false);

if (!aidl_hw_device && !hw_device) {
Expand Down

0 comments on commit 73b983a

Please sign in to comment.