Remove search indexing pipeline from Settings

Index is already handled by SettingsIntelligenec. No longer needed in
Settings.

Change-Id: Id43fb3100dc2759185744441cff8cb9cd2d2da20
Fixes: 69808376
Test: robotests
This commit is contained in:
Fan Zhang
2018-06-20 14:02:56 -07:00
parent 8691fed1cb
commit 7431c91de6
56 changed files with 42 additions and 4625 deletions

View File

@@ -17,23 +17,9 @@
package com.android.settings.search;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.ArrayMap;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.AbstractPreferenceController;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
/**
* Utility class for {@like DatabaseIndexingManager} to handle the mapping between Payloads
@@ -46,96 +32,6 @@ public class DatabaseIndexingUtils {
public static final String FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER =
"SEARCH_INDEX_DATA_PROVIDER";
/**
* Builds intent that launches the search destination as a sub-setting.
*/
public static Intent buildSearchResultPageIntent(Context context, String className, String key,
String screenTitle) {
return buildSearchResultPageIntent(context, className, key, screenTitle,
MetricsProto.MetricsEvent.DASHBOARD_SEARCH_RESULTS);
}
public static Intent buildSearchResultPageIntent(Context context, String className, String key,
String screenTitle, int sourceMetricsCategory) {
final Bundle args = new Bundle();
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
final Intent searchDestination = new SubSettingLauncher(context)
.setDestination(className)
.setArguments(args)
.setTitleText(screenTitle)
.setSourceMetricsCategory(sourceMetricsCategory)
.toIntent();
searchDestination.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key)
.setAction("com.android.settings.SEARCH_RESULT_TRAMPOLINE")
.setComponent(null);
return searchDestination;
}
/**
* @param className which wil provide the map between from {@link Uri}s to
* {@link PreferenceControllerMixin}
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
public static Map<String, ResultPayload> getPayloadKeyMap(String className, Context context) {
ArrayMap<String, ResultPayload> map = new ArrayMap<>();
if (context == null) {
return map;
}
final Class<?> clazz = getIndexableClass(className);
if (clazz == null) {
Log.d(TAG, "SearchIndexableResource '" + className +
"' should implement the " + Indexable.class.getName() + " interface!");
return map;
}
// Will be non null only for a Local provider implementing a
// SEARCH_INDEX_DATA_PROVIDER field
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(clazz);
final List<AbstractPreferenceController> controllers =
provider.getPreferenceControllers(context);
if (controllers == null) {
return map;
}
for (AbstractPreferenceController controller : controllers) {
ResultPayload payload;
if (controller instanceof PreferenceControllerMixin) {
payload = ((PreferenceControllerMixin) controller).getResultPayload();
} else if (controller instanceof BasePreferenceController) {
payload = ((BasePreferenceController) controller).getResultPayload();
} else {
throw new IllegalStateException(controller.getClass().getName()
+ " must implement " + PreferenceControllerMixin.class.getName());
}
if (payload != null) {
map.put(controller.getPreferenceKey(), payload);
}
}
return map;
}
public static Class<?> getIndexableClass(String className) {
final Class<?> clazz;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
Log.d(TAG, "Cannot find class: " + className);
return null;
}
return isIndexableClass(clazz) ? clazz : null;
}
public static boolean isIndexableClass(final Class<?> clazz) {
return (clazz != null) && Indexable.class.isAssignableFrom(clazz);
}
public static Indexable.SearchIndexProvider getSearchIndexProvider(final Class<?> clazz) {
try {
final Field f = clazz.getField(FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER);