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

Commit 6d24c30d authored by Felipe Leme's avatar Felipe Leme
Browse files

Don't trigger new partition on fields from SaveInfo

Fixes: 37551943

Test: existing CtsAutoFillServiceTestCases pass
Test: modified LoginActivityTest.testSaveOnly
Test: new LoginActivityTest.testSaveOnlyOptionalField

Change-Id: I2ae11c4f0aebe63fd02f81fbc37466435e3a2820
parent f9db6d3b
Loading
Loading
Loading
Loading
+34 −14
Original line number Diff line number Diff line
@@ -839,6 +839,21 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                setViewStatesLocked(response, dataset, state);
            }
        }
        final SaveInfo saveInfo = response.getSaveInfo();
        if (saveInfo != null) {
            final AutofillId[] requiredIds = saveInfo.getRequiredIds();
            for (int i = 0; i < requiredIds.length; i++) {
                final AutofillId id = requiredIds[i];
                createOrUpdateViewStateLocked(id, state, null);
            }
            final AutofillId[] optionalIds = saveInfo.getOptionalIds();
            if (optionalIds != null) {
                for (int i = 0; i < optionalIds.length; i++) {
                    final AutofillId id = optionalIds[i];
                    createOrUpdateViewStateLocked(id, state, null);
                }
            }
        }
    }

    /**
@@ -850,6 +865,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        final ArrayList<AutofillValue> values = dataset.getFieldValues();
        for (int j = 0; j < ids.size(); j++) {
            final AutofillId id = ids.get(j);
            final AutofillValue value = values.get(j);
            final ViewState viewState = createOrUpdateViewStateLocked(id, state, value);
            if (response != null) {
                viewState.setResponse(response);
            }
        }
    }

    private ViewState createOrUpdateViewStateLocked(AutofillId id, int state,AutofillValue value) {
        ViewState viewState = mViewStates.get(id);
        if (viewState != null)  {
            viewState.setState(state);
@@ -861,13 +885,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mViewStates.put(id, viewState);
        }
        if ((state & ViewState.STATE_AUTOFILLED) != 0) {
                viewState.setAutofilledValue(values.get(j));
            }

            if (response != null) {
                viewState.setResponse(response);
            }
            viewState.setAutofilledValue(value);
        }
        return viewState;
    }

    /**