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