Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b787dff5 authored by Reema Bajwa's avatar Reema Bajwa Committed by Android (Google) Code Review
Browse files

Merge "Propagate cancellations to session" into main

parents f758ea9b ca10918a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -45,6 +45,17 @@ public class GetCandidateCredentialsException extends Exception {
    public static final String TYPE_NO_CREDENTIAL =
            "android.credentials.GetCandidateCredentialsException.TYPE_NO_CREDENTIAL";

    @NonNull
    public static final String TYPE_USER_CANCELED =
            "android.credentials.GetCredentialException.TYPE_USER_CANCELED";
    /**
     * The error type value for when the given operation failed due to internal interruption.
     * Retrying the same operation should fix the error.
     */
    @NonNull
    public static final String TYPE_INTERRUPTED =
            "android.credentials.GetCredentialException.TYPE_INTERRUPTED";

    @NonNull
    private final String mType;

+2 −1
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
            long startedTimestamp) {
        super(context, sessionCallback, lock, userId, callingUid, request, callback,
                RequestInfo.TYPE_UNDEFINED,
                callingAppInfo, enabledProviders, cancellationSignal, startedTimestamp);
                callingAppInfo, enabledProviders, cancellationSignal, startedTimestamp,
                /*shouldBindClientToDeath=*/ true);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -63,7 +63,8 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
            long startedTimestamp) {
        super(context, sessionCallback, lock, userId, callingUid, request, callback,
                RequestInfo.TYPE_CREATE,
                callingAppInfo, enabledProviders, cancellationSignal, startedTimestamp);
                callingAppInfo, enabledProviders, cancellationSignal, startedTimestamp,
                /*shouldBindClientToDeath=*/ true);
        mRequestSessionMetric.collectCreateFlowInitialMetricInfo(
                /*origin=*/request.getOrigin() != null, request);
        mPrimaryProviders = primaryProviders;
+17 −4
Original line number Diff line number Diff line
@@ -65,10 +65,13 @@ public class GetCandidateRequestSession extends RequestSession<GetCredentialRequ
            IAutoFillManagerClient autoFillCallback) {
        super(context, sessionCallback, lock, userId, callingUid, request, callback,
                RequestInfo.TYPE_GET, callingAppInfo, enabledProviders,
                cancellationSignal, 0L);
                cancellationSignal, 0L, /*shouldBindClientToDeath=*/ false);
        mAutoFillCallback = autoFillCallback;
        mAutofillSessionId = request.getData().getInt(SESSION_ID_KEY, -1);
        mAutofillRequestId = request.getData().getInt(REQUEST_ID_KEY, -1);
        if (mAutoFillCallback != null) {
            setUpClientCallbackListener(mAutoFillCallback.asBinder());
        }
    }

    /**
@@ -144,17 +147,27 @@ public class GetCandidateRequestSession extends RequestSession<GetCredentialRequ
    @Override
    public void onFinalErrorReceived(ComponentName componentName, String errorType,
            String message) {
        // Not applicable for session without UI
        respondToClientWithErrorAndFinish(errorType, message);
    }

    @Override
    public void onUiCancellation(boolean isUserCancellation) {
        // Not applicable for session without UI
        String exception = GetCandidateCredentialsException.TYPE_USER_CANCELED;
        String message = "User cancelled the selector";
        if (!isUserCancellation) {
            exception = GetCandidateCredentialsException.TYPE_INTERRUPTED;
            message = "The UI was interrupted - please try again.";
        }
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception, message);
    }

    @Override
    public void onUiSelectorInvocationFailure() {
        // Not applicable for session without UI
        String exception = GetCandidateCredentialsException.TYPE_NO_CREDENTIAL;
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception,
                "No credentials available.");
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
            long startedTimestamp) {
        super(context, sessionCallback, lock, userId, callingUid, request, callback,
                getRequestInfoFromRequest(request), callingAppInfo, enabledProviders,
                cancellationSignal, startedTimestamp);
                cancellationSignal, startedTimestamp, /*shouldBindClientToDeath=*/ true);
        mRequestSessionMetric.collectGetFlowInitialMetricInfo(request);
    }

Loading