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

Commit 919f2169 authored by Rob Barnes's avatar Rob Barnes Committed by android-build-merger
Browse files

Merge "Added listUidsForAuthBoundKeys to KeyStore" am: 73e96401

am: 3090f045

Change-Id: I10ebfdc276a6af84b32b116c6d93f488ad0c97b8
parents bc9e3a0d 3090f045
Loading
Loading
Loading
Loading
+26 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ import java.math.BigInteger;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.InvalidKeyException;
import java.util.Arrays;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletableFuture;
@@ -296,6 +297,31 @@ public class KeyStore {
        }
        }
    }
    }


    /**
     * List uids of all keys that are auth bound to the current user. 
     * Only system is allowed to call this method.
     */
    @UnsupportedAppUsage
    public int[] listUidsOfAuthBoundKeys() {
        final int MAX_RESULT_SIZE = 100;
        int[] uidsOut = new int[MAX_RESULT_SIZE];
        try {
            int rc = mBinder.listUidsOfAuthBoundKeys(uidsOut);
            if (rc != NO_ERROR) {
                Log.w(TAG, String.format("listUidsOfAuthBoundKeys failed with error code %d", rc));
                return null;
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Cannot connect to keystore", e);
            return null;
        } catch (android.os.ServiceSpecificException e) {
            Log.w(TAG, "KeyStore exception", e);
            return null;
        }
        // Remove any 0 entries
        return Arrays.stream(uidsOut).filter(x -> x > 0).toArray();
   }

    public String[] list(String prefix) {
    public String[] list(String prefix) {
        return list(prefix, UID_SELF);
        return list(prefix, UID_SELF);
    }
    }