Add Indexable.SearchIndexProvider.getNonIndexableKeys(Context)

- getNonIndexableKeys(Context) allow a SearchIndexProvider to tell which data
he does not want to index by providing a list of the data keys
- use this new API for SoundSettings and removing KEY_EMERGENCY_TONE related
settings if the device is not CDMA
- add a BaseSearchIndexProvider for code simplification

Change-Id: I23633ace1d7e390ee05fac0a5458a33e04e72d8d
diff --git a/src/com/android/settings/SoundSettings.java b/src/com/android/settings/SoundSettings.java
index 45fd0db..49928f5 100644
--- a/src/com/android/settings/SoundSettings.java
+++ b/src/com/android/settings/SoundSettings.java
@@ -47,11 +47,14 @@
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 import android.util.Log;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class SoundSettings extends SettingsPreferenceFragment implements
-        Preference.OnPreferenceChangeListener {
+        Preference.OnPreferenceChangeListener, Indexable {
     private static final String TAG = "SoundSettings";
 
     private static final int DIALOG_NOT_DOCKED = 1;
@@ -446,5 +449,23 @@
         ab.setPositiveButton(android.R.string.ok, null);
         return ab.create();
     }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+        new BaseSearchIndexProvider() {
+            @Override
+            public List<String> getNonIndexableKeys(Context context) {
+                final List<String> keys = new ArrayList<String>();
+
+                int activePhoneType = TelephonyManager.getDefault().getCurrentPhoneType();
+
+                if (TelephonyManager.PHONE_TYPE_CDMA != activePhoneType) {
+                    // device is not CDMA, do not display CDMA emergency_tone
+                    keys.add(KEY_EMERGENCY_TONE);
+                }
+
+                return keys;
+            }
+        };
+
 }