Merge "Return USER_CANCELED exception type for credMan get & create flows"
This commit is contained in:
@@ -81,8 +81,9 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
|
||||
mClientAppInfo.getPackageName()),
|
||||
providerDataList));
|
||||
} catch (RemoteException e) {
|
||||
Log.i(TAG, "Issue with invoking pending intent: " + e.getMessage());
|
||||
// TODO: Propagate failure
|
||||
respondToClientWithErrorAndFinish(
|
||||
CreateCredentialException.TYPE_UNKNOWN,
|
||||
"Unable to invoke selector");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +107,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
|
||||
|
||||
@Override
|
||||
public void onUiCancellation() {
|
||||
// TODO("Replace with properly defined error type")
|
||||
respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL,
|
||||
respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_USER_CANCELED,
|
||||
"User cancelled the selector");
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest
|
||||
mRequestId, mClientRequest, mClientAppInfo.getPackageName()),
|
||||
providerDataList));
|
||||
} catch (RemoteException e) {
|
||||
Log.i(TAG, "Issue with invoking pending intent: " + e.getMessage());
|
||||
// TODO: Propagate failure
|
||||
respondToClientWithErrorAndFinish(
|
||||
GetCredentialException.TYPE_UNKNOWN, "Unable to instantiate selector");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,7 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest
|
||||
|
||||
@Override
|
||||
public void onUiCancellation() {
|
||||
// TODO("Replace with user cancelled error type when ready")
|
||||
respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
|
||||
respondToClientWithErrorAndFinish(GetCredentialException.TYPE_USER_CANCELED,
|
||||
"User cancelled the selector");
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,12 @@ public class PendingIntentResultHandler {
|
||||
return pendingIntentResponse.getResultCode() == Activity.RESULT_OK;
|
||||
}
|
||||
|
||||
/** Returns true if the pending intent was cancelled by the user. */
|
||||
public static boolean isCancelledResponse(
|
||||
ProviderPendingIntentResponse pendingIntentResponse) {
|
||||
return pendingIntentResponse.getResultCode() == Activity.RESULT_CANCELED;
|
||||
}
|
||||
|
||||
/** Extracts the {@link CredentialsResponseContent} object added to the result data. */
|
||||
public static CredentialsResponseContent extractResponseContent(Intent resultData) {
|
||||
if (resultData == null) {
|
||||
|
||||
@@ -263,9 +263,9 @@ public final class ProviderCreateSession extends ProviderSession<
|
||||
Log.i(TAG, "Pending intent contains provider exception");
|
||||
return exception;
|
||||
}
|
||||
} else if (PendingIntentResultHandler.isCancelledResponse(pendingIntentResponse)) {
|
||||
return new CreateCredentialException(CreateCredentialException.TYPE_USER_CANCELED);
|
||||
} else {
|
||||
Log.i(TAG, "Pending intent result code not Activity.RESULT_OK");
|
||||
// TODO("Update with unknown exception when ready")
|
||||
return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREDENTIAL);
|
||||
}
|
||||
return null;
|
||||
@@ -273,12 +273,11 @@ public final class ProviderCreateSession extends ProviderSession<
|
||||
|
||||
/**
|
||||
* When an invalid state occurs, e.g. entry mismatch or no response from provider,
|
||||
* we send back a TYPE_NO_CREDENTIAL error as to the developer, it is the same as not
|
||||
* getting any credentials back.
|
||||
* we send back a TYPE_UNKNOWN error as to the developer.
|
||||
*/
|
||||
private void invokeCallbackOnInternalInvalidState() {
|
||||
mCallbacks.onFinalErrorReceived(mComponentName,
|
||||
CreateCredentialException.TYPE_NO_CREDENTIAL,
|
||||
CreateCredentialException.TYPE_UNKNOWN,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,8 +429,9 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
|
||||
Log.i(TAG, "Pending intent contains provider exception");
|
||||
return exception;
|
||||
}
|
||||
} else if (PendingIntentResultHandler.isCancelledResponse(pendingIntentResponse)) {
|
||||
return new GetCredentialException(GetCredentialException.TYPE_USER_CANCELED);
|
||||
} else {
|
||||
Log.i(TAG, "Pending intent result code not Activity.RESULT_OK");
|
||||
return new GetCredentialException(GetCredentialException.TYPE_NO_CREDENTIAL);
|
||||
}
|
||||
return null;
|
||||
@@ -438,12 +439,10 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
|
||||
|
||||
/**
|
||||
* When an invalid state occurs, e.g. entry mismatch or no response from provider,
|
||||
* we send back a TYPE_NO_CREDENTIAL error as to the developer, it is the same as not
|
||||
* getting any credentials back.
|
||||
* we send back a TYPE_UNKNOWN error as to the developer.
|
||||
*/
|
||||
private void invokeCallbackOnInternalInvalidState() {
|
||||
mCallbacks.onFinalErrorReceived(mComponentName,
|
||||
GetCredentialException.TYPE_NO_CREDENTIAL,
|
||||
null);
|
||||
GetCredentialException.TYPE_UNKNOWN, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user