public class DeviceInfoSettings extends SettingsPreferenceFragment {
- private static final String TAG = "DeviceInfoSettings";
+ 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_DEVICE_MODEL = "device_model";
private static final String KEY_BASEBAND_VERSION = "baseband_version";
private static final String KEY_FIRMWARE_VERSION = "firmware_version";
- 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_UPDATE_SETTING = "additional_system_update_settings";
long[] mHits = new long[3];
addPreferencesFromResource(R.xml.device_info_settings);
- // If we don't have an IME tutorial, remove that option
- String currentIme = Settings.Secure.getString(getContentResolver(),
- Settings.Secure.DEFAULT_INPUT_METHOD);
- ComponentName component = ComponentName.unflattenFromString(currentIme);
- Intent imeIntent = new Intent(component.getPackageName() + ".tutorial");
- PackageManager pm = getPackageManager();
- List<ResolveInfo> tutorials = pm.queryIntentActivities(imeIntent, 0);
- if(tutorials == null || tutorials.isEmpty()) {
- getPreferenceScreen().removePreference(findPreference("system_tutorial"));
- }
-
setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE);
findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband");
- setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
- setStringSummary(KEY_DEVICE_MODEL, Build.MODEL);
+ setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + getMsvSuffix());
setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY);
findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion());
removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal",
PROPERTY_URL_SAFETYLEGAL);
- // Remove Equipment id preference if FCC ID is not set by RIL
- removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_EQUIPMENT_ID,
- PROPERTY_EQUIPMENT_ID);
-
-
// Remove Baseband version if wifi-only device
- if (Utils.isWifiOnly()) {
+ if (Utils.isWifiOnly(getActivity())) {
getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION));
}
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_CONTRIBUTORS,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
+
+ // Read platform settings for additional system update setting
+ boolean isUpdateSettingAvailable =
+ getResources().getBoolean(R.bool.config_additional_system_update_setting_enable);
+ if (isUpdateSettingAvailable == false) {
+ getPreferenceScreen().removePreference(findPreference(KEY_UPDATE_SETTING));
+ }
}
@Override
try {
startActivity(intent);
} catch (Exception e) {
+ Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
}
}
}
try {
preferenceGroup.removePreference(findPreference(preference));
} catch (RuntimeException e) {
- Log.d(TAG, "Property '" + property + "' missing and no '"
+ Log.d(LOG_TAG, "Property '" + property + "' missing and no '"
+ preference + "' preference");
}
}
SystemProperties.get(property,
getResources().getString(R.string.device_info_default)));
} catch (RuntimeException e) {
+ // No recovery
+ }
+ }
+ /**
+ * Reads a line from the specified file.
+ * @param filename the file to read from
+ * @return the first line, if any.
+ * @throws IOException if the file couldn't be read
+ */
+ private String readLine(String filename) throws IOException {
+ BufferedReader reader = new BufferedReader(new FileReader(filename), 256);
+ try {
+ return reader.readLine();
+ } finally {
+ reader.close();
}
}
String procVersionStr;
try {
- BufferedReader reader = new BufferedReader(new FileReader("/proc/version"), 256);
- try {
- procVersionStr = reader.readLine();
- } finally {
- reader.close();
- }
+ procVersionStr = readLine(FILENAME_PROC_VERSION);
final String PROC_VERSION_REGEX =
"\\w+\\s+" + /* ignore: Linux */
Matcher m = p.matcher(procVersionStr);
if (!m.matches()) {
- Log.e(TAG, "Regex did not match on /proc/version: " + procVersionStr);
+ Log.e(LOG_TAG, "Regex did not match on /proc/version: " + procVersionStr);
return "Unavailable";
} else if (m.groupCount() < 4) {
- Log.e(TAG, "Regex match on /proc/version only returned " + m.groupCount()
+ Log.e(LOG_TAG, "Regex match on /proc/version only returned " + m.groupCount()
+ " groups");
return "Unavailable";
} else {
.append(m.group(4))).toString();
}
} catch (IOException e) {
- Log.e(TAG,
+ Log.e(LOG_TAG,
"IO Exception when getting kernel version for Device Info screen",
e);
}
}
+ /**
+ * Returns " (ENGINEERING)" if the msv file has a zero value, else returns "".
+ * @return a string to append to the model number description.
+ */
+ private String getMsvSuffix() {
+ // Production devices should have a non-zero value. If we can't read it, assume it's a
+ // production device so that we don't accidentally show that it's an ENGINEERING device.
+ try {
+ String msv = readLine(FILENAME_MSV);
+ // Parse as a hex number. If it evaluates to a zero, then it's an engineering build.
+ if (Long.parseLong(msv, 16) == 0) {
+ return " (ENGINEERING)";
+ }
+ } catch (IOException ioe) {
+ // Fail quietly, as the file may not exist on some devices.
+ } catch (NumberFormatException nfe) {
+ // Fail quietly, returning empty string should be sufficient
+ }
+ return "";
+ }
}