diff --git a/services/credentials/java/com/android/server/credentials/GetRequestSession.java b/services/credentials/java/com/android/server/credentials/GetRequestSession.java index 5e167712a8e87..32b14d773b952 100644 --- a/services/credentials/java/com/android/server/credentials/GetRequestSession.java +++ b/services/credentials/java/com/android/server/credentials/GetRequestSession.java @@ -44,7 +44,6 @@ public final class GetRequestSession extends RequestSession implements ProviderSession.ProviderInternalCallback { private static final String TAG = "GetRequestSession"; - public GetRequestSession(Context context, int userId, int callingUid, IGetCredentialCallback callback, GetCredentialRequest request, CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { @@ -173,6 +172,12 @@ public final class GetRequestSession extends RequestSession { + ProviderGetSession session = (ProviderGetSession) mProviders.get(key); + if (!session.mComponentName.equals(componentName)) { + session.updateAuthEntriesStatusFromAnotherSession(); + } + }); + + // Invoke UI since it needs to show a snackbar if last auth entry, or a status on each + // auth entries along with other valid entries + getProviderDataAndInitiateUi(); + + // Respond to client if all auth entries are empty and nothing else to show on the UI + if (providerDataContainsEmptyAuthEntriesOnly()) { + respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, + "No credentials available"); + } + } + + private boolean providerDataContainsEmptyAuthEntriesOnly() { + for (String key : mProviders.keySet()) { + ProviderGetSession session = (ProviderGetSession) mProviders.get(key); + if (!session.containsEmptyAuthEntriesOnly()) { + return false; + } + } + return true; + } } diff --git a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java index 12074c7494bf9..8c94b0ada2a82 100644 --- a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java +++ b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java @@ -241,13 +241,14 @@ public final class ProviderGetSession extends ProviderSession e.second.getStatus() == AuthenticationEntry + .STATUS_UNLOCKED_BUT_EMPTY_LESS_RECENT + || e.second.getStatus() + == AuthenticationEntry.STATUS_UNLOCKED_BUT_EMPTY_MOST_RECENT + ); + } + private class ProviderResponseDataHandler { private final ComponentName mExpectedRemoteEntryProviderService; @NonNull @@ -610,7 +632,12 @@ public final class ProviderGetSession extends ProviderSession * on the credMan UI. */ public static boolean isUiInvokingStatus(Status status) { - return status == Status.CREDENTIALS_RECEIVED || status == Status.SAVE_ENTRIES_RECEIVED; + return status == Status.CREDENTIALS_RECEIVED || status == Status.SAVE_ENTRIES_RECEIVED + || status == Status.NO_CREDENTIALS_FROM_AUTH_ENTRY; } /** @@ -140,7 +141,7 @@ public abstract class ProviderSession PENDING_INTENT_INVOKED, CREDENTIAL_RECEIVED_FROM_SELECTION, SAVE_ENTRIES_RECEIVED, CANCELED, - NO_CREDENTIALS, EMPTY_RESPONSE, COMPLETE + NO_CREDENTIALS, EMPTY_RESPONSE, NO_CREDENTIALS_FROM_AUTH_ENTRY, COMPLETE } /** Converts exception to a provider session status. */ diff --git a/services/credentials/java/com/android/server/credentials/RequestSession.java b/services/credentials/java/com/android/server/credentials/RequestSession.java index f0d05c5dfd059..f8bbfcfb6a4d5 100644 --- a/services/credentials/java/com/android/server/credentials/RequestSession.java +++ b/services/credentials/java/com/android/server/credentials/RequestSession.java @@ -216,7 +216,7 @@ abstract class RequestSession implements CredentialManagerUi.CredentialMan * Returns true if at least one provider is ready for UI invocation, and no * provider is pending a response. */ - boolean isUiInvocationNeeded() { + protected boolean isUiInvocationNeeded() { for (ProviderSession session : mProviders.values()) { if (ProviderSession.isUiInvokingStatus(session.getStatus())) { return true;