Add Safety information to Settings > About Phone

The Safety information link is stored in a system property, ro.url.safetylegal

If the phone has data connection, select "Safety information" menu will open the
Safety information link.  If there is no data connection for the phone, a message will
pop up which ask user to open Safety information link from PC.

Change-Id: Ia46e2e868ebcda93138cb9f00c978d8ac827022a
This commit is contained in:
Wink Saville
2009-09-26 16:47:18 -07:00
parent 9281c929d6
commit a40fb23734
5 changed files with 148 additions and 1 deletions

View File

@@ -48,6 +48,7 @@ public class DeviceInfoSettings extends PreferenceActivity {
private static final String KEY_LICENSE = "license";
private static final String KEY_COPYRIGHT = "copyright";
private static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings";
private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal";
@Override
protected void onCreate(Bundle icicle) {
@@ -61,6 +62,10 @@ public class DeviceInfoSettings extends PreferenceActivity {
setStringSummary("build_number", Build.DISPLAY);
findPreference("kernel_version").setSummary(getFormattedKernelVersion());
// Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal",
PROPERTY_URL_SAFETYLEGAL);
/*
* Settings is a generic app and should not contain any device-specific
* info.
@@ -85,7 +90,21 @@ public class DeviceInfoSettings extends PreferenceActivity {
Utils.updatePreferenceToSpecificActivityOrRemove(this, parentPreference, KEY_CONTRIBUTORS,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
}
private void removePreferenceIfPropertyMissing(PreferenceGroup preferenceGroup,
String preference, String property ) {
if (SystemProperties.get(property).equals(""))
{
// Property is missing so remove preference from group
try {
preferenceGroup.removePreference(findPreference(preference));
} catch (RuntimeException e) {
Log.d(TAG, "Property '" + property + "' missing and no '"
+ preference + "' preference");
}
}
}
private void setStringSummary(String preference, String value) {
try {
findPreference(preference).setSummary(value);