KeyguardStateMonitor looses connection with keystore if keystore dies
When keystore dies it no longer gets information about the lock screen
visibility state. This state is vital to enforcing the "unlocked
device required" authorization of keymaster keys.
With this patch KeyguardStateMonitor tries to reestablish the connection
to keystore if communication fails.
Test: run atest android.keystore.cts.CipherTest#testKeyguardLockAndUnlock
after killing keystore
Bug: 117552147
Change-Id: I8346e53c342bdba0f5960b1feba7c26db5cef33e
This commit is contained in:
@@ -95,10 +95,22 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
|
||||
mIsShowing = showing;
|
||||
|
||||
mCallback.onShowingChanged();
|
||||
try {
|
||||
mKeystoreService.onKeyguardVisibilityChanged(showing, mCurrentUserId);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Error informing keystore of screen lock", e);
|
||||
int retry = 2;
|
||||
while (retry > 0) {
|
||||
try {
|
||||
mKeystoreService.onKeyguardVisibilityChanged(showing, mCurrentUserId);
|
||||
break;
|
||||
} catch (RemoteException e) {
|
||||
if (retry == 2) {
|
||||
Slog.w(TAG, "Error informing keystore of screen lock. Keystore may have died"
|
||||
+ " -> refreshing service token and retrying");
|
||||
mKeystoreService = IKeystoreService.Stub.asInterface(ServiceManager
|
||||
.getService("android.security.keystore"));
|
||||
} else {
|
||||
Slog.e(TAG, "Error informing keystore of screen lock after retrying once", e);
|
||||
}
|
||||
--retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user