Merge "Address TODOs for Credential Manager" into udc-dev
This commit is contained in:
@@ -196,25 +196,36 @@ public final class CredentialManagerService
|
||||
return;
|
||||
}
|
||||
|
||||
CredentialManagerServiceImpl serviceToBeRemoved = null;
|
||||
List<CredentialManagerServiceImpl> servicesToBeRemoved = new ArrayList<>();
|
||||
for (CredentialManagerServiceImpl service : services) {
|
||||
if (service != null) {
|
||||
CredentialProviderInfo credentialProviderInfo = service.getCredentialProviderInfo();
|
||||
ComponentName componentName =
|
||||
credentialProviderInfo.getServiceInfo().getComponentName();
|
||||
if (packageName.equals(componentName.getPackageName())) {
|
||||
serviceToBeRemoved = service;
|
||||
removeServiceFromMultiModeSettings(componentName.flattenToString(), userId);
|
||||
break;
|
||||
servicesToBeRemoved.add(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (serviceToBeRemoved != null) {
|
||||
|
||||
// Iterate over all the services to be removed, and remove them from the user configurable
|
||||
// services cache, the system services cache as well as the setting key-value pair.
|
||||
for (CredentialManagerServiceImpl serviceToBeRemoved : servicesToBeRemoved) {
|
||||
removeServiceFromCache(serviceToBeRemoved, userId);
|
||||
removeServiceFromSystemServicesCache(serviceToBeRemoved, userId);
|
||||
removeServiceFromMultiModeSettings(serviceToBeRemoved.getComponentName()
|
||||
.flattenToString(), userId);
|
||||
CredentialDescriptionRegistry.forUser(userId)
|
||||
.evictProviderWithPackageName(serviceToBeRemoved.getServicePackageName());
|
||||
}
|
||||
// TODO("Iterate over system services and remove if needed")
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private void removeServiceFromSystemServicesCache(
|
||||
CredentialManagerServiceImpl serviceToBeRemoved, int userId) {
|
||||
if (mSystemServicesCacheList.get(userId) != null) {
|
||||
mSystemServicesCacheList.get(userId).remove(serviceToBeRemoved);
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
|
||||
@@ -38,7 +38,6 @@ public final class CredentialManagerServiceImpl extends
|
||||
AbstractPerUserSystemService<CredentialManagerServiceImpl, CredentialManagerService> {
|
||||
private static final String TAG = "CredManSysServiceImpl";
|
||||
|
||||
// TODO(b/210531) : Make final when update flow is fixed
|
||||
@GuardedBy("mLock")
|
||||
@NonNull
|
||||
private CredentialProviderInfo mInfo;
|
||||
@@ -72,7 +71,6 @@ public final class CredentialManagerServiceImpl extends
|
||||
@GuardedBy("mLock")
|
||||
protected ServiceInfo newServiceInfoLocked(@NonNull ComponentName serviceComponent)
|
||||
throws PackageManager.NameNotFoundException {
|
||||
// TODO : Test update flows with multiple providers
|
||||
if (mInfo != null) {
|
||||
Slog.i(TAG, "newServiceInfoLocked, mInfo not null : "
|
||||
+ mInfo.getServiceInfo().getComponentName().flattenToString() + " , "
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CredentialManagerUi {
|
||||
private final CredentialManagerUiCallback mCallbacks;
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
// TODO : Use for starting the activity for this user
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
private UiStatus mStatus;
|
||||
|
||||
@@ -62,7 +62,6 @@ public final class ProviderClearSession extends ProviderSession<ClearCredentialS
|
||||
android.credentials.ClearCredentialStateRequest clientRequest,
|
||||
CallingAppInfo callingAppInfo
|
||||
) {
|
||||
// TODO: Determine if provider needs to declare clear capability in manifest
|
||||
return new ClearCredentialStateRequest(
|
||||
callingAppInfo,
|
||||
clientRequest.getData());
|
||||
@@ -95,7 +94,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredentialS
|
||||
mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
|
||||
}
|
||||
mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
|
||||
updateStatusAndInvokeCallback(toStatus(errorCode),
|
||||
updateStatusAndInvokeCallback(Status.CANCELED,
|
||||
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class ProviderCreateSession extends ProviderSession<
|
||||
mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
|
||||
}
|
||||
mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
|
||||
updateStatusAndInvokeCallback(toStatus(errorCode),
|
||||
updateStatusAndInvokeCallback(Status.CANCELED,
|
||||
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
|
||||
mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
|
||||
}
|
||||
mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
|
||||
updateStatusAndInvokeCallback(toStatus(errorCode),
|
||||
updateStatusAndInvokeCallback(Status.CANCELED,
|
||||
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +110,7 @@ public abstract class ProviderSession<T, R>
|
||||
* and is ready to return the final credential back to the user.
|
||||
*/
|
||||
public static boolean isCompletionStatus(Status status) {
|
||||
return status == Status.CREDENTIAL_RECEIVED_FROM_INTENT
|
||||
|| status == Status.CREDENTIAL_RECEIVED_FROM_SELECTION
|
||||
|| status == Status.COMPLETE;
|
||||
return status == Status.COMPLETE || status == Status.EMPTY_RESPONSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,26 +149,17 @@ public abstract class ProviderSession<T, R>
|
||||
mProviderSessionUid = MetricUtilities.getPackageUid(mContext, mComponentName);
|
||||
}
|
||||
|
||||
/** Provider status at various states of the request session. */
|
||||
// TODO: Review status values, and adjust where needed
|
||||
/** Provider status at various states of the provider session. */
|
||||
enum Status {
|
||||
NOT_STARTED,
|
||||
PENDING,
|
||||
REQUIRES_AUTHENTICATION,
|
||||
CREDENTIALS_RECEIVED,
|
||||
SERVICE_DEAD,
|
||||
CREDENTIAL_RECEIVED_FROM_INTENT,
|
||||
PENDING_INTENT_INVOKED,
|
||||
CREDENTIAL_RECEIVED_FROM_SELECTION,
|
||||
SAVE_ENTRIES_RECEIVED, CANCELED,
|
||||
NO_CREDENTIALS, EMPTY_RESPONSE, NO_CREDENTIALS_FROM_AUTH_ENTRY, COMPLETE
|
||||
}
|
||||
|
||||
/** Converts exception to a provider session status. */
|
||||
@NonNull
|
||||
public static Status toStatus(int errorCode) {
|
||||
// TODO : Add more mappings as more flows are supported
|
||||
return Status.CANCELED;
|
||||
SAVE_ENTRIES_RECEIVED,
|
||||
CANCELED,
|
||||
EMPTY_RESPONSE,
|
||||
NO_CREDENTIALS_FROM_AUTH_ENTRY,
|
||||
COMPLETE
|
||||
}
|
||||
|
||||
protected static String generateUniqueId() {
|
||||
|
||||
Reference in New Issue
Block a user