Do not initialize the weaver service at boot

It can be initialized when needed. Some weaver HAL implementations
aren't ready that early, so we don't want to try and initialize it then.

Test: atest com.android.server.locksettings
Bug: 252760591
Change-Id: I6eba59cc64025de496bdf91f9aa5eff53a515143
This commit is contained in:
Devin Moore
2023-01-31 20:53:27 +00:00
parent 4f7673588f
commit 61bd5961f6
3 changed files with 9 additions and 16 deletions

View File

@@ -814,7 +814,6 @@ public class LockSettingsService extends ILockSettings.Stub {
.hasSystemFeature(PackageManager.FEATURE_SECURE_LOCK_SCREEN);
migrateOldData();
getGateKeeperService();
mSpManager.initWeaverService();
getAuthSecretHal();
mDeviceProvisionedObserver.onSystemReady();

View File

@@ -499,40 +499,35 @@ class SyntheticPasswordManager {
return null;
}
public synchronized void initWeaverService() {
private synchronized boolean isWeaverAvailable() {
if (mWeaver != null) {
return;
return true;
}
// Re-initialize weaver in case there was a transient error preventing access to it.
IWeaver weaver = getWeaverService();
if (weaver == null) {
return;
return false;
}
// Get the config
WeaverConfig weaverConfig = null;
final WeaverConfig weaverConfig;
try {
weaverConfig = weaver.getConfig();
} catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Failed to get weaver config", e);
return false;
}
if (weaverConfig == null || weaverConfig.slots <= 0) {
Slog.e(TAG, "Failed to initialize weaver config");
return;
Slog.e(TAG, "Invalid weaver config");
return false;
}
mWeaver = weaver;
mWeaverConfig = weaverConfig;
mPasswordSlotManager.refreshActiveSlots(getUsedWeaverSlots());
Slog.i(TAG, "Weaver service initialized");
}
private synchronized boolean isWeaverAvailable() {
if (mWeaver == null) {
//Re-initializing weaver in case there was a transient error preventing access to it.
initWeaverService();
}
return mWeaver != null && mWeaverConfig.slots > 0;
return true;
}
/**

View File

@@ -119,6 +119,5 @@ public class MockSyntheticPasswordManager extends SyntheticPasswordManager {
public void enableWeaver() {
mWeaverService = new MockWeaverService();
initWeaverService();
}
}