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

Commit 3e340ca1 authored by Diogo Ferreira's avatar Diogo Ferreira Committed by Ricardo Cerqueira
Browse files

PhoneBase: Add auto-rat switching on capability changes

Certain modems have a configuration where the primary data subscription
can do 3/4G while secondary ones will only do 2G.

This patchset updates preferred types for each Phone when its
capabilities change. So if a modem has a limitation as described
above and correctly reports it, the telephony stack will automatically
upgrade/downgrade the RAT accordingly.

Change-Id: I1ca4f6ef94e03666d575588b2c30c78182b37598
parent 1bcee712
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -2637,10 +2637,22 @@ public abstract class PhoneBase extends Handler implements Phone {
        mRadioCapability.set(rc);
        mRadioCapability.set(rc);


        if (SubscriptionManager.isValidSubscriptionId(getSubId())) {
        if (SubscriptionManager.isValidSubscriptionId(getSubId())) {
            updatePreferredType();
            sendSubscriptionSettings(true);
            sendSubscriptionSettings(true);
        }
        }
    }
    }


    private void updatePreferredType() {
        int preferredRaf = getRadioAccessFamily();
        int userNwType = SubscriptionController.getInstance().getUserNwMode(getPhoneId());
        if (userNwType != SubscriptionManager.DEFAULT_NW_MODE) {
            preferredRaf &= RadioAccessFamily.getRafFromNetworkType(userNwType);
        }
        int filteredType = RadioAccessFamily.getNetworkTypeFromRaf(preferredRaf);
        TelephonyManager.putIntAtIndex(mContext.getContentResolver(),
                Settings.Global.PREFERRED_NETWORK_MODE, getPhoneId(), filteredType);
    }

    public void sendSubscriptionSettings(boolean restoreNetworkSelection) {
    public void sendSubscriptionSettings(boolean restoreNetworkSelection) {
        // Send settings down
        // Send settings down
        int type = PhoneFactory.calculatePreferredNetworkType(mContext, getSubId());
        int type = PhoneFactory.calculatePreferredNetworkType(mContext, getSubId());