diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 70aff057c9ab1..e19ef1074ebf8 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -189,6 +189,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -1780,11 +1781,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState */ private static class DatasetComputationContainer { // List of all autofill ids that have a corresponding datasets - Set mAutofillIds = new ArraySet<>(); + Set mAutofillIds = new LinkedHashSet<>(); // Set of datasets. Kept separately, to be able to be used directly for composing // FillResponse. Set mDatasets = new LinkedHashSet<>(); - ArrayMap> mAutofillIdToDatasetMap = new ArrayMap<>(); + Map> mAutofillIdToDatasetMap = new LinkedHashMap<>(); public String toString() { final StringBuilder builder = new StringBuilder("DatasetComputationContainer["); @@ -1822,7 +1823,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // for now to keep safe. TODO(b/266379948): Revisit this logic. Set datasets = c2.mAutofillIdToDatasetMap.get(id); - Set copyDatasets = new ArraySet<>(datasets); + Set copyDatasets = new LinkedHashSet<>(datasets); c1.mAutofillIds.add(id); c1.mAutofillIdToDatasetMap.put(id, copyDatasets); c1.mDatasets.addAll(copyDatasets); @@ -1849,9 +1850,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } List datasets = response.getDatasets(); if (datasets == null) return; - ArrayMap> autofillIdToDatasetMap = new ArrayMap<>(); + Map> autofillIdToDatasetMap = new LinkedHashMap<>(); Set eligibleDatasets = new LinkedHashSet<>(); - Set eligibleAutofillIds = new ArraySet<>(); + Set eligibleAutofillIds = new LinkedHashSet<>(); for (Dataset dataset : response.getDatasets()) { if (dataset.getFieldIds() == null || dataset.getFieldIds().isEmpty()) continue; @DatasetEligibleReason int pickReason = globalPickReason; @@ -1927,7 +1928,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState eligibleAutofillIds.add(id); Set datasetForIds = autofillIdToDatasetMap.get(id); if (datasetForIds == null) { - datasetForIds = new ArraySet<>(); + datasetForIds = new LinkedHashSet<>(); } datasetForIds.add(dataset); autofillIdToDatasetMap.put(id, datasetForIds); @@ -1944,17 +1945,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (datasets == null) return; synchronized (mLock) { - ArrayMap> hintsToAutofillIdMap = + Map> hintsToAutofillIdMap = mClassificationState.mHintsToAutofillIdMap; // TODO(266379948): Handle group hints too. - ArrayMap> groupHintsToAutofillIdMap = + Map> groupHintsToAutofillIdMap = mClassificationState.mGroupHintsToAutofillIdMap; - ArrayMap> map = new ArrayMap<>(); + Map> map = new LinkedHashMap<>(); Set eligibleDatasets = new LinkedHashSet<>(); - Set eligibleAutofillIds = new ArraySet<>(); + Set eligibleAutofillIds = new LinkedHashSet<>(); for (int i = 0; i < datasets.size(); i++) { @@ -1970,7 +1971,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState ArrayList fieldInlinePresentations = new ArrayList<>(); ArrayList fieldInlineTooltipPresentations = new ArrayList<>(); ArrayList fieldFilters = new ArrayList<>(); - Set datasetAutofillIds = new ArraySet<>(); + Set datasetAutofillIds = new LinkedHashSet<>(); for (int j = 0; j < dataset.getAutofillDatatypes().size(); j++) { if (dataset.getAutofillDatatypes().get(j) == null) { @@ -2032,7 +2033,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (map.containsKey(autofillId)) { newDatasets = map.get(autofillId); } else { - newDatasets = new ArraySet<>(); + newDatasets = new LinkedHashSet<>(); } newDatasets.add(newDataset); map.put(autofillId, newDatasets);