Delete DynamicindexableContentMonitor & all refs to it

Convert input device search into a search query loader

And remove old logic from DynamicIndexableContentMonitor

Change-Id: If652b1ea7c8add9185bbd025055e14925d3a8eec
Bug: 64310452
Bug: 63831980
Test: robotests
This commit is contained in:
Fan Zhang
2017-08-02 17:32:43 -07:00
parent 0ed0319005
commit e3535d9998
30 changed files with 597 additions and 1209 deletions

View File

@@ -57,7 +57,9 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
@VisibleForTesting
static final String APP_RESULTS_LOADER_KEY = InstalledAppResultLoader.class.getName();
@VisibleForTesting
static final String ACCESSIBLITY_LOADER_KEY = AccessibilityServiceResultLoader.class.getName();
static final String ACCESSIBILITY_LOADER_KEY = AccessibilityServiceResultLoader.class.getName();
@VisibleForTesting
static final String INPUT_DEVICE_LOADER_KEY = InputDeviceResultLoader.class.getName();
@VisibleForTesting
static final int MSG_RANKING_TIMED_OUT = 1;
@@ -265,17 +267,21 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
List<? extends SearchResult> installedAppResults =
getSortedLoadedResults(APP_RESULTS_LOADER_KEY);
List<? extends SearchResult> accessibilityResults =
getSortedLoadedResults(ACCESSIBLITY_LOADER_KEY);
getSortedLoadedResults(ACCESSIBILITY_LOADER_KEY);
List<? extends SearchResult> inputDeviceResults =
getSortedLoadedResults(INPUT_DEVICE_LOADER_KEY);
int dbSize = databaseResults.size();
int appSize = installedAppResults.size();
int a11ySize = accessibilityResults.size();
int inputDeviceSize = inputDeviceResults.size();
int dbIndex = 0;
int appIndex = 0;
int a11yIndex = 0;
int inputDeviceIndex = 0;
int rank = SearchResult.TOP_RANK;
// TODO: We need a helper method to do k-way merge.
mStaticallyRankedSearchResults.clear();
while (rank <= SearchResult.BOTTOM_RANK) {
while ((dbIndex < dbSize) && (databaseResults.get(dbIndex).rank == rank)) {
@@ -287,6 +293,10 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
while ((a11yIndex < a11ySize) && (accessibilityResults.get(a11yIndex).rank == rank)) {
mStaticallyRankedSearchResults.add(accessibilityResults.get(a11yIndex++));
}
while (inputDeviceIndex < inputDeviceSize
&& inputDeviceResults.get(inputDeviceIndex).rank == rank) {
mStaticallyRankedSearchResults.add(inputDeviceResults.get(inputDeviceIndex++));
}
rank++;
}
@@ -299,6 +309,9 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
while(a11yIndex < a11ySize) {
mStaticallyRankedSearchResults.add(accessibilityResults.get(a11yIndex++));
}
while (inputDeviceIndex < inputDeviceSize) {
mStaticallyRankedSearchResults.add(inputDeviceResults.get(inputDeviceIndex++));
}
}
private void updateSearchResults() {
@@ -332,12 +345,16 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
List<? extends SearchResult> installedAppResults =
getSortedLoadedResults(APP_RESULTS_LOADER_KEY);
List<? extends SearchResult> accessibilityResults =
getSortedLoadedResults(ACCESSIBLITY_LOADER_KEY);
getSortedLoadedResults(ACCESSIBILITY_LOADER_KEY);
List<? extends SearchResult> inputDeviceResults =
getSortedLoadedResults(INPUT_DEVICE_LOADER_KEY);
int dbSize = databaseResults.size();
int appSize = installedAppResults.size();
int a11ySize = accessibilityResults.size();
int inputDeviceSize = inputDeviceResults.size();
final List<SearchResult> asyncRankingResults = new ArrayList<>(dbSize + appSize + a11ySize);
final List<SearchResult> asyncRankingResults = new ArrayList<>(
dbSize + appSize + a11ySize + inputDeviceSize);
TreeSet<SearchResult> dbResultsSortedByScores = new TreeSet<>(
new Comparator<SearchResult>() {
@Override
@@ -358,13 +375,13 @@ public class SearchResultsAdapter extends RecyclerView.Adapter<SearchViewHolder>
// Other results are not ranked by async ranking and appended at the end of the list.
asyncRankingResults.addAll(installedAppResults);
asyncRankingResults.addAll(accessibilityResults);
asyncRankingResults.addAll(inputDeviceResults);
return asyncRankingResults;
}
@VisibleForTesting
Set<? extends SearchResult> getUnsortedLoadedResults(String loaderKey) {
return mResultsMap.containsKey(loaderKey) ?
mResultsMap.get(loaderKey) : new HashSet<SearchResult>();
return mResultsMap.containsKey(loaderKey) ? mResultsMap.get(loaderKey) : new HashSet<>();
}
@VisibleForTesting