Skip to content
Snippets Groups Projects
Commit 40a8d1f7 authored by Shaquille Johnson's avatar Shaquille Johnson
Browse files

Update exception thrown for keystore

When the keystore service is not available or
not initialized we do not want to crash the service.
So we throw and Exception that KeystoreService
is not availble when it should be possibly in an
incorrect state.

Test: atest CtsKeystoreTestCases
Bug: 304758094
Change-Id: If73856deb27b9f11a9b77f0ba32c3b4037332759
parent ad73c57d
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@ import android.system.keystore2.ResponseCode;
import android.util.Log;
import java.util.Calendar;
import java.util.Objects;
/**
* @hide This should not be made public in its present form because it
......@@ -139,13 +138,25 @@ public class KeyStore2 {
return new KeyStore2();
}
/**
* Gets the {@link IKeystoreService} that should be started in early_hal in Android.
*
* @throws IllegalStateException if the KeystoreService is not available or has not
* been initialized when called. This is a state that should not happen and indicates
* and error somewhere in the stack or with the calling processes access permissions.
*/
@NonNull private synchronized IKeystoreService getService(boolean retryLookup) {
if (mBinder == null || retryLookup) {
mBinder = IKeystoreService.Stub.asInterface(ServiceManager
.getService(KEYSTORE2_SERVICE_NAME));
Binder.allowBlocking(mBinder.asBinder());
.getService(KEYSTORE2_SERVICE_NAME));
}
if (mBinder == null) {
throw new IllegalStateException(
"Could not connect to Keystore service. Keystore may have crashed or not been"
+ " initialized");
}
return Objects.requireNonNull(mBinder);
Binder.allowBlocking(mBinder.asBinder());
return mBinder;
}
void delete(KeyDescriptor descriptor) throws KeyStoreException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment