Turn new suggestion sources off by default. The user will have to turn them
on explicitly in settings.
Also change to a resource for the list of default trusted sources. These will
stay on by default.
diff --git a/res/values/trusted_search_providers.xml b/res/values/trusted_search_providers.xml
new file mode 100644
index 0000000..f9e78e2
--- /dev/null
+++ b/res/values/trusted_search_providers.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!--
+The string array below lists package names which we trust by default as
+'promoted' search providers in global search. Packages in this list will
+be capable of being promoted to the top list of results, even before the
+user has interacted with them.
+-->
+<resources>
+ <string-array name="trusted_search_providers">
+ <item>com.android.contacts</item>
+ <item>com.android.browser</item>
+ <item>com.android.providers.applications</item>
+ </string-array>
+</resources>
diff --git a/src/com/android/globalsearch/SuggestionSources.java b/src/com/android/globalsearch/SuggestionSources.java
index 18956bd..3bf70e4 100644
--- a/src/com/android/globalsearch/SuggestionSources.java
+++ b/src/com/android/globalsearch/SuggestionSources.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.res.Resources;
import android.database.ContentObserver;
import android.os.Handler;
import android.provider.Settings;
@@ -127,10 +128,10 @@
}
/**
- * Checks whether a suggestion source is enabled by default.
+ * Checks whether a suggestion source is enabled by default. For now, only trusted sources are.
*/
public boolean isSourceDefaultEnabled(SuggestionSource source) {
- return true; // TODO: get from source?
+ return isTrustedSource(source);
}
/** {@inheritDoc} */
@@ -216,12 +217,15 @@
mLoaded = false;
}
- // TODO: should get this form a resource file, to allow vendor overlays
private void loadTrustedPackages() {
+ // Get the list of trusted packages from a resource, which allows vendor overlays.
+ String[] trustedPackages = mContext.getResources().getStringArray(
+ R.array.trusted_search_providers);
+
mTrustedPackages = new HashSet<String>();
- mTrustedPackages.add("com.android.contacts");
- mTrustedPackages.add("com.android.browser");
- mTrustedPackages.add("com.android.providers.applications");
+ for (String trustedPackage : trustedPackages) {
+ mTrustedPackages.add(trustedPackage);
+ }
}
/**