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

Commit f2c4c0a0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixes attestation id gathering from secondary android user"

parents bfe08f7b 6ab9bb68
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,12 @@ public class Process {
     */
    public static final int VPN_UID = 1016;

    /**
     * Defines the UID/GID for keystore.
     * @hide
     */
    public static final int KEYSTORE_UID = 1017;

    /**
     * Defines the UID/GID for the NFC service process.
     * @hide
+14 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Binder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.security.keymaster.KeyAttestationPackageInfo;
@@ -45,14 +46,19 @@ public class KeyAttestationApplicationIdProviderService

    public KeyAttestationApplicationId getKeyAttestationApplicationId(int uid)
            throws RemoteException {
        if (Binder.getCallingUid() != android.os.Process.KEYSTORE_UID) {
            throw new SecurityException("This service can only be used by Keystore");
        }
        KeyAttestationPackageInfo[] keyAttestationPackageInfos = null;
        final long token = Binder.clearCallingIdentity();
        try {
            String[] packageNames = mPackageManager.getPackagesForUid(uid);
            if (packageNames == null) {
                throw new RemoteException("No packages for uid");
            }
            int userId = UserHandle.getUserId(uid);
        KeyAttestationPackageInfo[] keyAttestationPackageInfos =
                new KeyAttestationPackageInfo[packageNames.length];
        try {
            keyAttestationPackageInfos = new KeyAttestationPackageInfo[packageNames.length];

            for (int i = 0; i < packageNames.length; ++i) {
                PackageInfo packageInfo = mPackageManager.getPackageInfoAsUser(packageNames[i],
                        PackageManager.GET_SIGNATURES, userId);
@@ -61,6 +67,8 @@ public class KeyAttestationApplicationIdProviderService
            }
        } catch (NameNotFoundException nnfe) {
            throw new RemoteException(nnfe.getMessage());
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return new KeyAttestationApplicationId(keyAttestationPackageInfos);
    }