From 2ec78636f75964a48be5e95fe9b7e71f2270f917 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Fri, 25 Jul 2014 16:28:53 -0700 Subject: [PATCH] Implement #15841213 Search - index Developer Option only and only if they have been activated - do not index Developer Options if they are not activated - index them just after their activation Change-Id: I54fcc6b55a1f29eb6b19d6e14e3158d4a38a6fe6 --- .../android/settings/DevelopmentSettings.java | 17 +++++++++++++++++ .../android/settings/DeviceInfoSettings.java | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index c7d945dd85a..60116da96c8 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -1586,9 +1586,22 @@ public class DevelopmentSettings extends SettingsPreferenceFragment */ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { + + private boolean isShowingDeveloperOptions(Context context) { + return context.getSharedPreferences(DevelopmentSettings.PREF_FILE, + Context.MODE_PRIVATE).getBoolean( + DevelopmentSettings.PREF_SHOW, + android.os.Build.TYPE.equals("eng")); + } + @Override public List getXmlResourcesToIndex( Context context, boolean enabled) { + + if (!isShowingDeveloperOptions(context)) { + return null; + } + final SearchIndexableResource sir = new SearchIndexableResource(context); sir.xmlResId = R.xml.development_prefs; return Arrays.asList(sir); @@ -1596,6 +1609,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment @Override public List getNonIndexableKeys(Context context) { + if (!isShowingDeveloperOptions(context)) { + return null; + } + final List keys = new ArrayList(); if (!showEnableOemUnlockPreference()) { keys.add(ENABLE_OEM_UNLOCK); diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index c26e4abd1c4..b6d8fefe847 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -41,6 +41,7 @@ import android.text.TextUtils; import android.util.Log; import android.widget.Toast; import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Index; import com.android.settings.search.Indexable; import java.io.BufferedReader; @@ -212,6 +213,11 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, Toast.LENGTH_LONG); mDevHitToast.show(); + // This is good time to index the Developer Options + Index.getInstance( + getActivity().getApplicationContext()).updateFromClassNameResource( + DevelopmentSettings.class.getName(), true, true); + } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER-2)) { if (mDevHitToast != null) {