Remove packageName from getRecoveryStatus
This parameter is unused.
Bug: 73757432
Test: runtest frameworks-services -p
com.android.server.locksettings.recoverablekeystore
Change-Id: I153a84d71b0ebaed8ce3a1f0f33c70036dd960b2
This commit is contained in:
@@ -4293,12 +4293,11 @@ package android.security.keystore.recovery {
|
||||
|
||||
public class RecoveryController {
|
||||
method public byte[] generateAndStoreKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
|
||||
method public java.util.List<java.lang.String> getAliases(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public java.util.List<java.lang.String> getAliases() throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public static android.security.keystore.recovery.RecoveryController getInstance(android.content.Context);
|
||||
method public int[] getPendingRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public android.security.keystore.recovery.KeyChainSnapshot getRecoveryData() throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public int[] getRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public 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 void initRecoveryService(java.lang.String, byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public void recoverySecretAvailable(android.security.keystore.recovery.KeyChainProtectionParams) throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public void removeKey(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
|
||||
@@ -94,6 +94,9 @@ package android.os {
|
||||
package android.security.keystore.recovery {
|
||||
|
||||
public class RecoveryController {
|
||||
method public deprecated java.util.List<java.lang.String> getAliases(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
|
||||
method public deprecated android.security.keystore.recovery.KeyChainSnapshot getRecoveryData() 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 void setRecoveryStatus(java.lang.String, java.lang.String, int) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.content.pm.PackageManager.NameNotFoundException;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public class RecoveryController {
|
||||
// IPC doesn't support generic Maps.
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Integer> result =
|
||||
(Map<String, Integer>) mBinder.getRecoveryStatus(/*packageName=*/ null);
|
||||
(Map<String, Integer>) mBinder.getRecoveryStatus();
|
||||
return result;
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -175,28 +175,13 @@ public class RecoveryController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - use getKeyChainSnapshot.
|
||||
*
|
||||
* Returns data necessary to store all recoverable keys. Key material is
|
||||
* encrypted with user secret and recovery public key.
|
||||
*
|
||||
* @return Data necessary to recover keystore.
|
||||
* @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery
|
||||
* service.
|
||||
* @deprecated Use {@link #getKeyChainSnapshot()}
|
||||
* @removed
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE)
|
||||
public @Nullable KeyChainSnapshot getRecoveryData()
|
||||
throws InternalRecoveryServiceException {
|
||||
try {
|
||||
return mBinder.getKeyChainSnapshot();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
} catch (ServiceSpecificException e) {
|
||||
if (e.errorCode == ERROR_NO_SNAPSHOT_PENDING) {
|
||||
return null;
|
||||
}
|
||||
throw wrapUnexpectedServiceSpecificException(e);
|
||||
}
|
||||
public @Nullable KeyChainSnapshot getRecoveryData() throws InternalRecoveryServiceException {
|
||||
return getKeyChainSnapshot();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,17 +253,21 @@ public class RecoveryController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets aliases of recoverable keys for the application.
|
||||
*
|
||||
* @param packageName which recoverable keys' aliases will be returned.
|
||||
*
|
||||
* @return {@code List} of all aliases.
|
||||
* @deprecated Use {@link #getAliases()}.
|
||||
* @removed
|
||||
*/
|
||||
@Deprecated
|
||||
public List<String> getAliases(@Nullable String packageName)
|
||||
throws InternalRecoveryServiceException {
|
||||
return getAliases();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of aliases of keys belonging to the application.
|
||||
*/
|
||||
public List<String> getAliases() throws InternalRecoveryServiceException {
|
||||
try {
|
||||
// TODO: update aidl
|
||||
Map<String, Integer> allStatuses = mBinder.getRecoveryStatus(packageName);
|
||||
Map<String, Integer> allStatuses = mBinder.getRecoveryStatus();
|
||||
return new ArrayList<>(allStatuses.keySet());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -323,28 +312,31 @@ public class RecoveryController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns recovery status for Application's KeyStore key.
|
||||
* Negative status values are reserved for recovery agent specific codes. List of common codes:
|
||||
* @deprecated Use {@link #getRecoveryStatus(String)}.
|
||||
* @removed
|
||||
*/
|
||||
@Deprecated
|
||||
public int getRecoveryStatus(String packageName, String alias)
|
||||
throws InternalRecoveryServiceException {
|
||||
return getRecoveryStatus(alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recovery status for the key with the given {@code alias}.
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link #RECOVERY_STATUS_SYNCED}
|
||||
* <li>{@link #RECOVERY_STATUS_SYNC_IN_PROGRESS}
|
||||
* <li>{@link #RECOVERY_STATUS_MISSING_ACCOUNT}
|
||||
* <li>{@link #RECOVERY_STATUS_PERMANENT_FAILURE}
|
||||
* </ul>
|
||||
*
|
||||
* @param packageName Application whose recoverable key status is returned.
|
||||
* @param alias Application-specific key alias.
|
||||
* @return Recovery status.
|
||||
* @see #setRecoveryStatus
|
||||
* @see #setRecoveryStatus(String, int)
|
||||
* @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery
|
||||
* service.
|
||||
*/
|
||||
public int getRecoveryStatus(String packageName, String alias)
|
||||
throws InternalRecoveryServiceException {
|
||||
public int getRecoveryStatus(String alias) throws InternalRecoveryServiceException {
|
||||
try {
|
||||
// TODO: update aidl
|
||||
Map<String, Integer> allStatuses = mBinder.getRecoveryStatus(packageName);
|
||||
Map<String, Integer> allStatuses = mBinder.getRecoveryStatus();
|
||||
Integer status = allStatuses.get(alias);
|
||||
if (status == null) {
|
||||
return RecoveryController.RECOVERY_STATUS_PERMANENT_FAILURE;
|
||||
|
||||
@@ -73,7 +73,7 @@ interface ILockSettings {
|
||||
Map getRecoverySnapshotVersions();
|
||||
void setServerParams(in byte[] serverParams);
|
||||
void setRecoveryStatus(in String alias, int status);
|
||||
Map getRecoveryStatus(in String packageName);
|
||||
Map getRecoveryStatus();
|
||||
void setRecoverySecretTypes(in int[] secretTypes);
|
||||
int[] getRecoverySecretTypes();
|
||||
int[] getPendingRecoverySecretTypes();
|
||||
|
||||
@@ -2005,8 +2005,8 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
mRecoverableKeyStoreManager.setRecoveryStatus(alias, status);
|
||||
}
|
||||
|
||||
public Map getRecoveryStatus(@Nullable String packageName) throws RemoteException {
|
||||
return mRecoverableKeyStoreManager.getRecoveryStatus(packageName);
|
||||
public Map getRecoveryStatus() throws RemoteException {
|
||||
return mRecoverableKeyStoreManager.getRecoveryStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -285,16 +285,14 @@ public class RecoverableKeyStoreManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets recovery status for caller or other application {@code packageName}.
|
||||
* @param packageName which recoverable keys statuses will be returned.
|
||||
* Returns recovery statuses for all keys belonging to the calling uid.
|
||||
*
|
||||
* @return {@code Map} from KeyStore alias to recovery status.
|
||||
* @return {@link Map} from key alias to recovery status. Recovery status is one of
|
||||
* {@link RecoveryController#RECOVERY_STATUS_SYNCED},
|
||||
* {@link RecoveryController#RECOVERY_STATUS_SYNC_IN_PROGRESS} or
|
||||
* {@link RecoveryController#RECOVERY_STATUS_PERMANENT_FAILURE}.
|
||||
*/
|
||||
public @NonNull Map<String, Integer> getRecoveryStatus(@Nullable String packageName)
|
||||
throws RemoteException {
|
||||
// Any application should be able to check status for its own keys.
|
||||
// If caller is a recovery agent it can check statuses for other packages, but
|
||||
// only for recoverable keys it manages.
|
||||
public @NonNull Map<String, Integer> getRecoveryStatus() throws RemoteException {
|
||||
return mDatabase.getStatusForAllKeys(Binder.getCallingUid());
|
||||
}
|
||||
|
||||
|
||||
@@ -648,12 +648,12 @@ public class RecoverableKeyStoreManagerTest {
|
||||
WrappedKey wrappedKey = new WrappedKey(NONCE, KEY_MATERIAL, GENERATION_ID, status);
|
||||
mRecoverableKeyStoreDb.insertKey(userId, uid, alias, wrappedKey);
|
||||
Map<String, Integer> statuses =
|
||||
mRecoverableKeyStoreManager.getRecoveryStatus(/*packageName=*/ null);
|
||||
mRecoverableKeyStoreManager.getRecoveryStatus();
|
||||
assertThat(statuses).hasSize(1);
|
||||
assertThat(statuses).containsEntry(alias, status);
|
||||
|
||||
mRecoverableKeyStoreManager.setRecoveryStatus(alias, status2);
|
||||
statuses = mRecoverableKeyStoreManager.getRecoveryStatus(/*packageName=*/ null);
|
||||
statuses = mRecoverableKeyStoreManager.getRecoveryStatus();
|
||||
assertThat(statuses).hasSize(1);
|
||||
assertThat(statuses).containsEntry(alias, status2); // updated
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user