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

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

Removed IAutofillManager.updateOrRestartSession() logic.

On Android O, when an autofill service returned a null FillResponse the
app session would be done, unless a manual autofill request was made (and this
method was used to implement that logic).

But on Android P the workflow was improved so that when the service returns
a null FillResponse, the session remains in a "semi-dead" state where a new
server-side session is created whenever a view that hasn't been "seen" by the server yet is focused, and this new workflow makes the old logic obsolete.

Test: atest CtsAutoFillServiceTestCases

Bug: 73536867
Bug: 70046972

Change-Id: I9c819ba97b2a9a9de70e60fa9ebe433fb3b7fca8
parent 871e8864
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -1582,29 +1582,9 @@ public final class AutofillManager {
            Log.v(TAG, "updateSessionLocked(): id=" + id + ", bounds=" + bounds
                    + ", value=" + value + ", action=" + action + ", flags=" + flags);
        }
        boolean restartIfNecessary = (flags & FLAG_MANUAL_REQUEST) != 0;

        try {
            if (restartIfNecessary) {
                final AutofillClient client = getClient();
                if (client == null) return; // NOTE: getClient() already logd it..

                final int newId = mService.updateOrRestartSession(
                        client.autofillClientGetActivityToken(),
                        mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
                        mCallback != null, flags, client.autofillClientGetComponentName(),
                        mSessionId, action, isCompatibilityModeEnabledLocked());
                if (newId != mSessionId) {
                    if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId);
                    mSessionId = newId;
                    mState = (mSessionId == NO_SESSION) ? STATE_UNKNOWN : STATE_ACTIVE;
                    client.autofillClientResetableStateAvailable();
                }
            } else {
            mService.updateSession(mSessionId, id, bounds, value, action, flags,
                    mContext.getUserId());
            }

        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+0 −4
Original line number Diff line number Diff line
@@ -45,10 +45,6 @@ interface IAutoFillManager {
    boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
    void updateSession(int sessionId, in AutofillId id, in Rect bounds,
            in AutofillValue value, int action, int flags, int userId);
    int updateOrRestartSession(IBinder activityToken, in IBinder appCallback,
            in AutofillId autoFillId, in Rect bounds, in AutofillValue value, int userId,
            boolean hasCallback, int flags, in ComponentName componentName, int sessionId,
            int action, boolean compatMode);
    void setAutofillFailure(int sessionId, in List<AutofillId> ids, int userId);
    void finishSession(int sessionId, int userId);
    void cancelSession(int sessionId, int userId);
+0 −24
Original line number Diff line number Diff line
@@ -1063,30 +1063,6 @@ public final class AutofillManagerService extends SystemService {
            }
        }

        @Override
        public int updateOrRestartSession(IBinder activityToken, IBinder appCallback,
                AutofillId autoFillId, Rect bounds, AutofillValue value, int userId,
                boolean hasCallback, int flags, ComponentName componentName, int sessionId,
                int action, boolean compatMode) {
            boolean restart = false;
            synchronized (mLock) {
                final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
                if (service != null) {
                    restart = service.updateSessionLocked(sessionId, getCallingUid(), autoFillId,
                            bounds, value, action, flags);
                } else if (sVerbose) {
                    Slog.v(TAG, "updateOrRestartSession(): no service for " + userId);
                }
            }
            if (restart) {
                return startSession(activityToken, appCallback, autoFillId, bounds, value, userId,
                        hasCallback, flags, componentName, compatMode);
            }

            // Nothing changed...
            return sessionId;
        }

        @Override
        public void setAutofillFailure(int sessionId, @NonNull List<AutofillId> ids, int userId) {
            synchronized (mLock) {