Loading services/credentials/java/com/android/server/credentials/ClearRequestSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,6 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } } // TODO: Replace with properly defined error type respondToClientWithErrorAndFinish("unknown", "All providers failed"); respondToClientWithErrorAndFinish("UNKNOWN", "All providers failed"); } } services/credentials/java/com/android/server/credentials/CreateRequestSession.java +3 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialRequest; import android.credentials.CreateCredentialResponse; import android.credentials.CredentialManager; Loading Loading @@ -98,8 +99,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR if (response != null) { respondToClientWithResponseAndFinish(response); } else { // TODO("Replace with properly defined error type) respondToClientWithErrorAndFinish("unknown_type", respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL, "Invalid response"); } } Loading @@ -113,7 +113,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR @Override public void onUiCancellation() { // TODO("Replace with properly defined error type") respondToClientWithErrorAndFinish("user_cancelled", respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL, "User cancelled the selector"); } Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +8 −5 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.credentials.ClearCredentialStateRequest; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialException; import android.credentials.GetCredentialOption; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialStateCallback; Loading Loading @@ -286,8 +288,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError(GetCredentialException.TYPE_NO_CREDENTIAL, "No credentials available on this device."); } catch (RemoteException e) { Log.i( TAG, Loading Loading @@ -331,8 +333,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError(CreateCredentialException.TYPE_NO_CREDENTIAL, "No credentials available on this device."); } catch (RemoteException e) { Log.i( TAG, Loading Loading @@ -447,7 +449,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError("UNKNOWN", "No crdentials available on this " + "device"); } catch (RemoteException e) { Log.i( TAG, Loading services/credentials/java/com/android/server/credentials/GetRequestSession.java +7 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.credentials; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.credentials.GetCredentialException; import android.credentials.GetCredentialRequest; import android.credentials.GetCredentialResponse; import android.credentials.IGetCredentialCallback; Loading Loading @@ -93,8 +94,7 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest if (response != null) { respondToClientWithResponseAndFinish(response); } else { // TODO("Replace with no credentials/unknown type when ready) respondToClientWithErrorAndFinish("unknown_type", respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "Invalid response from provider"); } } Loading @@ -108,29 +108,28 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest } private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onResponse(response); } catch (RemoteException e) { e.printStackTrace(); Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); } finishSession(); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { e.printStackTrace(); Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } finishSession(); } @Override public void onUiCancellation() { // TODO("Replace with properly defined error type") respondToClientWithErrorAndFinish("user_canceled", // TODO("Replace with user cancelled error type when ready") respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "User cancelled the selector"); } } services/credentials/java/com/android/server/credentials/ProviderCreateSession.java +18 −17 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.UserIdInt; import android.content.Context; import android.content.Intent; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialResponse; import android.credentials.ui.CreateCredentialProviderData; import android.credentials.ui.Entry; import android.credentials.ui.ProviderPendingIntentResponse; Loading Loading @@ -98,7 +99,7 @@ public final class ProviderCreateSession extends ProviderSession< private ProviderCreateSession( @NonNull Context context, @NonNull CredentialProviderInfo info, @NonNull ProviderInternalCallback callbacks, @NonNull ProviderInternalCallback<CreateCredentialResponse> callbacks, @UserIdInt int userId, @NonNull RemoteCredentialService remoteCredentialService, @NonNull BeginCreateCredentialRequest beginCreateRequest, Loading Loading @@ -180,9 +181,7 @@ public final class ProviderCreateSession extends ProviderSession< onSaveEntrySelected(providerPendingIntentResponse); } else { Log.i(TAG, "Unexpected save entry key"); // TODO("Replace with no credentials error type"); invokeCallbackWithError("unknown_type", "Issue while retrieving credential"); invokeCallbackOnInternalInvalidState(); } break; case REMOTE_ENTRY_KEY: Loading @@ -190,9 +189,7 @@ public final class ProviderCreateSession extends ProviderSession< onRemoteEntrySelected(providerPendingIntentResponse); } else { Log.i(TAG, "Unexpected remote entry key"); // TODO("Replace with unknown/no credentials exception") invokeCallbackWithError("unknown_type", "Issue while retrieving credential"); invokeCallbackOnInternalInvalidState(); } break; default: Loading Loading @@ -248,15 +245,8 @@ public final class ProviderCreateSession extends ProviderSession< } else { Log.i(TAG, "onSaveEntrySelected - no response or error found in pending " + "intent response"); invokeCallbackWithError( // TODO("Replace with unknown/no credentials exception") "unknown", "Issue encountered while retrieving the credential"); } invokeCallbackOnInternalInvalidState(); } private void invokeCallbackWithError(String errorType, @Nullable String message) { mCallbacks.onFinalErrorReceived(mComponentName, errorType, message); } @Nullable Loading @@ -264,7 +254,7 @@ public final class ProviderCreateSession extends ProviderSession< ProviderPendingIntentResponse pendingIntentResponse) { if (pendingIntentResponse == null) { Log.i(TAG, "pendingIntentResponse is null"); return null; return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREDENTIAL); } if (PendingIntentResultHandler.isValidResponse(pendingIntentResponse)) { CreateCredentialException exception = PendingIntentResultHandler Loading @@ -276,8 +266,19 @@ public final class ProviderCreateSession extends ProviderSession< } else { Log.i(TAG, "Pending intent result code not Activity.RESULT_OK"); // TODO("Update with unknown exception when ready") return new CreateCredentialException("unknown"); return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREDENTIAL); } return null; } /** * 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. */ private void invokeCallbackOnInternalInvalidState() { mCallbacks.onFinalErrorReceived(mComponentName, CreateCredentialException.TYPE_NO_CREDENTIAL, null); } } Loading
services/credentials/java/com/android/server/credentials/ClearRequestSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,6 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } } // TODO: Replace with properly defined error type respondToClientWithErrorAndFinish("unknown", "All providers failed"); respondToClientWithErrorAndFinish("UNKNOWN", "All providers failed"); } }
services/credentials/java/com/android/server/credentials/CreateRequestSession.java +3 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialRequest; import android.credentials.CreateCredentialResponse; import android.credentials.CredentialManager; Loading Loading @@ -98,8 +99,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR if (response != null) { respondToClientWithResponseAndFinish(response); } else { // TODO("Replace with properly defined error type) respondToClientWithErrorAndFinish("unknown_type", respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL, "Invalid response"); } } Loading @@ -113,7 +113,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR @Override public void onUiCancellation() { // TODO("Replace with properly defined error type") respondToClientWithErrorAndFinish("user_cancelled", respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL, "User cancelled the selector"); } Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +8 −5 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.credentials.ClearCredentialStateRequest; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialException; import android.credentials.GetCredentialOption; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialStateCallback; Loading Loading @@ -286,8 +288,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError(GetCredentialException.TYPE_NO_CREDENTIAL, "No credentials available on this device."); } catch (RemoteException e) { Log.i( TAG, Loading Loading @@ -331,8 +333,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError(CreateCredentialException.TYPE_NO_CREDENTIAL, "No credentials available on this device."); } catch (RemoteException e) { Log.i( TAG, Loading Loading @@ -447,7 +449,8 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { // TODO("Replace with properly defined error type") callback.onError("unknown_type", "No providers available to fulfill request."); callback.onError("UNKNOWN", "No crdentials available on this " + "device"); } catch (RemoteException e) { Log.i( TAG, Loading
services/credentials/java/com/android/server/credentials/GetRequestSession.java +7 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.credentials; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.credentials.GetCredentialException; import android.credentials.GetCredentialRequest; import android.credentials.GetCredentialResponse; import android.credentials.IGetCredentialCallback; Loading Loading @@ -93,8 +94,7 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest if (response != null) { respondToClientWithResponseAndFinish(response); } else { // TODO("Replace with no credentials/unknown type when ready) respondToClientWithErrorAndFinish("unknown_type", respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "Invalid response from provider"); } } Loading @@ -108,29 +108,28 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest } private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onResponse(response); } catch (RemoteException e) { e.printStackTrace(); Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); } finishSession(); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { e.printStackTrace(); Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } finishSession(); } @Override public void onUiCancellation() { // TODO("Replace with properly defined error type") respondToClientWithErrorAndFinish("user_canceled", // TODO("Replace with user cancelled error type when ready") respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "User cancelled the selector"); } }
services/credentials/java/com/android/server/credentials/ProviderCreateSession.java +18 −17 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.UserIdInt; import android.content.Context; import android.content.Intent; import android.credentials.CreateCredentialException; import android.credentials.CreateCredentialResponse; import android.credentials.ui.CreateCredentialProviderData; import android.credentials.ui.Entry; import android.credentials.ui.ProviderPendingIntentResponse; Loading Loading @@ -98,7 +99,7 @@ public final class ProviderCreateSession extends ProviderSession< private ProviderCreateSession( @NonNull Context context, @NonNull CredentialProviderInfo info, @NonNull ProviderInternalCallback callbacks, @NonNull ProviderInternalCallback<CreateCredentialResponse> callbacks, @UserIdInt int userId, @NonNull RemoteCredentialService remoteCredentialService, @NonNull BeginCreateCredentialRequest beginCreateRequest, Loading Loading @@ -180,9 +181,7 @@ public final class ProviderCreateSession extends ProviderSession< onSaveEntrySelected(providerPendingIntentResponse); } else { Log.i(TAG, "Unexpected save entry key"); // TODO("Replace with no credentials error type"); invokeCallbackWithError("unknown_type", "Issue while retrieving credential"); invokeCallbackOnInternalInvalidState(); } break; case REMOTE_ENTRY_KEY: Loading @@ -190,9 +189,7 @@ public final class ProviderCreateSession extends ProviderSession< onRemoteEntrySelected(providerPendingIntentResponse); } else { Log.i(TAG, "Unexpected remote entry key"); // TODO("Replace with unknown/no credentials exception") invokeCallbackWithError("unknown_type", "Issue while retrieving credential"); invokeCallbackOnInternalInvalidState(); } break; default: Loading Loading @@ -248,15 +245,8 @@ public final class ProviderCreateSession extends ProviderSession< } else { Log.i(TAG, "onSaveEntrySelected - no response or error found in pending " + "intent response"); invokeCallbackWithError( // TODO("Replace with unknown/no credentials exception") "unknown", "Issue encountered while retrieving the credential"); } invokeCallbackOnInternalInvalidState(); } private void invokeCallbackWithError(String errorType, @Nullable String message) { mCallbacks.onFinalErrorReceived(mComponentName, errorType, message); } @Nullable Loading @@ -264,7 +254,7 @@ public final class ProviderCreateSession extends ProviderSession< ProviderPendingIntentResponse pendingIntentResponse) { if (pendingIntentResponse == null) { Log.i(TAG, "pendingIntentResponse is null"); return null; return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREDENTIAL); } if (PendingIntentResultHandler.isValidResponse(pendingIntentResponse)) { CreateCredentialException exception = PendingIntentResultHandler Loading @@ -276,8 +266,19 @@ public final class ProviderCreateSession extends ProviderSession< } else { Log.i(TAG, "Pending intent result code not Activity.RESULT_OK"); // TODO("Update with unknown exception when ready") return new CreateCredentialException("unknown"); return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREDENTIAL); } return null; } /** * 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. */ private void invokeCallbackOnInternalInvalidState() { mCallbacks.onFinalErrorReceived(mComponentName, CreateCredentialException.TYPE_NO_CREDENTIAL, null); } }