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

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

Set preferred network mode based on phoneID

Currently, on initialization we send a default network mode
 and later when subscriptions are discovered we send the sub
 based network mode. With this change we will send the network mode
 associated with the slot in the previous boot which will end up
 being the same as after the subscription is discovered
 (assuming the card has not changed).  With this we don't end up
 sending different network modes one after the other unnecessarily.
 We do this even when a card is removed and a new card is inserted
 into the same slot.
 The getNetworkTypeFromRaf utility has no way to differentiate
 between MODE_GSM_UMTS and MODE_WCDMA_PREF since they have the
 same raf. So check for it explicitly

Change-Id: Ibbc9453d4146a3d10ba081e4b313e93996e177aa
parent e1cf3fa6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1473,6 +1473,12 @@ public abstract class PhoneBase extends Handler implements Phone {
        int filteredRaf = (rafFromType & modemRaf);
        int filteredType = RadioAccessFamily.getNetworkTypeFromRaf(filteredRaf);

        // The getNetworkTypeFromRaf, has no way to differentiate between MODE_GSM_UMTS
        // and MODE_WCDMA_PREF since they have the same raf. So check for it explicitly
        if (networkType == RILConstants.NETWORK_MODE_GSM_UMTS &&
                filteredType == RILConstants.NETWORK_MODE_WCDMA_PREF) {
            filteredType = RILConstants.NETWORK_MODE_GSM_UMTS;
        }
        Rlog.d(LOG_TAG, "setPreferredNetworkType: networkType = " + networkType
                + " modemRaf = " + modemRaf
                + " rafFromType = " + rafFromType
+9 −2
Original line number Diff line number Diff line
@@ -138,8 +138,15 @@ public class PhoneFactory {
                for (int i = 0; i < numPhones; i++) {
                    // reads the system properties and makes commandsinterface
                    // Get preferred network type.
                   try {
                        networkModes[i]  = TelephonyManager.getIntAtIndex(
                                context.getContentResolver(),
                               Settings.Global.PREFERRED_NETWORK_MODE , i);
                    } catch (SettingNotFoundException snfe) {
                        Rlog.e(LOG_TAG, "Settings Exception Reading Value At Index for"+
                               " Settings.Global.PREFERRED_NETWORK_MODE");
                        networkModes[i] = RILConstants.PREFERRED_NETWORK_MODE;

                    }
                    Rlog.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkModes[i]));
                    sCommandsInterfaces[i] = new RIL(context, networkModes[i],
                            cdmaSubscription, i);
+11 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.ServiceManager;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.telephony.Rlog;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
@@ -429,7 +430,16 @@ public class SubscriptionInfoUpdater extends Handler {

            if (storedSubId != subId) {
                int networkType = RILConstants.PREFERRED_NETWORK_MODE;

                //Get previous network mode for this slot,
                // to be more relevant instead of default mode
                try {
                    networkType  = TelephonyManager.getIntAtIndex(
                            mContext.getContentResolver(),
                           Settings.Global.PREFERRED_NETWORK_MODE, slotId);
                } catch (SettingNotFoundException snfe) {
                    Rlog.e(LOG_TAG, "Settings Exception Reading Value At Index for"+
                           " Settings.Global.PREFERRED_NETWORK_MODE");
                }
                // Set the modem network mode
                mPhone[slotId].setPreferredNetworkType(networkType, null);
                Settings.Global.putInt(mPhone[slotId].getContext().getContentResolver(),