diff options
| author | 2018-02-23 13:31:32 +0000 | |
|---|---|---|
| committer | 2018-02-23 15:12:06 +0000 | |
| commit | 56f06b4d111f99f72d4232b43037fea2f6246e7d (patch) | |
| tree | d458f78e9715237ead7bd6ad73d2589dd265bed6 | |
| parent | 24257520267701f36e67754677bdae9472b05428 (diff) | |
Remove packageName from getRecoveryStatus
This parameter is unused.
Bug: 73757432
Test: runtest frameworks-services -p
com.android.server.locksettings.recoverablekeystore
Change-Id: I153a84d71b0ebaed8ce3a1f0f33c70036dd960b2
8 files changed, 47 insertions, 55 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 1235591a7e6b..73101c39c244 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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; diff --git a/api/system-removed.txt b/api/system-removed.txt index ac40052b7e80..ab344eb3606c 100644 --- a/api/system-removed.txt +++ b/api/system-removed.txt @@ -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; } diff --git a/core/java/android/security/keystore/RecoveryController.java b/core/java/android/security/keystore/RecoveryController.java index 786d45417f6f..4a0de5f2c7f0 100644 --- a/core/java/android/security/keystore/RecoveryController.java +++ b/core/java/android/security/keystore/RecoveryController.java @@ -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(); diff --git a/core/java/android/security/keystore/recovery/RecoveryController.java b/core/java/android/security/keystore/recovery/RecoveryController.java index d57782c066e1..f407bd5e028d 100644 --- a/core/java/android/security/keystore/recovery/RecoveryController.java +++ b/core/java/android/security/keystore/recovery/RecoveryController.java @@ -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; diff --git a/core/java/com/android/internal/widget/ILockSettings.aidl b/core/java/com/android/internal/widget/ILockSettings.aidl index 17e498ce5e50..5f6702aed7e2 100644 --- a/core/java/com/android/internal/widget/ILockSettings.aidl +++ b/core/java/com/android/internal/widget/ILockSettings.aidl @@ -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(); diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 838aa701ae4a..a118219e5150 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -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 diff --git a/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java b/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java index 35954a54e385..e8f80ad34e29 100644 --- a/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java +++ b/services/core/java/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManager.java @@ -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()); } diff --git a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java index 3c35c5ba80d5..da6fa8924a38 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/recoverablekeystore/RecoverableKeyStoreManagerTest.java @@ -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 } |