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

Commit bf087747 authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Android (Google) Code Review
Browse files

Merge "Throw invalid cert exception when deprecated initRecoveryService method...

Merge "Throw invalid cert exception when deprecated initRecoveryService method is used." into pi-dev
parents 49eb4c1f 50bc7e42
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.util.Log;

@@ -99,12 +98,11 @@ public class RecoveryController {
    }

    /**
     * Deprecated.
     * Gets a new instance of the class.
     */
    public static RecoveryController getInstance() {
        ILockSettings lockSettings =
                ILockSettings.Stub.asInterface(ServiceManager.getService("lock_settings"));
        return new RecoveryController(lockSettings);
        throw new UnsupportedOperationException("using Deprecated RecoveryController version");
    }

    /**
@@ -128,16 +126,8 @@ public class RecoveryController {
    public void initRecoveryService(
            @NonNull String rootCertificateAlias, @NonNull byte[] signedPublicKeyList)
            throws BadCertificateFormatException, InternalRecoveryServiceException {
        try {
            mBinder.initRecoveryService(rootCertificateAlias, signedPublicKeyList);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (ServiceSpecificException e) {
            if (e.errorCode == ERROR_BAD_CERTIFICATE_FORMAT) {
                throw new BadCertificateFormatException(e.getMessage());
            }
            throw wrapUnexpectedServiceSpecificException(e);
        }
        throw new UnsupportedOperationException("Deprecated initRecoveryService method called");

    }

    /**
+1 −11
Original line number Diff line number Diff line
@@ -285,17 +285,7 @@ public class RecoveryController {
    public void initRecoveryService(
            @NonNull String rootCertificateAlias, @NonNull byte[] signedPublicKeyList)
            throws CertificateException, InternalRecoveryServiceException {
        try {
            mBinder.initRecoveryService(rootCertificateAlias, signedPublicKeyList);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (ServiceSpecificException e) {
            if (e.errorCode == ERROR_BAD_CERTIFICATE_FORMAT
                    || e.errorCode == ERROR_INVALID_CERTIFICATE) {
                throw new CertificateException("Invalid certificate for recovery service", e);
            }
            throw wrapUnexpectedServiceSpecificException(e);
        }
        throw new CertificateException("Deprecated initRecoveryService method called");
    }

    /**