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

Commit fbf20917 authored by Kuen Yuet Cheung's avatar Kuen Yuet Cheung
Browse files

Add IMS reg checking before display Cross Sim SPN

Add a condition to check if IMS have registered before displaying Cross
Sim SPN. Without this the Cross Sim SPN will be displayed if radioTech
is CrossSim no matter is  IMS is still registering. It may confuse User
on why IMS entered Backup Calling when other RAT is available.

Flag: EXEMPT bugfix
Bug: 302469576
Test: atest
Change-Id: I0c841e432da47394bb3f14e76a0e4d996883946c
parent fb600ea3
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -2897,10 +2897,8 @@ public class ServiceStateTracker extends Handler {
        }

        String crossSimSpnFormat = null;
        if (mPhone.getImsPhone() != null
                && (mPhone.getImsPhone() != null)
                && (mPhone.getImsPhone().getImsRegistrationTech()
                == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM)) {
        if ((getImsRegistrationTech() == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM)
                && mPhone.isImsRegistered()) {
            // In Cross SIM Calling mode show SPN or PLMN + Cross SIM Calling
            //
            // 1) Show SPN + Cross SIM Calling If SIM has SPN and SPN display condition
+2 −1
Original line number Diff line number Diff line
@@ -477,7 +477,8 @@ public class CarrierDisplayNameResolver {
        CarrierDisplayNameData data = getCarrierDisplayNameFromEf();
        if (DBG) Rlog.d(TAG, "CarrierName from EF: " + data);
        if ((mPhone.getImsPhone() != null) && (mPhone.getImsPhone().getImsRegistrationTech()
                == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM)) {
                == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM
                && mPhone.isImsRegistered())) {
            data = getCarrierDisplayNameFromCrossSimCallingOverride(data);
            if (DBG) {
                Rlog.d(TAG, "CarrierName override by Cross-SIM Calling " + data);
+64 −0
Original line number Diff line number Diff line
@@ -3082,6 +3082,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        doReturn(mImsPhone).when(mPhone).getImsPhone();
        doReturn(ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM).when(mImsPhone)
                .getImsRegistrationTech();
        doReturn(true).when(mPhone).isImsRegistered();
        String[] formats = {CROSS_SIM_CALLING_VOICE_FORMAT, "%s"};
        Resources r = mContext.getResources();
        doReturn(formats).when(r).getStringArray(anyInt());
@@ -3245,6 +3246,69 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertThat(b.getBoolean(TelephonyManager.EXTRA_SHOW_PLMN)).isTrue();
    }

    @Test
    public void testUpdateSpnDisplayLegacy_CrossSimCallingDataOOS_displayOOS() {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_ENABLE_CARRIER_DISPLAY_NAME_RESOLVER_BOOL, false);
        sendCarrierConfigUpdate(PHONE_ID);

        // GSM phone
        doReturn(true).when(mPhone).isPhoneTypeGsm();

        // Reg tech is Cross Sim but both data and voice are OOS
        doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getState();
        doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getDataRegistrationState();
        doReturn(TelephonyManager.NETWORK_TYPE_IWLAN).when(mServiceState).getDataNetworkType();
        doReturn(mImsPhone).when(mPhone).getImsPhone();
        doReturn(ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM).when(
                mImsPhone).getImsRegistrationTech();
        sst.mSS = mServiceState;

        // wifi-calling is enabled
        doReturn(true).when(mPhone).isWifiCallingEnabled();

        // update the spn
        sst.updateSpnDisplay();

        // Plmn should be shown, and the string is "No service"
        Bundle b = getExtrasFromLastSpnUpdateIntent();
        assertThat(b.getString(TelephonyManager.EXTRA_PLMN))
                .isEqualTo(CARRIER_NAME_DISPLAY_NO_SERVICE);
        assertThat(b.getBoolean(TelephonyManager.EXTRA_SHOW_PLMN)).isTrue();
    }

    @Test
    public void testUpdateSpnDisplayLegacy_CrossSimCallingVoiceOOS_displayOOS() {
        mBundle.putBoolean(
                CarrierConfigManager.KEY_ENABLE_CARRIER_DISPLAY_NAME_RESOLVER_BOOL, false);
        sendCarrierConfigUpdate(PHONE_ID);

        // GSM phone
        doReturn(true).when(mPhone).isPhoneTypeGsm();

        // voice out of service but data in service (connected to Cross Sim IWLAN)
        doReturn(ServiceState.STATE_OUT_OF_SERVICE).when(mServiceState).getState();
        doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getDataRegistrationState();
        doReturn(TelephonyManager.NETWORK_TYPE_IWLAN).when(mServiceState).getDataNetworkType();
        doReturn(mImsPhone).when(mPhone).getImsPhone();
        doReturn(ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM).when(
                mImsPhone).getImsRegistrationTech();
        doReturn(false).when(mPhone).isImsRegistered();
        sst.mSS = mServiceState;

        // wifi-calling is enabled
        doReturn(true).when(mPhone).isWifiCallingEnabled();

        // update the spn
        sst.updateSpnDisplay();

        // Plmn should be shown, and the string is "No service"
        Bundle b = getExtrasFromLastSpnUpdateIntent();
        assertThat(b.getString(TelephonyManager.EXTRA_PLMN))
                .isEqualTo(CARRIER_NAME_DISPLAY_NO_SERVICE);
        assertThat(b.getBoolean(TelephonyManager.EXTRA_SHOW_PLMN)).isTrue();
    }

    private Bundle getExtrasFromLastSpnUpdateIntent() {
        // Verify the spn update notification was sent
        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);