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

Commit f04ea961 authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Remove finished sessions on ACTION_CLOSE_SYSTEM_DIALOGS." into oc-mr1-dev am: 56e5c394

am: 64a61880

Change-Id: I568c3a67d43b0a1eb1af4350f523ba291c5ea9f2
parents 7393cfe3 64a61880
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -1342,11 +1342,17 @@ public final class AutofillManager {
        }
    }

    private void setSessionFinished() {
        if (sVerbose) Log.v(TAG, "setSessionFinished()");
    /**
     * Marks the state of the session as finished.
     *
     * @param newState {@link #STATE_FINISHED} (because the autofill service returned a {@code null}
     *  FillResponse) or {@link #STATE_UNKNOWN} (because the session was removed).
     */
    private void setSessionFinished(int newState) {
        synchronized (mLock) {
            if (sVerbose) Log.v(TAG, "setSessionFinished(): from " + mState + " to " + newState);
            resetSessionLocked();
            mState = STATE_FINISHED;
            mState = newState;
        }
    }

@@ -1413,7 +1419,7 @@ public final class AutofillManager {

        if (sessionFinished) {
            // Callback call was "hijacked" to also update the session state.
            setSessionFinished();
            setSessionFinished(STATE_FINISHED);
        }
    }

@@ -1898,10 +1904,10 @@ public final class AutofillManager {
        }

        @Override
        public void setSessionFinished() {
        public void setSessionFinished(int newState) {
            final AutofillManager afm = mAfm.get();
            if (afm != null) {
                afm.post(() -> afm.setSessionFinished());
                afm.post(() -> afm.setSessionFinished(newState));
            }
        }
    }
+4 −3
Original line number Diff line number Diff line
@@ -82,8 +82,9 @@ oneway interface IAutoFillManagerClient {
   void setSaveUiState(int sessionId, boolean shown);

   /**
     * Marks the state of the session as finished (because the AutofillService returned a null
     * FillResponse).
     * Marks the state of the session as finished.
     * @param newState STATE_FINISHED (because the autofill service returned a null
     * FillResponse) or STATE_UNKNOWN (because the session was removed).
     */
   void setSessionFinished();
   void setSessionFinished(int newState);
}
+12 −0
Original line number Diff line number Diff line
@@ -120,6 +120,18 @@ public final class AutofillManagerService extends SystemService {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
                if (sDebug) Slog.d(TAG, "Close system dialogs");

                // TODO(b/64940307): we need to destroy all sessions that are finished but showing
                // Save UI because there is no way to show the Save UI back when the activity
                // beneath it is brought back to top. Ideally, we should just hide the UI and
                // bring it back when the activity resumes.
                synchronized (mLock) {
                    for (int i = 0; i < mServicesCache.size(); i++) {
                        mServicesCache.valueAt(i).destroyFinishedSessionsLocked();
                    }
                }

                mUi.hideAll(null);
            }
        }
+13 −1
Original line number Diff line number Diff line
@@ -452,7 +452,7 @@ final class AutofillManagerServiceImpl {
            final int sessionCount = mSessions.size();
            for (int i = sessionCount - 1; i >= 0; i--) {
                final Session session = mSessions.valueAt(i);
                if (session.isSaveUiPendingForToken(token)) {
                if (session.isSaveUiPendingForTokenLocked(token)) {
                    session.onPendingSaveUi(operation, token);
                    return;
                }
@@ -646,6 +646,18 @@ final class AutofillManagerServiceImpl {
        }
    }

    // TODO(b/64940307): remove this method if SaveUI is refactored to be attached on activities
    void destroyFinishedSessionsLocked() {
        final int sessionCount = mSessions.size();
        for (int i = sessionCount - 1; i >= 0; i--) {
            final Session session = mSessions.valueAt(i);
            if (session.isSavingLocked()) {
                if (sDebug) Slog.d(TAG, "destroyFinishedSessionsLocked(): " + session.id);
                session.forceRemoveSelfLocked();
            }
        }
    }

    void listSessionsLocked(ArrayList<String> output) {
        final int numSessions = mSessions.size();
        for (int i = 0; i < numSessions; i++) {
+11 −12
Original line number Diff line number Diff line
@@ -1376,7 +1376,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                if (mHasCallback) {
                    mClient.notifyNoFillUi(id, mCurrentViewId, sessionFinished);
                } else if (sessionFinished) {
                    mClient.setSessionFinished();
                    mClient.setSessionFinished(AutofillManager.STATE_FINISHED);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Error notifying client no fill UI: id=" + mCurrentViewId, e);
@@ -1795,18 +1795,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    void forceRemoveSelfLocked() {
        if (sVerbose) Slog.v(TAG, "forceRemoveSelfLocked(): " + mPendingSaveUi);

        final boolean isPendingSaveUi = isSaveUiPendingLocked();
        mPendingSaveUi = null;
        removeSelfLocked();

        mHandlerCaller.getHandler().post(() -> {
        mUi.destroyAll(mPendingSaveUi, this, false);
        if (!isPendingSaveUi) {
            try {
                mClient.setState(mService.isEnabled(), true, false);
                mClient.setSessionFinished(AutofillManager.STATE_UNKNOWN);
            } catch (RemoteException e) {
                Slog.w(TAG, "error updating client state: " + e);
                Slog.e(TAG, "Error notifying client to finish session", e);
            }
        }
        });

        mUi.destroyAll(mPendingSaveUi, this, false);
    }

    /**
@@ -1829,7 +1828,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    + id + " destroyed");
            return;
        }
        if (isSaveUiPending()) {
        if (isSaveUiPendingLocked()) {
            Slog.i(TAG, "removeSelfLocked() ignored, waiting for pending save ui");
            return;
        }
@@ -1850,14 +1849,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
     * a specific {@code token} created by
     * {@link PendingUi#PendingUi(IBinder, int, IAutoFillManagerClient)}.
     */
    boolean isSaveUiPendingForToken(@NonNull IBinder token) {
        return isSaveUiPending() && token.equals(mPendingSaveUi.getToken());
    boolean isSaveUiPendingForTokenLocked(@NonNull IBinder token) {
        return isSaveUiPendingLocked() && token.equals(mPendingSaveUi.getToken());
    }

    /**
     * Checks whether this session is hiding the Save UI to handle a custom description link.
     */
    private boolean isSaveUiPending() {
    private boolean isSaveUiPendingLocked() {
        return mPendingSaveUi != null && mPendingSaveUi.getState() == PendingUi.STATE_PENDING;
    }

+1 −1

File changed.

Contains only whitespace changes.

Loading