SettingsProvider: use sysprop as API for telephony
Bug: 117924132
Bug: 141246285
Test: lunch blueline-userdebug; m checkbuild
Change-Id: Ib28d5804dcb8480f5a00a869c16a1112fb2c075d
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 44de09b..386626d 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -41,6 +41,7 @@
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
+import android.sysprop.TelephonyProperties;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -2487,9 +2488,7 @@
// Data roaming default, based on build
loadSetting(stmt, Settings.Global.DATA_ROAMING,
- "true".equalsIgnoreCase(
- SystemProperties.get("ro.com.android.dataroaming",
- "false")) ? 1 : 0);
+ TelephonyProperties.data_roaming().orElse(false) ? 1 : 0);
loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED,
R.bool.def_device_provisioned);
@@ -2510,9 +2509,7 @@
// Mobile Data default, based on build
loadSetting(stmt, Settings.Global.MOBILE_DATA,
- "true".equalsIgnoreCase(
- SystemProperties.get("ro.com.android.mobiledata",
- "true")) ? 1 : 0);
+ TelephonyProperties.mobile_data().orElse(true) ? 1 : 0);
loadBooleanSetting(stmt, Settings.Global.NETSTATS_ENABLED,
R.bool.def_netstats_enabled);
@@ -2564,20 +2561,17 @@
// Set the preferred network mode to target desired value or Default
// value defined in system property
- String val = "";
- String mode;
+ StringBuilder val = new StringBuilder();
+ List<Integer> defaultNetworks = TelephonyProperties.default_network();
for (int phoneId = 0;
phoneId < TelephonyManager.getDefault().getPhoneCount(); phoneId++) {
- mode = TelephonyManager.getTelephonyProperty(phoneId,
- "ro.telephony.default_network",
- Integer.toString(RILConstants.PREFERRED_NETWORK_MODE));
- if (phoneId == 0) {
- val = mode;
- } else {
- val = val + "," + mode;
- }
+ int mode = defaultNetworks.size() <= phoneId
+ || defaultNetworks.get(phoneId) == null
+ ? RILConstants.PREFERRED_NETWORK_MODE : defaultNetworks.get(phoneId);
+ if (phoneId > 0) val.append(',');
+ val.append(mode);
}
- loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, val);
+ loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, val.toString());
// Set the preferred cdma subscription source to target desired value or default
// value defined in Phone