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

Commit c0f8195b authored by Felipe Leme's avatar Felipe Leme
Browse files

Moved logContextCommitted() logic to the handler...

...so it does not block showSaveUi.

Bug: 70939974
Test: atest CtsAutoFillServiceTestCases:FieldsClassificationTest

Change-Id: I64bb20c1c617790e7281f287c567cb5c13178a6e
parent 9d51240f
Loading
Loading
Loading
Loading
+35 −37
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ final class AutofillManagerServiceImpl {
            return;
        }

        session.logContextCommittedLocked();
        session.logContextCommitted();

        final boolean finished = session.showSaveLocked();
        if (sVerbose) Slog.v(TAG, "finishSessionLocked(): session finished on save? " + finished);
@@ -713,7 +713,7 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill response when an autofill context is committed.
     */
    void logContextCommitted(int sessionId, @Nullable Bundle clientState,
    void logContextCommittedLocked(int sessionId, @Nullable Bundle clientState,
            @Nullable ArrayList<String> selectedDatasets,
            @Nullable ArraySet<String> ignoredDatasets,
            @Nullable ArrayList<AutofillId> changedFieldIds,
@@ -723,7 +723,6 @@ final class AutofillManagerServiceImpl {
            @Nullable ArrayList<AutofillId> detectedFieldIdsList,
            @Nullable ArrayList<FieldClassification> detectedFieldClassificationsList,
            @NonNull String appPackageName) {
        synchronized (mLock) {
        if (isValidEventLocked("logDatasetNotSelected()", sessionId)) {
            AutofillId[] detectedFieldsIds = null;
            FieldClassification[] detectedFieldClassifications = null;
@@ -762,7 +761,6 @@ final class AutofillManagerServiceImpl {
                    detectedFieldsIds, detectedFieldClassifications));
        }
    }
    }

    /**
     * Gets the fill event history.
+14 −3
Original line number Diff line number Diff line
@@ -907,7 +907,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
     * Generates a {@link android.service.autofill.FillEventHistory.Event#TYPE_CONTEXT_COMMITTED}
     * when necessary.
     */
    public void logContextCommittedLocked() {
    public void logContextCommitted() {
        mHandlerCaller.getHandler().post(() -> {
            synchronized (mLock) {
                logContextCommittedLocked();
            }
        });
    }

    private void logContextCommittedLocked() {
        final FillResponse lastResponse = getLastResponseLocked("logContextCommited()");
        if (lastResponse == null) return;

@@ -1116,7 +1124,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            }
        }

        mService.logContextCommitted(id, mClientState, mSelectedDatasetIds, ignoredDatasets,
        mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds, ignoredDatasets,
                changedFieldIds, changedDatasetIds,
                manuallyFilledFieldIds, manuallyFilledDatasetIds,
                detectedFieldIds, detectedFieldClassifications, mComponentName.getPackageName());
@@ -1360,7 +1368,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                }

                if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
                mService.logSaveShown(id, mClientState);

                // Use handler so logContextCommitted() is logged first
                mHandlerCaller.getHandler().post(() -> mService.logSaveShown(id, mClientState));

                final IAutoFillManagerClient client = getClient();
                mPendingSaveUi = new PendingUi(mActivityToken, id, client);
                getUiForShowing().showSaveUi(mService.getServiceLabel(), mService.getServiceIcon(),