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

Commit 53ed38f8 authored by Joonhun Shin's avatar Joonhun Shin Committed by Android (Google) Code Review
Browse files

Merge "Fix to update wfc mode in roaming network" into main

parents 7de9f2af 8aeca63b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -55,3 +55,10 @@ flag {
    description: "For DSDA devices, controls whether the existing call will be dropped when an incoming call on a different sub is answered, when either sub does not support hold capability."
    bug:"315993953"
}

flag {
    name: "update_roaming_state_to_set_wfc_mode"
    namespace: "telephony"
    description: "This flag updates roaming state to set wfc mode"
    bug:"317298331"
}
+6 −1
Original line number Diff line number Diff line
@@ -2436,7 +2436,9 @@ public class ImsPhone extends ImsPhoneBase {

        if (mCT.getState() == PhoneConstants.State.IDLE) {
            if (DBG) logd("updateRoamingState now: " + newRoamingState);
            if (!mFeatureFlags.updateRoamingStateToSetWfcMode()) {
                mLastKnownRoamingState = newRoamingState;
            }
            CarrierConfigManager configManager = (CarrierConfigManager)
                    getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
            // Don't set wfc mode if carrierconfig has not loaded. It will be set by GsmCdmaPhone
@@ -2445,6 +2447,9 @@ public class ImsPhone extends ImsPhoneBase {
                    configManager.getConfigForSubId(getSubId()))) {
                ImsManager imsManager = mImsManagerFactory.create(mContext, mPhoneId);
                imsManager.setWfcMode(imsManager.getWfcMode(newRoamingState), newRoamingState);
                if (mFeatureFlags.updateRoamingStateToSetWfcMode()) {
                    mLastKnownRoamingState = newRoamingState;
                }
            }
        } else {
            if (DBG) logd("updateRoamingState postponed: " + newRoamingState);
+32 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import static org.mockito.Mockito.verify;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
@@ -818,6 +819,37 @@ public class ImsPhoneTest extends TelephonyTest {
        verify(mImsManager, times(1)).setWfcMode(anyInt(), anyBoolean());
    }

    @Test
    @SmallTest
    public void testSetWfcModeInRoaming() throws Exception {
        doReturn(true).when(mFeatureFlags).updateRoamingStateToSetWfcMode();
        doReturn(PhoneConstants.State.IDLE).when(mImsCT).getState();
        doReturn(true).when(mPhone).isRadioOn();

        // Set CarrierConfigManager to be invalid
        doReturn(null).when(mContext).getSystemService(Context.CARRIER_CONFIG_SERVICE);

        //Roaming - data registration only on LTE
        Message m = getServiceStateChangedMessage(getServiceStateDataOnly(
                ServiceState.RIL_RADIO_TECHNOLOGY_LTE, ServiceState.STATE_IN_SERVICE, true));
        // Inject the message synchronously instead of waiting for the thread to do it.
        mImsPhoneUT.handleMessage(m);
        m.recycle();

        verify(mImsManager, never()).setWfcMode(anyInt(), eq(true));

        // Set CarrierConfigManager to be valid
        doReturn(mCarrierConfigManager).when(mContext)
                .getSystemService(Context.CARRIER_CONFIG_SERVICE);

        m = getServiceStateChangedMessage(getServiceStateDataOnly(
                ServiceState.RIL_RADIO_TECHNOLOGY_LTE, ServiceState.STATE_IN_SERVICE, true));
        mImsPhoneUT.handleMessage(m);
        m.recycle();

        verify(mImsManager, times(1)).setWfcMode(anyInt(), eq(true));
    }

    @Test
    public void testNonNullTrackersInImsPhone() throws Exception {
        assertNotNull(mImsPhoneUT.getEmergencyNumberTracker());