Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 746dc496 authored by Lin Ma's avatar Lin Ma Committed by Gerrit Code Review
Browse files

Fix ro.telephony.default_network setting parsing

* The code that parses ro.telephony.default_network is broken,
instead of reading numbers separate by comma, it reads the first
number and replicates it for other slots. Settings like "8,1" will
be written to the db as "8,8"

Change-Id: I6b77000e00ada02ec89b09c752a9b337a6a8182b
parent c28e5886
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -2821,20 +2821,27 @@ public class DatabaseHelper extends SQLiteOpenHelper {

            // Set the preferred network mode to target desired value or Default
            // value defined in RILConstants
            int type;
            int phoneCount = TelephonyManager.getDefault().getPhoneCount();
            type = SystemProperties.getInt("ro.telephony.default_network",
                        RILConstants.PREFERRED_NETWORK_MODE);
            String val = Integer.toString(type);
            for (int phoneId = 1; phoneId < phoneCount; phoneId++) {
                val = val + "," + type;
            final String defVal = SystemProperties.get("ro.telephony.default_network", "");
            final String[] defNetworkSettings = defVal.split(",");
            final int phoneCount = TelephonyManager.getDefault().getPhoneCount();
            final String[] networkSettings = new String[phoneCount];
            boolean error = defNetworkSettings.length != phoneCount;
            for (int i = 0; i < phoneCount; i++) {
                try {
                    networkSettings[i] = String.valueOf(Integer.parseInt(defNetworkSettings[i]));
                } catch (NumberFormatException ex) {
                    networkSettings[i] = RILConstants.PREFERRED_NETWORK_MODE;
                    error = true;
                }

            loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, val);
            }
            if (error) {
                Log.w(TAG, "Wrong ro.telephony.default_network setting " + defVal + ". Fallback to defaults");
            }
            loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, TextUtils.join(",", networkSettings));

            // Set the preferred cdma subscription source to target desired value or default
            // value defined in CdmaSubscriptionSourceManager
            type = SystemProperties.getInt("ro.telephony.default_cdma_sub",
            int type = SystemProperties.getInt("ro.telephony.default_cdma_sub",
                        CdmaSubscriptionSourceManager.PREFERRED_CDMA_SUBSCRIPTION);
            loadSetting(stmt, Settings.Global.CDMA_SUBSCRIPTION_MODE, type);