summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/KeyStore.java
diff options
context:
space:
mode:
authorIrina Dumitrescu <irinaid@google.com>2018-06-08 19:36:34 +0100
committerIrina Dumitrescu <irinaid@google.com>2018-06-12 14:32:29 +0100
commit4a1cccc93809920adeb0f25eaf69c9de7ec7c7d6 (patch)
tree68194f37c71b19edbaa5fdfe1c7c767084d14817 /keystore/java/android/security/KeyStore.java
parent70b447a378d0233dfc76cf208e5959c6070f1ed0 (diff)
Add Keystore get option that supresses caught exceptions warnings.
This is useful when the caught exceptions are not informative and they act as a red herring in the adb logs. Bug:109791294 Test: call this method in the VpnSettings and manually navigate to adding a new VPN by searching for VPN in settings and then pressing '+'. Change-Id: I4bc86e3ea5b11027090fd3a27dc7455557cf66ab
Diffstat (limited to 'keystore/java/android/security/KeyStore.java')
-rw-r--r--keystore/java/android/security/KeyStore.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index fe05c13c999b..850230943458 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -190,22 +190,33 @@ public class KeyStore {
}
public byte[] get(String key, int uid) {
+ return get(key, uid, false);
+ }
+
+ public byte[] get(String key) {
+ return get(key, UID_SELF);
+ }
+
+ public byte[] get(String key, int uid, boolean suppressKeyNotFoundWarning) {
try {
key = key != null ? key : "";
return mBinder.get(key, uid);
} catch (RemoteException e) {
- Log.w(TAG, "Cannot connect to keystore", e);
+ Log.w(TAG, "Cannot connect to keystore", e);
return null;
} catch (android.os.ServiceSpecificException e) {
- Log.w(TAG, "KeyStore exception", e);
+ if (!suppressKeyNotFoundWarning || e.errorCode != KEY_NOT_FOUND) {
+ Log.w(TAG, "KeyStore exception", e);
+ }
return null;
}
}
- public byte[] get(String key) {
- return get(key, UID_SELF);
+ public byte[] get(String key, boolean suppressKeyNotFoundWarning) {
+ return get(key, UID_SELF, suppressKeyNotFoundWarning);
}
+
public boolean put(String key, byte[] value, int uid, int flags) {
return insert(key, value, uid, flags) == NO_ERROR;
}