Throw invalid cert exception when deprecated initRecoveryService method

is used.

Throw unsupported operation exception when older version of RecoveryController is used.

Bug: 77293264
Test: atest RecoveryControllerHostTest
Change-Id: I0003104a4305444fac0092f4f6929545cf7c9413
This commit is contained in:
Dmitry Dementyev
2018-03-30 20:18:22 -07:00
parent 9cbf27af12
commit 50bc7e42d7
2 changed files with 5 additions and 25 deletions

View File

@@ -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");
}
/**

View File

@@ -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");
}
/**