diff options
author | Daniel Norman <danielnorman@google.com> | 2021-02-08 11:11:18 -0800 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2021-02-17 08:39:59 -0800 |
commit | 337095f9d277c566cb888bc3adbac16576f1ae70 (patch) | |
tree | 8818a5cd44fdfa89f7ef4d8570dbc67239e087dd /keystore/java/android/security/KeyStoreSecurityLevel.java | |
parent | 80b7ed3f7373212a33fe42af8a7b7fc0ebcb187c (diff) | |
parent | a66768631e6f47e1f7ffcf4ec86f96d6e8f35282 (diff) |
Merge SP1A.210208.001
Change-Id: I7d4929024872b369444e276a60ded06e37b1fefb
Diffstat (limited to 'keystore/java/android/security/KeyStoreSecurityLevel.java')
-rw-r--r-- | keystore/java/android/security/KeyStoreSecurityLevel.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/keystore/java/android/security/KeyStoreSecurityLevel.java b/keystore/java/android/security/KeyStoreSecurityLevel.java index 3ef4aa5b7ec3..372add9b7ecb 100644 --- a/keystore/java/android/security/KeyStoreSecurityLevel.java +++ b/keystore/java/android/security/KeyStoreSecurityLevel.java @@ -52,7 +52,7 @@ public class KeyStoreSecurityLevel { try { return request.execute(); } catch (ServiceSpecificException e) { - throw new KeyStoreException(e.errorCode, ""); + throw KeyStore2.getKeyStoreException(e.errorCode); } catch (RemoteException e) { // Log exception and report invalid operation handle. // This should prompt the caller drop the reference to this operation and retry. @@ -96,25 +96,26 @@ public class KeyStoreSecurityLevel { } catch (ServiceSpecificException e) { switch (e.errorCode) { case ResponseCode.BACKEND_BUSY: { + long backOffHint = (long) (Math.random() * 80 + 20); if (CompatChanges.isChangeEnabled( KeyStore2.KEYSTORE_OPERATION_CREATION_MAY_FAIL)) { // Starting with Android S we inform the caller about the // backend being busy. - throw new BackendBusyException(); + throw new BackendBusyException(backOffHint); } else { // Before Android S operation creation must always succeed. So we // just have to retry. We do so with a randomized back-off between - // 50 and 250ms. + // 20 and 100ms. // It is a little awkward that we cannot break out of this loop // by interrupting this thread. But that is the expected behavior. // There is some comfort in the fact that interrupting a thread // also does not unblock a thread waiting for a binder transaction. - interruptedPreservingSleep((long) (Math.random() * 200 + 50)); + interruptedPreservingSleep(backOffHint); } break; } default: - throw new KeyStoreException(e.errorCode, ""); + throw KeyStore2.getKeyStoreException(e.errorCode); } } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); |