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

Commit d02bcc83 authored by Gary Jian's avatar Gary Jian
Browse files

Update the VoNR setting after carrier config change

Confirm whether vonr_enabled_bool is true and then set the setting
according to the value stored in telephony.db, if it has not been
overwritten(-1), it will be enabled by default. If vonr_enabled_bool
is false, hard disabled.

Bug: 202150953
Test: atest GsmCdmaPhoneTest
Change-Id: I11d50c7ff1e0c11efb56b97ed8c8e664c8241a21
parent 8e68fd6d
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -2954,6 +2954,7 @@ public class GsmCdmaPhone extends Phone {
                updateCdmaRoamingSettingsAfterCarrierConfigChanged(b);

                updateNrSettingsAfterCarrierConfigChanged(b);
                updateVoNrSettings(b);
                updateSsOverCdmaSupported(b);
                loadAllowedNetworksFromSubscriptionDatabase();
                // Obtain new radio capabilities from the modem, since some are SIM-dependent
@@ -3266,6 +3267,10 @@ public class GsmCdmaPhone extends Phone {
                resetCarrierKeysForImsiEncryption();
                break;
            }
            case EVENT_SET_VONR_ENABLED_DONE:
                logd("EVENT_SET_VONR_ENABLED_DONE is done");
                break;

            default:
                super.handleMessage(msg);
        }
@@ -4690,6 +4695,38 @@ public class GsmCdmaPhone extends Phone {
        mIsCarrierNrSupported = !ArrayUtils.isEmpty(nrAvailabilities);
    }

    private void updateVoNrSettings(PersistableBundle config) {
        if (config == null) {
            loge("didn't get the vonr_enabled_bool from the carrier config.");
            return;
        }

        boolean mIsVonrEnabledByCarrier =
                config.getBoolean(CarrierConfigManager.KEY_VONR_ENABLED_BOOL);

        String result = SubscriptionController.getInstance().getSubscriptionProperty(
                getSubId(),
                SubscriptionManager.NR_ADVANCED_CALLING_ENABLED);

        int setting = -1;
        if (result != null) {
            setting = Integer.parseInt(result);
        }

        logd("VoNR setting from telephony.db:"
                + setting
                + " ,vonr_enabled_bool:"
                + mIsVonrEnabledByCarrier);

        if (!mIsVonrEnabledByCarrier) {
            mCi.setVoNrEnabled(false, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        } else if (setting == 1 || setting == -1) {
            mCi.setVoNrEnabled(true, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        } else if (setting == 0) {
            mCi.setVoNrEnabled(false, obtainMessage(EVENT_SET_VONR_ENABLED_DONE), null);
        }
    }

    private void updateCdmaRoamingSettingsAfterCarrierConfigChanged(PersistableBundle config) {
        if (config == null) {
            loge("didn't get the cdma_roaming_mode changes from the carrier config.");
+2 −1
Original line number Diff line number Diff line
@@ -232,8 +232,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_BARRING_INFO_CHANGED = 58;
    protected static final int EVENT_LINK_CAPACITY_CHANGED = 59;
    protected static final int EVENT_RESET_CARRIER_KEY_IMSI_ENCRYPTION = 60;
    protected static final int EVENT_SET_VONR_ENABLED_DONE = 61;

    protected static final int EVENT_LAST = EVENT_RESET_CARRIER_KEY_IMSI_ENCRYPTION;
    protected static final int EVENT_LAST = EVENT_SET_VONR_ENABLED_DONE;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
+3 −0
Original line number Diff line number Diff line
@@ -1560,6 +1560,9 @@ public class GsmCdmaPhoneTest extends TelephonyTest {

    @Test
    public void testEventCarrierConfigChanged() {
        doReturn(null).when(mSubscriptionController).getSubscriptionProperty(anyInt(),
                eq(SubscriptionManager.NR_ADVANCED_CALLING_ENABLED));

        mPhoneUT.mCi = mMockCi;
        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(Phone.EVENT_CARRIER_CONFIG_CHANGED));
        processAllMessages();