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

Commit f070b516 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents f899e268 203bd1b1
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -222,6 +222,15 @@ public class KeyStore {
    }
    }


    public byte[] get(String key, int uid) {
    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 {
        try {
            key = key != null ? key : "";
            key = key != null ? key : "";
            return mBinder.get(key, uid);
            return mBinder.get(key, uid);
@@ -229,16 +238,18 @@ public class KeyStore {
            Log.w(TAG, "Cannot connect to keystore", e);
            Log.w(TAG, "Cannot connect to keystore", e);
            return null;
            return null;
        } catch (android.os.ServiceSpecificException e) {
        } catch (android.os.ServiceSpecificException e) {
            if (!suppressKeyNotFoundWarning || e.errorCode != KEY_NOT_FOUND) {
                Log.w(TAG, "KeyStore exception", e);
                Log.w(TAG, "KeyStore exception", e);
            }
            return null;
            return null;
        }
        }
    }
    }


    @UnsupportedAppUsage
    public byte[] get(String key, boolean suppressKeyNotFoundWarning) {
    public byte[] get(String key) {
        return get(key, UID_SELF, suppressKeyNotFoundWarning);
        return get(key, UID_SELF);
    }
    }



    public boolean put(String key, byte[] value, int uid, int flags) {
    public boolean put(String key, byte[] value, int uid, int flags) {
        return insert(key, value, uid, flags) == NO_ERROR;
        return insert(key, value, uid, flags) == NO_ERROR;
    }
    }