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

Commit c6bd1855 authored by Robert Berry's avatar Robert Berry Committed by Android (Google) Code Review
Browse files

Merge "Unhide RecoveryController#getRootCertificates()" into pi-dev

parents 3818de59 93d002ca
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -4371,6 +4371,7 @@ package android.security.keystore.recovery {
    method public int[] getRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public int[] getRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated int getRecoveryStatus(java.lang.String, java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated int getRecoveryStatus(java.lang.String, java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public int getRecoveryStatus(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public int getRecoveryStatus(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public java.util.Map<java.lang.String, java.security.cert.X509Certificate> getRootCertificates();
    method public java.security.Key importKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public java.security.Key importKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public deprecated void initRecoveryService(java.lang.String, byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated void initRecoveryService(java.lang.String, byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
    method public void initRecoveryService(java.lang.String, byte[], byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
    method public void initRecoveryService(java.lang.String, byte[], byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import java.security.Key;
import java.security.UnrecoverableKeyException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertPath;
import java.security.cert.CertPath;
import java.security.cert.CertificateException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@@ -654,6 +655,11 @@ public class RecoveryController {
        return RecoverySession.newInstance(this);
        return RecoverySession.newInstance(this);
    }
    }


    @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE)
    public Map<String, X509Certificate> getRootCertificates() {
        return TrustedRootCertificates.getRootCertificates();
    }

    InternalRecoveryServiceException wrapUnexpectedServiceSpecificException(
    InternalRecoveryServiceException wrapUnexpectedServiceSpecificException(
            ServiceSpecificException e) {
            ServiceSpecificException e) {
        if (e.errorCode == ERROR_SERVICE_INTERNAL_ERROR) {
        if (e.errorCode == ERROR_SERVICE_INTERNAL_ERROR) {
+5 −2
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import java.util.Map;
 *
 *
 * @hide
 * @hide
 */
 */
public class TrustedRootCertificates {
public final class TrustedRootCertificates {


    public static final String GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS =
    public static final String GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS =
            "GoogleCloudKeyVaultServiceV1";
            "GoogleCloudKeyVaultServiceV1";
@@ -83,7 +83,7 @@ public class TrustedRootCertificates {
    /**
    /**
     * Returns all available root certificates, keyed by alias.
     * Returns all available root certificates, keyed by alias.
     */
     */
    public static Map<String, X509Certificate> listRootCertificates() {
    public static Map<String, X509Certificate> getRootCertificates() {
        return new ArrayMap(ALL_ROOT_CERTIFICATES);
        return new ArrayMap(ALL_ROOT_CERTIFICATES);
    }
    }


@@ -114,4 +114,7 @@ public class TrustedRootCertificates {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        }
        }
    }
    }

    // Statics only
    private TrustedRootCertificates() {}
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -16,7 +16,7 @@


package android.security.keystore.recovery;
package android.security.keystore.recovery;


import static android.security.keystore.recovery.TrustedRootCertificates.listRootCertificates;
import static android.security.keystore.recovery.TrustedRootCertificates.getRootCertificates;


import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;


@@ -36,8 +36,8 @@ public class TrustedRootCertificatesTest {
            "GoogleCloudKeyVaultServiceV1";
            "GoogleCloudKeyVaultServiceV1";


    @Test
    @Test
    public void listRootCertificates_listsGoogleCloudVaultV1Certificate() {
    public void getRootCertificates_listsGoogleCloudVaultV1Certificate() {
        Map<String, X509Certificate> certificates = listRootCertificates();
        Map<String, X509Certificate> certificates = getRootCertificates();


        assertTrue(certificates.containsKey(GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS));
        assertTrue(certificates.containsKey(GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS));
    }
    }