Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bf37cf8 authored by Irina Dumitrescu's avatar Irina Dumitrescu Committed by android-build-merger
Browse files

Merge "Add Keystore get option that supresses caught exceptions warnings."

am: f070b516

Change-Id: I5f229fc9d08e445c32ea8cf4e971129d79019cef
parents 8dada718 f070b516
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -222,6 +222,15 @@ public class KeyStore {
    }

    public byte[] get(String key, int uid) {
        return get(key, uid, false);
    }

    @UnsupportedAppUsage
    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);
@@ -229,16 +238,18 @@ public class KeyStore {
            Log.w(TAG, "Cannot connect to keystore", e);
            return null;
        } catch (android.os.ServiceSpecificException e) {
            if (!suppressKeyNotFoundWarning || e.errorCode != KEY_NOT_FOUND) {
                Log.w(TAG, "KeyStore exception", e);
            }
            return null;
        }
    }

    @UnsupportedAppUsage
    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;
    }