diff options
6 files changed, 30 insertions, 46 deletions
diff --git a/core/java/android/service/autofill/AutofillService.java b/core/java/android/service/autofill/AutofillService.java index 269839b61bef..e6a84df16c27 100644 --- a/core/java/android/service/autofill/AutofillService.java +++ b/core/java/android/service/autofill/AutofillService.java @@ -37,6 +37,7 @@ import android.view.ViewStructure; import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager; import android.view.autofill.AutofillValue; +import android.view.autofill.IAutoFillManagerClient; import com.android.internal.os.IResultReceiver; @@ -641,7 +642,7 @@ public abstract class AutofillService extends Service { @Override public void onFillCredentialRequest(FillRequest request, IFillCallback callback, - IBinder autofillClientCallback) { + IAutoFillManagerClient autofillClientCallback) { ICancellationSignal transport = CancellationSignal.createTransport(); try { callback.onCancellable(transport); @@ -723,7 +724,7 @@ public abstract class AutofillService extends Service { */ public void onFillCredentialRequest(@NonNull FillRequest request, @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback, - @NonNull IBinder autofillClientCallback) {} + @NonNull IAutoFillManagerClient autofillClientCallback) {} /** * Called by the Android system to convert a credential manager response to a dataset diff --git a/core/java/android/service/autofill/IAutoFillService.aidl b/core/java/android/service/autofill/IAutoFillService.aidl index 3b64b8a0ec5e..2c2feae7aeea 100644 --- a/core/java/android/service/autofill/IAutoFillService.aidl +++ b/core/java/android/service/autofill/IAutoFillService.aidl @@ -16,13 +16,13 @@ package android.service.autofill; -import android.os.IBinder; import android.service.autofill.ConvertCredentialRequest; import android.service.autofill.IConvertCredentialCallback; import android.service.autofill.FillRequest; import android.service.autofill.IFillCallback; import android.service.autofill.ISaveCallback; import android.service.autofill.SaveRequest; +import android.view.autofill.IAutoFillManagerClient; import com.android.internal.os.IResultReceiver; /** @@ -34,7 +34,7 @@ oneway interface IAutoFillService { void onConnectedStateChanged(boolean connected); void onFillRequest(in FillRequest request, in IFillCallback callback); void onFillCredentialRequest(in FillRequest request, in IFillCallback callback, - in IBinder client); + in IAutoFillManagerClient client); void onSaveRequest(in SaveRequest request, in ISaveCallback callback); void onSavedPasswordCountRequest(in IResultReceiver receiver); void onConvertCredentialRequest(in ConvertCredentialRequest convertCredentialRequest, in IConvertCredentialCallback convertCredentialCallback); diff --git a/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt b/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt index 50ebdd5e3ce7..4109079e20a5 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/autofill/CredentialAutofillService.kt @@ -47,9 +47,9 @@ import android.service.autofill.SaveRequest import android.service.credentials.CredentialProviderService import android.util.Log import android.content.Intent -import android.os.IBinder import android.view.autofill.AutofillId import android.view.autofill.AutofillManager +import android.view.autofill.IAutoFillManagerClient import android.widget.RemoteViews import android.widget.inline.InlinePresentationSpec import androidx.autofill.inline.v1.InlineSuggestionUi @@ -95,7 +95,7 @@ class CredentialAutofillService : AutofillService() { request: FillRequest, cancellationSignal: CancellationSignal, callback: FillCallback, - autofillCallback: IBinder + autofillCallback: IAutoFillManagerClient ) { val context = request.fillContexts val structure = context[context.size - 1].structure @@ -160,7 +160,7 @@ class CredentialAutofillService : AutofillService() { CancellationSignal(), Executors.newSingleThreadExecutor(), outcome, - autofillCallback + autofillCallback.asBinder() ) } diff --git a/services/autofill/java/com/android/server/autofill/RemoteFillService.java b/services/autofill/java/com/android/server/autofill/RemoteFillService.java index 7ceb3bb56403..c96688c1b9ae 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteFillService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteFillService.java @@ -28,7 +28,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.os.Handler; -import android.os.IBinder; import android.os.ICancellationSignal; import android.os.RemoteException; import android.service.autofill.AutofillService; @@ -43,6 +42,7 @@ import android.service.autofill.ISaveCallback; import android.service.autofill.SaveRequest; import android.text.format.DateUtils; import android.util.Slog; +import android.view.autofill.IAutoFillManagerClient; import com.android.internal.infra.AbstractRemoteService; import com.android.internal.infra.ServiceConnector; @@ -283,7 +283,8 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> { return callback; } - public void onFillCredentialRequest(@NonNull FillRequest request, IBinder autofillCallback) { + public void onFillCredentialRequest(@NonNull FillRequest request, + IAutoFillManagerClient autofillCallback) { if (sVerbose) { Slog.v(TAG, "onFillRequest:" + request); } diff --git a/services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java b/services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java index 044a06417c00..ce9d1803d764 100644 --- a/services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java +++ b/services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java @@ -21,11 +21,11 @@ import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; import android.content.IntentSender; -import android.os.IBinder; import android.service.autofill.ConvertCredentialResponse; import android.service.autofill.FillRequest; import android.service.autofill.FillResponse; import android.util.Slog; +import android.view.autofill.IAutoFillManagerClient; /** * Requests autofill response from a Remote Autofill Service. This autofill service can be @@ -105,7 +105,8 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal /** * Requests a new fill response. */ - public void onFillRequest(FillRequest pendingFillRequest, int flag, IBinder client) { + public void onFillRequest(FillRequest pendingFillRequest, int flag, + IAutoFillManagerClient client) { Slog.v(TAG, "Requesting fill response to secondary provider."); mLastFlag = flag; if (mRemoteFillService != null && mRemoteFillService.isCredentialAutofillService()) { diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 9393c625337e..3f3ff4a46edf 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -757,14 +757,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mPendingInlineSuggestionsRequest, id); } mSecondaryProviderHandler.onFillRequest(mPendingFillRequest, - mPendingFillRequest.getFlags(), mClient.asBinder()); + mPendingFillRequest.getFlags(), mClient); } else if (mRemoteFillService != null) { if (mIsPrimaryCredential) { mPendingFillRequest = addCredentialManagerDataToClientState( mPendingFillRequest, mPendingInlineSuggestionsRequest, id); - mRemoteFillService.onFillCredentialRequest(mPendingFillRequest, - mClient.asBinder()); + mRemoteFillService.onFillCredentialRequest(mPendingFillRequest, mClient); } else { mRemoteFillService.onFillRequest(mPendingFillRequest); } @@ -2898,7 +2897,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState + ", clientState=" + newClientState + ", authenticationId=" + authenticationId); } if (Flags.autofillCredmanDevIntegration() && exception != null - && !exception.getType().equals(GetCredentialException.TYPE_USER_CANCELED)) { + && exception instanceof GetCredentialException) { if (dataset != null && dataset.getFieldIds().size() == 1) { if (sDebug) { Slog.d(TAG, "setAuthenticationResultLocked(): result returns with" @@ -6493,15 +6492,21 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } if (exception != null) { - if (viewId.isVirtualInt()) { - sendResponseToViewNode(viewId, /*response=*/ null, exception); - } else { - mClient.onGetCredentialException(id, viewId, exception.getType(), - exception.getMessage()); - } + mClient.onGetCredentialException(id, viewId, exception.getType(), + exception.getMessage()); } else if (response != null) { if (viewId.isVirtualInt()) { - sendResponseToViewNode(viewId, response, /*exception=*/ null); + ViewNode viewNode = getViewNodeFromContextsLocked(viewId); + if (viewNode != null && viewNode.getPendingCredentialCallback() != null) { + Bundle resultData = new Bundle(); + resultData.putParcelable( + CredentialProviderService.EXTRA_GET_CREDENTIAL_RESPONSE, + response); + viewNode.getPendingCredentialCallback().send(SUCCESS_CREDMAN_SELECTOR, + resultData); + } else { + Slog.w(TAG, "View node not found after GetCredentialResponse"); + } } else { mClient.onGetCredentialResponse(id, viewId, response); } @@ -6515,30 +6520,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } - @GuardedBy("mLock") - private void sendResponseToViewNode(AutofillId viewId, GetCredentialResponse response, - GetCredentialException exception) { - ViewNode viewNode = getViewNodeFromContextsLocked(viewId); - if (viewNode != null && viewNode.getPendingCredentialCallback() != null) { - Bundle resultData = new Bundle(); - if (response != null) { - resultData.putParcelable( - CredentialProviderService.EXTRA_GET_CREDENTIAL_RESPONSE, - response); - viewNode.getPendingCredentialCallback().send(SUCCESS_CREDMAN_SELECTOR, - resultData); - } else if (exception != null) { - resultData.putStringArray( - CredentialProviderService.EXTRA_GET_CREDENTIAL_EXCEPTION, - new String[] {exception.getType(), exception.getMessage()}); - viewNode.getPendingCredentialCallback().send(FAILURE_CREDMAN_SELECTOR, - resultData); - } - } else { - Slog.w(TAG, "View node not found after GetCredentialResponse"); - } - } - void autoFillApp(Dataset dataset) { synchronized (mLock) { if (mDestroyed) { |