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

Commit 411dfaa2 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Clean augmented-only autofill sessions when augmented service changes."

parents e5824b8a 6a02213f
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -1051,6 +1051,14 @@ final class AutofillManagerServiceImpl
        }
    }

    @GuardedBy("mLock")
    void destroySessionsForAugmentedAutofillOnlyLocked() {
        final int sessionCount = mSessions.size();
        for (int i = sessionCount - 1; i >= 0; i--) {
            mSessions.valueAt(i).forceRemoveSelfIfForAugmentedAutofillOnlyLocked();
        }
    }

    // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities
    @GuardedBy("mLock")
    void destroyFinishedSessionsLocked() {
@@ -1070,9 +1078,18 @@ final class AutofillManagerServiceImpl
    @GuardedBy("mLock")
    void listSessionsLocked(ArrayList<String> output) {
        final int numSessions = mSessions.size();
        if (numSessions <= 0) return;

        final String fmt = "%d:%s:%s";
        for (int i = 0; i < numSessions; i++) {
            output.add((mInfo != null ? mInfo.getServiceInfo().getComponentName()
                    : null) + ":" + mSessions.keyAt(i));
            final int id = mSessions.keyAt(i);
            final String service = mInfo == null
                    ? "no_svc"
                    : mInfo.getServiceInfo().getComponentName().flattenToShortString();
            final String augmentedService = mRemoteAugmentedAutofillServiceInfo == null
                    ? "no_aug"
                    : mRemoteAugmentedAutofillServiceInfo.getComponentName().flattenToShortString();
            output.add(String.format(fmt, id, service, augmentedService));
        }
    }

@@ -1136,6 +1153,7 @@ final class AutofillManagerServiceImpl
                    Slog.v(TAG, "updateRemoteAugmentedAutofillService(): "
                            + "destroying old remote service");
                }
                destroySessionsForAugmentedAutofillOnlyLocked();
                mRemoteAugmentedAutofillService.unbind();
                mRemoteAugmentedAutofillService = null;
                mRemoteAugmentedAutofillServiceInfo = null;
+11 −0
Original line number Diff line number Diff line
@@ -3260,6 +3260,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        forceRemoveSelfLocked(AutofillManager.STATE_UNKNOWN);
    }

    @GuardedBy("mLock")
    void forceRemoveSelfIfForAugmentedAutofillOnlyLocked() {
        if (sVerbose) {
            Slog.v(TAG, "forceRemoveSelfIfForAugmentedAutofillOnly(" + this.id + "): "
                    + mForAugmentedAutofillOnly);
        }
        if (!mForAugmentedAutofillOnly) return;

        forceRemoveSelfLocked();
    }

    @GuardedBy("mLock")
    void forceRemoveSelfLocked(int clientState) {
        if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi);