Loading services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java +1 −11 Original line number Diff line number Diff line Loading @@ -25,9 +25,6 @@ import android.service.autofill.FillRequest; import android.service.autofill.FillResponse; import android.util.Slog; import java.util.Objects; /** * Requests autofill response from a Remote Autofill Service. This autofill service can be * either a Credential Autofill Service or the user-opted autofill service. Loading @@ -51,7 +48,6 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal private final RemoteFillService mRemoteFillService; private final SecondaryProviderCallback mCallback; private FillRequest mLastFillRequest; private int mLastFlag; SecondaryProviderHandler( Loading Loading @@ -97,17 +93,11 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal } /** * Requests a new fill response. If the fill request is same as the last requested fill request, * then the request is duped. * Requests a new fill response. */ public void onFillRequest(FillRequest pendingFillRequest, int flag) { if (Objects.equals(pendingFillRequest, mLastFillRequest)) { Slog.v(TAG, "Deduping fill request to secondary provider."); return; } Slog.v(TAG, "Requesting fill response to secondary provider."); mLastFlag = flag; mLastFillRequest = pendingFillRequest; mRemoteFillService.onFillRequest(pendingFillRequest); } Loading services/autofill/java/com/android/server/autofill/Session.java +41 −13 Original line number Diff line number Diff line Loading @@ -367,6 +367,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private SparseArray<FillResponse> mResponses; @GuardedBy("mLock") private SparseArray<FillResponse> mSecondaryResponses; /** * Contexts read from the app; they will be updated (sanitized, change values for save) before * sent to {@link AutofillService}. Ordered by the time they were read. Loading Loading @@ -713,7 +716,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mPendingFillRequest.getDelayedFillIntentSender()); } mLastFillRequest = mPendingFillRequest; if (shouldRequestSecondaryProvider(mPendingFillRequest.getFlags()) && mSecondaryProviderHandler != null) { Slog.v(TAG, "Requesting fill response to secondary provider."); mSecondaryProviderHandler.onFillRequest(mPendingFillRequest, mPendingFillRequest.getFlags()); } else if (mRemoteFillService != null) { mRemoteFillService.onFillRequest(mPendingFillRequest); } mPendingInlineSuggestionsRequest = null; mWaitForInlineRequest = false; mPendingFillRequest = null; Loading Loading @@ -1196,7 +1206,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private void requestNewFillResponseLocked(@NonNull ViewState viewState, int newState, int flags) { final FillResponse existingResponse = viewState.getResponse(); final FillResponse existingResponse = shouldRequestSecondaryProvider(flags) ? viewState.getSecondaryResponse() : viewState.getResponse(); mFillRequestEventLogger.startLogForNewRequest(); mRequestCount++; mFillRequestEventLogger.maybeSetAppPackageUid(uid); Loading Loading @@ -1804,6 +1815,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } synchronized (mLock) { if (mSecondaryResponses == null) { mSecondaryResponses = new SparseArray<>(2); } mSecondaryResponses.put(fillResponse.getRequestId(), fillResponse); setViewStatesLocked(fillResponse, ViewState.STATE_FILLABLE, /* clearResponse= */ false, /* isPrimary= */ false); Loading Loading @@ -3980,7 +3995,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // If it's not, then check if it should start a partition. if (shouldStartNewPartitionLocked(id)) { if (shouldStartNewPartitionLocked(id, flags)) { if (sDebug) { Slog.d(TAG, "Starting partition or augmented request for view id " + id + ": " + viewState.getStateAsString()); Loading Loading @@ -4008,9 +4023,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * @return {@code true} if a new partition should be started */ @GuardedBy("mLock") private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id) { private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id, int flags) { final ViewState currentView = mViewStates.get(id); if (mResponses == null) { SparseArray<FillResponse> responses = shouldRequestSecondaryProvider(flags) ? mSecondaryResponses : mResponses; if (responses == null) { return currentView != null && (currentView.getState() & ViewState.STATE_PENDING_CREATE_INLINE_REQUEST) == 0; } Loading @@ -4022,7 +4039,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return true; } final int numResponses = mResponses.size(); final int numResponses = responses.size(); if (numResponses >= AutofillManagerService.getPartitionMaxCount()) { Slog.e(TAG, "Not starting a new partition on " + id + " because session " + this.id + " reached maximum of " + AutofillManagerService.getPartitionMaxCount()); Loading @@ -4030,7 +4047,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } for (int responseNum = 0; responseNum < numResponses; responseNum++) { final FillResponse response = mResponses.valueAt(responseNum); final FillResponse response = responses.valueAt(responseNum); if (ArrayUtils.contains(response.getIgnoredIds(), id)) { return false; Loading Loading @@ -4066,6 +4083,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } boolean shouldRequestSecondaryProvider(int flags) { if (!mService.isAutofillCredmanIntegrationEnabled() || mSecondaryProviderHandler == null) { return false; } if (mIsPrimaryCredential) { return (flags & FLAG_VIEW_REQUESTS_CREDMAN_SERVICE) == 0; } else { Loading Loading @@ -4205,12 +4226,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } break; case ACTION_VIEW_ENTERED: if (shouldRequestSecondaryProvider(flags) && mSecondaryProviderHandler != null && mAssistReceiver.mLastFillRequest != null) { mSecondaryProviderHandler.onFillRequest(mAssistReceiver.mLastFillRequest, flags); } mLatencyBaseTime = SystemClock.elapsedRealtime(); boolean wasPreviouslyFillDialog = mPreviouslyFillDialogPotentiallyStarted; mPreviouslyFillDialogPotentiallyStarted = false; Loading @@ -4225,6 +4240,19 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState viewState.setCurrentValue(value); } if (shouldRequestSecondaryProvider(flags)) { if (requestNewFillResponseOnViewEnteredIfNecessaryLocked( id, viewState, flags)) { Slog.v(TAG, "Started a new fill request for secondary provider."); return; } // If the ViewState is ready to be displayed, onReady() will be called. viewState.update(value, virtualBounds, flags); // return here because primary provider logic is not applicable. return; } if (mCompatMode && (viewState.getState() & ViewState.STATE_URL_BAR) != 0) { if (sDebug) Slog.d(TAG, "Ignoring VIEW_ENTERED on URL BAR (id=" + id + ")"); return; Loading services/autofill/java/com/android/server/autofill/ViewState.java +5 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,11 @@ final class ViewState { return mPrimaryFillResponse; } @Nullable FillResponse getSecondaryResponse() { return mSecondaryFillResponse; } void setResponse(FillResponse response) { setResponse(response, /* isPrimary= */ true); } Loading Loading
services/autofill/java/com/android/server/autofill/SecondaryProviderHandler.java +1 −11 Original line number Diff line number Diff line Loading @@ -25,9 +25,6 @@ import android.service.autofill.FillRequest; import android.service.autofill.FillResponse; import android.util.Slog; import java.util.Objects; /** * Requests autofill response from a Remote Autofill Service. This autofill service can be * either a Credential Autofill Service or the user-opted autofill service. Loading @@ -51,7 +48,6 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal private final RemoteFillService mRemoteFillService; private final SecondaryProviderCallback mCallback; private FillRequest mLastFillRequest; private int mLastFlag; SecondaryProviderHandler( Loading Loading @@ -97,17 +93,11 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal } /** * Requests a new fill response. If the fill request is same as the last requested fill request, * then the request is duped. * Requests a new fill response. */ public void onFillRequest(FillRequest pendingFillRequest, int flag) { if (Objects.equals(pendingFillRequest, mLastFillRequest)) { Slog.v(TAG, "Deduping fill request to secondary provider."); return; } Slog.v(TAG, "Requesting fill response to secondary provider."); mLastFlag = flag; mLastFillRequest = pendingFillRequest; mRemoteFillService.onFillRequest(pendingFillRequest); } Loading
services/autofill/java/com/android/server/autofill/Session.java +41 −13 Original line number Diff line number Diff line Loading @@ -367,6 +367,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private SparseArray<FillResponse> mResponses; @GuardedBy("mLock") private SparseArray<FillResponse> mSecondaryResponses; /** * Contexts read from the app; they will be updated (sanitized, change values for save) before * sent to {@link AutofillService}. Ordered by the time they were read. Loading Loading @@ -713,7 +716,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mPendingFillRequest.getDelayedFillIntentSender()); } mLastFillRequest = mPendingFillRequest; if (shouldRequestSecondaryProvider(mPendingFillRequest.getFlags()) && mSecondaryProviderHandler != null) { Slog.v(TAG, "Requesting fill response to secondary provider."); mSecondaryProviderHandler.onFillRequest(mPendingFillRequest, mPendingFillRequest.getFlags()); } else if (mRemoteFillService != null) { mRemoteFillService.onFillRequest(mPendingFillRequest); } mPendingInlineSuggestionsRequest = null; mWaitForInlineRequest = false; mPendingFillRequest = null; Loading Loading @@ -1196,7 +1206,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState @GuardedBy("mLock") private void requestNewFillResponseLocked(@NonNull ViewState viewState, int newState, int flags) { final FillResponse existingResponse = viewState.getResponse(); final FillResponse existingResponse = shouldRequestSecondaryProvider(flags) ? viewState.getSecondaryResponse() : viewState.getResponse(); mFillRequestEventLogger.startLogForNewRequest(); mRequestCount++; mFillRequestEventLogger.maybeSetAppPackageUid(uid); Loading Loading @@ -1804,6 +1815,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } synchronized (mLock) { if (mSecondaryResponses == null) { mSecondaryResponses = new SparseArray<>(2); } mSecondaryResponses.put(fillResponse.getRequestId(), fillResponse); setViewStatesLocked(fillResponse, ViewState.STATE_FILLABLE, /* clearResponse= */ false, /* isPrimary= */ false); Loading Loading @@ -3980,7 +3995,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } // If it's not, then check if it should start a partition. if (shouldStartNewPartitionLocked(id)) { if (shouldStartNewPartitionLocked(id, flags)) { if (sDebug) { Slog.d(TAG, "Starting partition or augmented request for view id " + id + ": " + viewState.getStateAsString()); Loading Loading @@ -4008,9 +4023,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState * @return {@code true} if a new partition should be started */ @GuardedBy("mLock") private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id) { private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id, int flags) { final ViewState currentView = mViewStates.get(id); if (mResponses == null) { SparseArray<FillResponse> responses = shouldRequestSecondaryProvider(flags) ? mSecondaryResponses : mResponses; if (responses == null) { return currentView != null && (currentView.getState() & ViewState.STATE_PENDING_CREATE_INLINE_REQUEST) == 0; } Loading @@ -4022,7 +4039,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return true; } final int numResponses = mResponses.size(); final int numResponses = responses.size(); if (numResponses >= AutofillManagerService.getPartitionMaxCount()) { Slog.e(TAG, "Not starting a new partition on " + id + " because session " + this.id + " reached maximum of " + AutofillManagerService.getPartitionMaxCount()); Loading @@ -4030,7 +4047,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } for (int responseNum = 0; responseNum < numResponses; responseNum++) { final FillResponse response = mResponses.valueAt(responseNum); final FillResponse response = responses.valueAt(responseNum); if (ArrayUtils.contains(response.getIgnoredIds(), id)) { return false; Loading Loading @@ -4066,6 +4083,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } boolean shouldRequestSecondaryProvider(int flags) { if (!mService.isAutofillCredmanIntegrationEnabled() || mSecondaryProviderHandler == null) { return false; } if (mIsPrimaryCredential) { return (flags & FLAG_VIEW_REQUESTS_CREDMAN_SERVICE) == 0; } else { Loading Loading @@ -4205,12 +4226,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } break; case ACTION_VIEW_ENTERED: if (shouldRequestSecondaryProvider(flags) && mSecondaryProviderHandler != null && mAssistReceiver.mLastFillRequest != null) { mSecondaryProviderHandler.onFillRequest(mAssistReceiver.mLastFillRequest, flags); } mLatencyBaseTime = SystemClock.elapsedRealtime(); boolean wasPreviouslyFillDialog = mPreviouslyFillDialogPotentiallyStarted; mPreviouslyFillDialogPotentiallyStarted = false; Loading @@ -4225,6 +4240,19 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState viewState.setCurrentValue(value); } if (shouldRequestSecondaryProvider(flags)) { if (requestNewFillResponseOnViewEnteredIfNecessaryLocked( id, viewState, flags)) { Slog.v(TAG, "Started a new fill request for secondary provider."); return; } // If the ViewState is ready to be displayed, onReady() will be called. viewState.update(value, virtualBounds, flags); // return here because primary provider logic is not applicable. return; } if (mCompatMode && (viewState.getState() & ViewState.STATE_URL_BAR) != 0) { if (sDebug) Slog.d(TAG, "Ignoring VIEW_ENTERED on URL BAR (id=" + id + ")"); return; Loading
services/autofill/java/com/android/server/autofill/ViewState.java +5 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,11 @@ final class ViewState { return mPrimaryFillResponse; } @Nullable FillResponse getSecondaryResponse() { return mSecondaryFillResponse; } void setResponse(FillResponse response) { setResponse(response, /* isPrimary= */ true); } Loading