summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DeviceInfoSettings.java
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-05-30 15:30:12 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2014-05-30 15:35:06 -0700
commitb2385ea46286933add8ea3fb86db7870fe294334 (patch)
treebb662bff5ed26013ac737baf816f93ea64674c9b /src/com/android/settings/DeviceInfoSettings.java
parenteed44c9d5f72a1981b7057ae8f1744863e036078 (diff)
downloadpackages_apps_Settings-b2385ea46286933add8ea3fb86db7870fe294334.zip
packages_apps_Settings-b2385ea46286933add8ea3fb86db7870fe294334.tar.gz
packages_apps_Settings-b2385ea46286933add8ea3fb86db7870fe294334.tar.bz2
Fix bug #15335840 "Safety information" search suggestion shown though
..."Safety information" setting is not available in settings app - implement a SearchIndexProvider for DeviceInfoSettings and remove some Preference indexing depending on the device state and configuration - remove old non used Preferences - some code cleaning Change-Id: I3b2c9dc7cb9f1137b553fed9330aeea4020bd2f8
Diffstat (limited to 'src/com/android/settings/DeviceInfoSettings.java')
-rw-r--r--src/com/android/settings/DeviceInfoSettings.java98
1 files changed, 88 insertions, 10 deletions
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index 9d10ecb..c26e4ab 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -35,27 +35,30 @@ import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class DeviceInfoSettings extends SettingsPreferenceFragment {
+public class DeviceInfoSettings extends SettingsPreferenceFragment implements Indexable {
private static final String LOG_TAG = "DeviceInfoSettings";
private static final String FILENAME_PROC_VERSION = "/proc/version";
private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
private static final String KEY_CONTAINER = "container";
- private static final String KEY_TEAM = "team";
- private static final String KEY_CONTRIBUTORS = "contributors";
private static final String KEY_REGULATORY_INFO = "regulatory_info";
private static final String KEY_TERMS = "terms";
private static final String KEY_LICENSE = "license";
@@ -73,6 +76,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id";
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
+ private static final String KEY_SAFETY_LEGAL = "safetylegal";
static final int TAPS_TO_BE_A_DEVELOPER = 7;
@@ -109,7 +113,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
PROPERTY_SELINUX_STATUS);
// Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
- removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal",
+ removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SAFETY_LEGAL,
PROPERTY_URL_SAFETYLEGAL);
// Remove Equipment id preference if FCC ID is not set by RIL
@@ -139,8 +143,6 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
- Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_TEAM,
- Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
// These are contained by the root preference screen
parentPreference = getPreferenceScreen();
@@ -152,8 +154,6 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
// Remove for secondary users
removePreference(KEY_SYSTEM_UPDATE_SETTINGS);
}
- Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_CONTRIBUTORS,
- Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
// Read platform settings for additional system update setting
removePreferenceIfBoolFalse(KEY_UPDATE_SETTING,
@@ -365,7 +365,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
}
private static String getFeedbackReporterPackage(Context context) {
- String feedbackReporter =
+ final String feedbackReporter =
context.getResources().getString(R.string.oem_preferred_feedback_reporter);
if (TextUtils.isEmpty(feedbackReporter)) {
// Reporter not configured. Return.
@@ -373,7 +373,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
}
// Additional checks to ensure the reporter is on system image, and reporter is
// configured to listen to the intent. Otherwise, dont show the "send feedback" option.
- Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
+ final Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> resolvedPackages =
@@ -398,5 +398,83 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
}
return null;
}
+
+ /**
+ * For Search.
+ */
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.device_info_settings;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = new ArrayList<String>();
+ if (isPropertyMissing(PROPERTY_SELINUX_STATUS)) {
+ keys.add(KEY_SELINUX_STATUS);
+ }
+ if (isPropertyMissing(PROPERTY_URL_SAFETYLEGAL)) {
+ keys.add(KEY_SAFETY_LEGAL);
+ }
+ if (isPropertyMissing(PROPERTY_EQUIPMENT_ID)) {
+ keys.add(KEY_EQUIPMENT_ID);
+ }
+ // Remove Baseband version if wifi-only device
+ if (Utils.isWifiOnly(context)) {
+ keys.add((KEY_BASEBAND_VERSION));
+ }
+ // Dont show feedback option if there is no reporter.
+ if (TextUtils.isEmpty(getFeedbackReporterPackage(context))) {
+ keys.add(KEY_DEVICE_FEEDBACK);
+ }
+ if (!checkIntentAction(context, "android.settings.TERMS")) {
+ keys.add(KEY_TERMS);
+ }
+ if (!checkIntentAction(context, "android.settings.LICENSE")) {
+ keys.add(KEY_LICENSE);
+ }
+ if (!checkIntentAction(context, "android.settings.COPYRIGHT")) {
+ keys.add(KEY_COPYRIGHT);
+ }
+ if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
+ keys.add(KEY_SYSTEM_UPDATE_SETTINGS);
+ }
+ if (!context.getResources().getBoolean(
+ R.bool.config_additional_system_update_setting_enable)) {
+ keys.add(KEY_UPDATE_SETTING);
+ }
+ return keys;
+ }
+
+ private boolean isPropertyMissing(String property) {
+ return SystemProperties.get(property).equals("");
+ }
+
+ private boolean checkIntentAction(Context context, String action) {
+ final Intent intent = new Intent(action);
+
+ // Find the activity that is in the system image
+ final PackageManager pm = context.getPackageManager();
+ final List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
+ final int listSize = list.size();
+
+ for (int i = 0; i < listSize; i++) {
+ ResolveInfo resolveInfo = list.get(i);
+ if ((resolveInfo.activityInfo.applicationInfo.flags &
+ ApplicationInfo.FLAG_SYSTEM) != 0) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ };
+
}