Loading src/java/com/android/internal/telephony/data/PhoneSwitcher.java +8 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATIO import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE; import static java.util.Arrays.copyOf; import android.annotation.NonNull; Loading Loading @@ -73,6 +72,7 @@ import android.util.Log; import com.android.ims.ImsException; import com.android.ims.ImsManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.Call; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.ISetOpportunisticDataCallback; import com.android.internal.telephony.IccCard; Loading Loading @@ -1678,8 +1678,14 @@ public class PhoneSwitcher extends Handler { } // A phone in voice call might trigger data being switched to it. // Exclude dialing to give modem time to process an EMC first before dealing with DDS switch // Include alerting because modem RLF leads to delay in switch, so carrier required to // switch in alerting phase. // TODO: check ringing call for vDADA return (!phone.getBackgroundCall().isIdle() || !phone.getForegroundCall().isIdle()); && phone.getBackgroundCall().getState() != Call.State.DIALING) || (!phone.getForegroundCall().isIdle() && phone.getForegroundCall().getState() != Call.State.DIALING); } private void updateHalCommandToUse() { Loading tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,8 @@ import static android.telephony.TelephonyManager.SIM_STATE_LOADED; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE; import static com.android.internal.telephony.data.AutoDataSwitchController.EVALUATION_REASON_VOICE_CALL_END; import static com.android.internal.telephony.data.PhoneSwitcher.ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading Loading @@ -121,6 +119,7 @@ public class PhoneSwitcherTest extends TelephonyTest { private GsmCdmaCall mInactiveCall; private GsmCdmaCall mDialCall; private GsmCdmaCall mIncomingCall; private GsmCdmaCall mAlertingCall; private ISetOpportunisticDataCallback mSetOpptDataCallback1; private ISetOpportunisticDataCallback mSetOpptDataCallback2; PhoneSwitcher.ImsRegTechProvider mMockImsRegTechProvider; Loading Loading @@ -161,6 +160,7 @@ public class PhoneSwitcherTest extends TelephonyTest { mInactiveCall = mock(GsmCdmaCall.class); mDialCall = mock(GsmCdmaCall.class); mIncomingCall = mock(GsmCdmaCall.class); mAlertingCall = mock(GsmCdmaCall.class); mSetOpptDataCallback1 = mock(ISetOpportunisticDataCallback.class); mSetOpptDataCallback2 = mock(ISetOpportunisticDataCallback.class); mMockImsRegTechProvider = mock(PhoneSwitcher.ImsRegTechProvider.class); Loading @@ -176,6 +176,7 @@ public class PhoneSwitcherTest extends TelephonyTest { doReturn(Call.State.HOLDING).when(mHoldingCall).getState(); doReturn(Call.State.DIALING).when(mDialCall).getState(); doReturn(Call.State.INCOMING).when(mIncomingCall).getState(); doReturn(Call.State.ALERTING).when(mAlertingCall).getState(); doReturn(true).when(mInactiveCall).isIdle(); doReturn(false).when(mActiveCall).isIdle(); Loading Loading @@ -878,13 +879,19 @@ public class PhoneSwitcherTest extends TelephonyTest { // Phone 0 should be the default data phoneId. assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId()); // Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled. This should // trigger data switch. // Dialing shouldn't trigger switch because we give modem time to deal with the dialing call // first. Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled. doReturn(mImsPhone).when(mPhone2).getImsPhone(); doReturn(true).when(mPhone2).isDataAllowed(); mockImsRegTech(1, REGISTRATION_TECH_LTE); notifyPhoneAsInDial(mImsPhone); // Phone1 should remain as the preferred data phone assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId()); // Dialing -> Alert, should trigger phone switch notifyPhoneAsAlerting(mImsPhone); // Phone2 should be preferred data phone assertEquals(1, mPhoneSwitcherUT.getPreferredDataPhoneId()); } Loading Loading @@ -1709,6 +1716,12 @@ public class PhoneSwitcherTest extends TelephonyTest { processAllMessages(); } private void notifyPhoneAsAlerting(Phone phone) { doReturn(mAlertingCall).when(phone).getForegroundCall(); mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED); processAllMessages(); } private void notifyPhoneAsInIncomingCall(Phone phone) { doReturn(mIncomingCall).when(phone).getForegroundCall(); mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED); Loading Loading
src/java/com/android/internal/telephony/data/PhoneSwitcher.java +8 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATIO import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE; import static java.util.Arrays.copyOf; import android.annotation.NonNull; Loading Loading @@ -73,6 +72,7 @@ import android.util.Log; import com.android.ims.ImsException; import com.android.ims.ImsManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.Call; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.ISetOpportunisticDataCallback; import com.android.internal.telephony.IccCard; Loading Loading @@ -1678,8 +1678,14 @@ public class PhoneSwitcher extends Handler { } // A phone in voice call might trigger data being switched to it. // Exclude dialing to give modem time to process an EMC first before dealing with DDS switch // Include alerting because modem RLF leads to delay in switch, so carrier required to // switch in alerting phase. // TODO: check ringing call for vDADA return (!phone.getBackgroundCall().isIdle() || !phone.getForegroundCall().isIdle()); && phone.getBackgroundCall().getState() != Call.State.DIALING) || (!phone.getForegroundCall().isIdle() && phone.getForegroundCall().getState() != Call.State.DIALING); } private void updateHalCommandToUse() { Loading
tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,8 @@ import static android.telephony.TelephonyManager.SIM_STATE_LOADED; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE; import static com.android.internal.telephony.data.AutoDataSwitchController.EVALUATION_REASON_VOICE_CALL_END; import static com.android.internal.telephony.data.PhoneSwitcher.ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading Loading @@ -121,6 +119,7 @@ public class PhoneSwitcherTest extends TelephonyTest { private GsmCdmaCall mInactiveCall; private GsmCdmaCall mDialCall; private GsmCdmaCall mIncomingCall; private GsmCdmaCall mAlertingCall; private ISetOpportunisticDataCallback mSetOpptDataCallback1; private ISetOpportunisticDataCallback mSetOpptDataCallback2; PhoneSwitcher.ImsRegTechProvider mMockImsRegTechProvider; Loading Loading @@ -161,6 +160,7 @@ public class PhoneSwitcherTest extends TelephonyTest { mInactiveCall = mock(GsmCdmaCall.class); mDialCall = mock(GsmCdmaCall.class); mIncomingCall = mock(GsmCdmaCall.class); mAlertingCall = mock(GsmCdmaCall.class); mSetOpptDataCallback1 = mock(ISetOpportunisticDataCallback.class); mSetOpptDataCallback2 = mock(ISetOpportunisticDataCallback.class); mMockImsRegTechProvider = mock(PhoneSwitcher.ImsRegTechProvider.class); Loading @@ -176,6 +176,7 @@ public class PhoneSwitcherTest extends TelephonyTest { doReturn(Call.State.HOLDING).when(mHoldingCall).getState(); doReturn(Call.State.DIALING).when(mDialCall).getState(); doReturn(Call.State.INCOMING).when(mIncomingCall).getState(); doReturn(Call.State.ALERTING).when(mAlertingCall).getState(); doReturn(true).when(mInactiveCall).isIdle(); doReturn(false).when(mActiveCall).isIdle(); Loading Loading @@ -878,13 +879,19 @@ public class PhoneSwitcherTest extends TelephonyTest { // Phone 0 should be the default data phoneId. assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId()); // Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled. This should // trigger data switch. // Dialing shouldn't trigger switch because we give modem time to deal with the dialing call // first. Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled. doReturn(mImsPhone).when(mPhone2).getImsPhone(); doReturn(true).when(mPhone2).isDataAllowed(); mockImsRegTech(1, REGISTRATION_TECH_LTE); notifyPhoneAsInDial(mImsPhone); // Phone1 should remain as the preferred data phone assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId()); // Dialing -> Alert, should trigger phone switch notifyPhoneAsAlerting(mImsPhone); // Phone2 should be preferred data phone assertEquals(1, mPhoneSwitcherUT.getPreferredDataPhoneId()); } Loading Loading @@ -1709,6 +1716,12 @@ public class PhoneSwitcherTest extends TelephonyTest { processAllMessages(); } private void notifyPhoneAsAlerting(Phone phone) { doReturn(mAlertingCall).when(phone).getForegroundCall(); mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED); processAllMessages(); } private void notifyPhoneAsInIncomingCall(Phone phone) { doReturn(mIncomingCall).when(phone).getForegroundCall(); mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED); Loading