From a594510bdca5829a1422909c5230735cacba75d5 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Mon, 19 Mar 2018 17:06:16 -0700 Subject: [PATCH] Fixed Save logic so it's not triggered when field was not autofilled. Test: atest CtsAutoFillServiceTestCases:VirtualContainerActivityTest#testSaveNotShown_initialValues_noUserInput_serviceDatasets\ CtsAutoFillServiceTestCases:VirtualContainerActivityCompatModeTest#testSaveNotShown_initialValues_noUserInput_serviceDatasets Test: atest CtsAutoFillServiceTestCases Test: manual verification with Chrome in compat mode Fixes: 75333153 Change-Id: I344755ce0f5937180b4647fa47269eca5c93c980 --- .../com/android/server/autofill/Session.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 755fc54fb6d6d..7f57615163022 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -1438,11 +1438,25 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final AutofillValue filledValue = viewState.getAutofilledValue(); if (!value.equals(filledValue)) { - if (sDebug) { - Slog.d(TAG, "found a change on required " + id + ": " + filledValue - + " => " + value); + boolean changed = true; + if (filledValue == null) { + // Dataset was not autofilled, make sure initial value didn't change. + final AutofillValue initialValue = getValueFromContextsLocked(id); + if (initialValue != null && initialValue.equals(value)) { + if (sDebug) { + Slog.d(TAG, "id " + id + " is part of dataset but initial value " + + "didn't change: " + value); + } + changed = false; + } + } + if (changed) { + if (sDebug) { + Slog.d(TAG, "found a change on required " + id + ": " + filledValue + + " => " + value); + } + atLeastOneChanged = true; } - atLeastOneChanged = true; } } }