Fix indexing in cast and zen mode settings

- Fragment should either not implement serach provider or return a valid
  xml. Search provider with 0 resource is invalid.

Change-Id: Ie87c739bf72c926cecf48d271c6c2d72459787c4
Fixes: 69864274
Test: robotests
This commit is contained in:
Fan Zhang
2017-11-28 16:52:53 -08:00
parent 6a68f306d7
commit 1ae1e17199
9 changed files with 108 additions and 55 deletions

View File

@@ -36,7 +36,7 @@ import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.ServiceManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference;
@@ -63,6 +63,11 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import java.util.ArrayList;
import java.util.List;
/**
* The Settings screen for WifiDisplay configuration and connection management.
@@ -72,7 +77,7 @@ import com.android.settings.dashboard.SummaryLoader;
* on the system. In that case, the enable option will not be shown but other
* remote display routes will continue to be made available.
*/
public final class WifiDisplaySettings extends SettingsPreferenceFragment {
public final class WifiDisplaySettings extends SettingsPreferenceFragment implements Indexable {
private static final String TAG = "WifiDisplaySettings";
private static final boolean DEBUG = false;
@@ -823,4 +828,18 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
= (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader);
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.wifi_display_settings;
result.add(sir);
return result;
}
};
}