diff options
| author | 2023-11-28 17:17:58 +0000 | |
|---|---|---|
| committer | 2023-11-28 17:17:58 +0000 | |
| commit | 0b37e75b10e781ecfe186c11a91eb5c67f3990a6 (patch) | |
| tree | 0a0452e00b918556c67b94ad0bf9727404d4de5b | |
| parent | 7d1d288a591f994395fec884b9c76dd907b13170 (diff) | |
| parent | 242534fe61e431ef68ea433c2c19b33bd77e73b3 (diff) | |
Merge "Update exception thrown for keystore" into main am: a7f6cb180d am: 242534fe61
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2827750
Change-Id: I30bf0253963c07e489c477e82ec8499517841168
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | keystore/java/android/security/KeyStore2.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/keystore/java/android/security/KeyStore2.java b/keystore/java/android/security/KeyStore2.java index 5e16bcee1a0e..dd703f5eefb9 100644 --- a/keystore/java/android/security/KeyStore2.java +++ b/keystore/java/android/security/KeyStore2.java @@ -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 { |