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

Commit dceb0ff1 authored by Chaitanya Saggurthi's avatar Chaitanya Saggurthi Committed by Linux Build Service Account
Browse files

Calculate preferred network based on phoneId for dumimy SubId

Once radio capabilties are available telephony will send
preferred network mode based on Sub ID, but at this time
Sub Id value is dummy value, so calculatePreferredNetworkType
will return default network mode value, this value may be different
from previously sent network mode. Fix this by calculate network
 mode based on phone ID for dummy SubId value.

Change-Id: Ibf1ad796ce1e31438f5dd984aac92a9bec583ad5
parent 35e17cac
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -318,9 +318,26 @@ public class PhoneFactory {
     */
    // TODO: Fix when we "properly" have TelephonyDevController/SubscriptionController ..
    public static int calculatePreferredNetworkType(Context context, int phoneSubId) {
        int networkType = android.provider.Settings.Global.getInt(context.getContentResolver(),
        int phoneId = SubscriptionController.getInstance().getPhoneId(phoneSubId);
        int phoneIdNetworkType = RILConstants.PREFERRED_NETWORK_MODE;
        try {
            phoneIdNetworkType = TelephonyManager.getIntAtIndex(context.getContentResolver(),
                    Settings.Global.PREFERRED_NETWORK_MODE , phoneId);
        } catch (SettingNotFoundException snfe) {
            Rlog.e(LOG_TAG, "Settings Exception Reading Valuefor phoneID");
        }
        int networkType = phoneIdNetworkType;
        Rlog.d(LOG_TAG, "calculatePreferredNetworkType: phoneId = " + phoneId +
                " phoneIdNetworkType = " + phoneIdNetworkType);

        if (SubscriptionController.getInstance().isActiveSubId(phoneSubId)) {
            networkType = android.provider.Settings.Global.getInt(context.getContentResolver(),
                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                RILConstants.PREFERRED_NETWORK_MODE);
                    phoneIdNetworkType);
        } else {
            Rlog.d(LOG_TAG, "calculatePreferredNetworkType: phoneSubId = " + phoneSubId +
                    " is not a active SubId");
        }
        Rlog.d(LOG_TAG, "calculatePreferredNetworkType: phoneSubId = " + phoneSubId +
                " networkType = " + networkType);
        return networkType;