Files
packages_apps_Settings/src/com/android/settings/search/indexing/PreIndexData.java
Matthew Fritze bdc8fe6da9 Separate collection of indexable data from indexing
The first step in refactoring the god class,
DatabaseIndexingManager.

The class has one major entry point: indexDatabase
which begins a chain of calls that first collects all the
data from the fragments, and then massages that data into
the SQLite database. Unfortunately, most of the methods
do not return data, and just pass along some mutated
form of the data until it can be insterted.

Reading and testing this class is very difficult.

This first step moves the collection of the indexable data
into a new class which has a few benefits:
- The data can be easily mocked in tests
- Reduces complexity of D.I.M.
- Separates data collection from indexing, which allows the
indexable data to be piped into a new API that unbundled
search can consume.

Bug:33577327
Test: make RunSettingsRoboTests
Test: Grabbed a DB dump before change, compared to DB dump after change
to make sure everything is still indexed.
Change-Id: Ibc91e3d75ff5dcf5274b93b29bf3544f90b2194d
2017-09-07 08:53:41 -07:00

56 lines
1.5 KiB
Java

/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.android.settings.search.indexing;
import android.provider.SearchIndexableData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Holds Data sources for indexable data.
* TODO (b/33577327) add getters and setters for data.
*/
public class PreIndexData {
public List<SearchIndexableData> dataToUpdate;
public Map<String, Set<String>> nonIndexableKeys;
public PreIndexData() {
dataToUpdate = new ArrayList<>();
nonIndexableKeys = new HashMap<>();
}
public PreIndexData(PreIndexData other) {
dataToUpdate = new ArrayList<>(other.dataToUpdate);
nonIndexableKeys = new HashMap<>(other.nonIndexableKeys);
}
public PreIndexData copy() {
return new PreIndexData(this);
}
public void clear() {
dataToUpdate.clear();
nonIndexableKeys.clear();
}
}