Ensure that LockSettingsService waits for gatekeeperd to be ready

gatekeeperd is started asynchronously.  Thus, there is no hard guarantee
that it will be ready when LockSettingsService first tries to use it.
Therefore, use waitForService() to wait for it to be ready.  To avoid
introducing any unnecessary delay, stop calling getGateKeeperService()
from LockSettingsService#systemReady(), where GK isn't yet needed.

This is motivated by a bug that caused gatekeeperd to wait 5 seconds
during start-up, fixed by https://r.android.com/2623413.  Apparently,
that was enough of a delay to sometimes cause gatekeeperd to not be
ready by LockSettingsService#loadEscrowData().

Bug: 283055837
Test: Boot and 'atest com.android.server.locksettings'
Change-Id: I815151cc6024c447bf3eff194a911ecdaab22d10
This commit is contained in:
Eric Biggers
2023-07-07 20:10:07 +00:00
parent c96354dd42
commit cdd03b770a
2 changed files with 2 additions and 3 deletions

View File

@@ -311,7 +311,7 @@ public class BiometricDeferredQueue {
@Nullable
private static synchronized IGateKeeperService getGatekeeperService() {
final IBinder service = ServiceManager.getService(Context.GATEKEEPER_SERVICE);
final IBinder service = ServiceManager.waitForService(Context.GATEKEEPER_SERVICE);
if (service == null) {
Slog.e(TAG, "Unable to acquire GateKeeperService");
return null;

View File

@@ -843,7 +843,6 @@ public class LockSettingsService extends ILockSettings.Stub {
mHasSecureLockScreen = mContext.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_SECURE_LOCK_SCREEN);
migrateOldData();
getGateKeeperService();
getAuthSecretHal();
mDeviceProvisionedObserver.onSystemReady();
@@ -2599,7 +2598,7 @@ public class LockSettingsService extends ILockSettings.Stub {
return mGateKeeperService;
}
final IBinder service = ServiceManager.getService(Context.GATEKEEPER_SERVICE);
final IBinder service = ServiceManager.waitForService(Context.GATEKEEPER_SERVICE);
if (service != null) {
try {
service.linkToDeath(new GateKeeperDiedRecipient(), 0);