Merge "Fix bug #15335840 "Safety information" search suggestion shown though ..."Safety information" setting is not available in settings app" into lmp-preview-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2aa322991d
@@ -80,15 +80,6 @@
|
|||||||
<intent android:action="android.settings.SAFETY" />
|
<intent android:action="android.settings.SAFETY" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<!-- Contributors -->
|
|
||||||
<!--
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="contributors"
|
|
||||||
android:title="@string/contributors_title">
|
|
||||||
<intent android:action="android.settings.TEAM" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="regulatory_info"
|
android:key="regulatory_info"
|
||||||
android:title="@string/regulatory_information">
|
android:title="@string/regulatory_information">
|
||||||
|
@@ -35,27 +35,30 @@ import android.os.UserManager;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settings.search.Indexable;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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 LOG_TAG = "DeviceInfoSettings";
|
||||||
private static final String FILENAME_PROC_VERSION = "/proc/version";
|
private static final String FILENAME_PROC_VERSION = "/proc/version";
|
||||||
private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
|
private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
|
||||||
|
|
||||||
private static final String KEY_CONTAINER = "container";
|
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_REGULATORY_INFO = "regulatory_info";
|
||||||
private static final String KEY_TERMS = "terms";
|
private static final String KEY_TERMS = "terms";
|
||||||
private static final String KEY_LICENSE = "license";
|
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 KEY_EQUIPMENT_ID = "fcc_equipment_id";
|
||||||
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
|
private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
|
||||||
private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
|
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;
|
static final int TAPS_TO_BE_A_DEVELOPER = 7;
|
||||||
|
|
||||||
@@ -109,7 +113,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
|
|||||||
PROPERTY_SELINUX_STATUS);
|
PROPERTY_SELINUX_STATUS);
|
||||||
|
|
||||||
// Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
|
// Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
|
||||||
removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal",
|
removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_SAFETY_LEGAL,
|
||||||
PROPERTY_URL_SAFETYLEGAL);
|
PROPERTY_URL_SAFETYLEGAL);
|
||||||
|
|
||||||
// Remove Equipment id preference if FCC ID is not set by RIL
|
// 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.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
|
||||||
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT,
|
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT,
|
||||||
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
|
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
|
// These are contained by the root preference screen
|
||||||
parentPreference = getPreferenceScreen();
|
parentPreference = getPreferenceScreen();
|
||||||
@@ -152,8 +154,6 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
|
|||||||
// Remove for secondary users
|
// Remove for secondary users
|
||||||
removePreference(KEY_SYSTEM_UPDATE_SETTINGS);
|
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
|
// Read platform settings for additional system update setting
|
||||||
removePreferenceIfBoolFalse(KEY_UPDATE_SETTING,
|
removePreferenceIfBoolFalse(KEY_UPDATE_SETTING,
|
||||||
@@ -365,7 +365,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getFeedbackReporterPackage(Context context) {
|
private static String getFeedbackReporterPackage(Context context) {
|
||||||
String feedbackReporter =
|
final String feedbackReporter =
|
||||||
context.getResources().getString(R.string.oem_preferred_feedback_reporter);
|
context.getResources().getString(R.string.oem_preferred_feedback_reporter);
|
||||||
if (TextUtils.isEmpty(feedbackReporter)) {
|
if (TextUtils.isEmpty(feedbackReporter)) {
|
||||||
// Reporter not configured. Return.
|
// 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
|
// 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.
|
// 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();
|
PackageManager pm = context.getPackageManager();
|
||||||
List<ResolveInfo> resolvedPackages =
|
List<ResolveInfo> resolvedPackages =
|
||||||
@@ -398,5 +398,83 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -498,7 +498,7 @@ public class Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addIndexablesForXmlResourceUri(Context packageContext, String packageName,
|
private void addIndexablesForXmlResourceUri(Context packageContext, String packageName,
|
||||||
Uri uri, String[] projection, int baseRank) {
|
Uri uri, String[] projection, int baseRank) {
|
||||||
|
|
||||||
final ContentResolver resolver = packageContext.getContentResolver();
|
final ContentResolver resolver = packageContext.getContentResolver();
|
||||||
final Cursor cursor = resolver.query(uri, projection, null, null, null);
|
final Cursor cursor = resolver.query(uri, projection, null, null, null);
|
||||||
@@ -545,7 +545,7 @@ public class Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addIndexablesForRawDataUri(Context packageContext, String packageName,
|
private void addIndexablesForRawDataUri(Context packageContext, String packageName,
|
||||||
Uri uri, String[] projection, int baseRank) {
|
Uri uri, String[] projection, int baseRank) {
|
||||||
|
|
||||||
final ContentResolver resolver = packageContext.getContentResolver();
|
final ContentResolver resolver = packageContext.getContentResolver();
|
||||||
final Cursor cursor = resolver.query(uri, projection, null, null, null);
|
final Cursor cursor = resolver.query(uri, projection, null, null, null);
|
||||||
|
@@ -219,7 +219,7 @@ public final class SearchIndexableResources {
|
|||||||
sResMap.put(DeviceInfoSettings.class.getName(),
|
sResMap.put(DeviceInfoSettings.class.getName(),
|
||||||
new SearchIndexableResource(
|
new SearchIndexableResource(
|
||||||
Ranking.getRankForClassName(DeviceInfoSettings.class.getName()),
|
Ranking.getRankForClassName(DeviceInfoSettings.class.getName()),
|
||||||
R.xml.device_info_settings,
|
NO_DATA_RES_ID,
|
||||||
DeviceInfoSettings.class.getName(),
|
DeviceInfoSettings.class.getName(),
|
||||||
R.drawable.ic_settings_about));
|
R.drawable.ic_settings_about));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user