Loading src/com/android/server/telecom/CallsManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -3187,7 +3187,10 @@ public class CallsManager extends Call.ListenerBase isEmergency); // Only one SIM PhoneAccount can be active at one time for DSDS. Only that SIM PhoneAccount // should be available if a call is already active on the SIM account. if (!isDsdaCallingPossible()) { // Similarly, the emergency call should be attempted over the same PhoneAccount as the // ongoing call. However, if the ongoing call is over cross-SIM registration, then the // emergency call will be attempted over a different Phone object at a later stage. if (isEmergency || !isDsdaCallingPossible()) { List<PhoneAccountHandle> simAccounts = mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser(); PhoneAccountHandle ongoingCallAccount = null; Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +65 −12 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.CarrierConfigManager; import android.telephony.PhoneCapability; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -243,6 +244,7 @@ public class CallsManagerTest extends TelecomTestCase { @Mock private AnomalyReporterAdapter mAnomalyReporterAdapter; @Mock private Ringer.AccessibilityManagerAdapter mAccessibilityManagerAdapter; @Mock private BlockedNumbersAdapter mBlockedNumbersAdapter; @Mock private PhoneCapability mPhoneCapability; private CallsManager mCallsManager; Loading Loading @@ -335,18 +337,9 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(0, mCallsManager.constructPossiblePhoneAccounts(null, null, false, false).size()); } /** * Verify behavior for multisim devices where we want to ensure that the active sim is used for * placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception { setupMsimAccounts(); private Call constructOngoingCall(String callId, PhoneAccountHandle phoneAccountHandle) { Call ongoingCall = new Call( "1", /* callId */ callId, mContext, mCallsManager, mLock, Loading @@ -355,13 +348,26 @@ public class CallsManagerTest extends TelecomTestCase { TEST_ADDRESS, null /* GatewayInfo */, null /* connectionManagerPhoneAccountHandle */, SIM_2_HANDLE, phoneAccountHandle, Call.CALL_DIRECTION_INCOMING, false /* shouldAttachToExistingConnection*/, false /* isConference */, mClockProxy, mToastFactory); ongoingCall.setState(CallState.ACTIVE, "just cuz"); return ongoingCall; } /** * Verify behavior for multisim devices where we want to ensure that the active sim is used for * placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception { setupMsimAccounts(); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( Loading @@ -384,6 +390,47 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(2, phoneAccountHandles.size()); } /** * For DSDA-enabled multisim devices with an ongoing call, verify that both SIMs' * PhoneAccountHandles are constructed while placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible() throws Exception { setupMsimAccounts(); setMaxActiveVoiceSubscriptions(2); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( TEST_ADDRESS, null, false, false); assertEquals(2, phoneAccountHandles.size()); } /** * For DSDA-enabled multisim devices with an ongoing call, verify that only the active SIMs' * PhoneAccountHandle is constructed while placing an emergency call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible_emergencyCall() throws Exception { setupMsimAccounts(); setMaxActiveVoiceSubscriptions(2); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( TEST_ADDRESS, null, false, true /* isEmergency */); assertEquals(1, phoneAccountHandles.size()); assertEquals(SIM_2_HANDLE, phoneAccountHandles.get(0)); } private void setupCallerInfoLookupHelper() { doAnswer(invocation -> { Uri handle = invocation.getArgument(0); Loading Loading @@ -2866,4 +2913,10 @@ public class CallsManagerTest extends TelecomTestCase { when(mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser()).thenReturn( new ArrayList<>(Arrays.asList(SIM_1_HANDLE, SIM_2_HANDLE))); } private void setMaxActiveVoiceSubscriptions(int num) { TelephonyManager mockTelephonyManager = mComponentContextFixture.getTelephonyManager(); when(mockTelephonyManager.getPhoneCapability()).thenReturn(mPhoneCapability); when(mPhoneCapability.getMaxActiveVoiceSubscriptions()).thenReturn(num); } } Loading
src/com/android/server/telecom/CallsManager.java +4 −1 Original line number Diff line number Diff line Loading @@ -3187,7 +3187,10 @@ public class CallsManager extends Call.ListenerBase isEmergency); // Only one SIM PhoneAccount can be active at one time for DSDS. Only that SIM PhoneAccount // should be available if a call is already active on the SIM account. if (!isDsdaCallingPossible()) { // Similarly, the emergency call should be attempted over the same PhoneAccount as the // ongoing call. However, if the ongoing call is over cross-SIM registration, then the // emergency call will be attempted over a different Phone object at a later stage. if (isEmergency || !isDsdaCallingPossible()) { List<PhoneAccountHandle> simAccounts = mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser(); PhoneAccountHandle ongoingCallAccount = null; Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +65 −12 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.CarrierConfigManager; import android.telephony.PhoneCapability; import android.telephony.TelephonyManager; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -243,6 +244,7 @@ public class CallsManagerTest extends TelecomTestCase { @Mock private AnomalyReporterAdapter mAnomalyReporterAdapter; @Mock private Ringer.AccessibilityManagerAdapter mAccessibilityManagerAdapter; @Mock private BlockedNumbersAdapter mBlockedNumbersAdapter; @Mock private PhoneCapability mPhoneCapability; private CallsManager mCallsManager; Loading Loading @@ -335,18 +337,9 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(0, mCallsManager.constructPossiblePhoneAccounts(null, null, false, false).size()); } /** * Verify behavior for multisim devices where we want to ensure that the active sim is used for * placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception { setupMsimAccounts(); private Call constructOngoingCall(String callId, PhoneAccountHandle phoneAccountHandle) { Call ongoingCall = new Call( "1", /* callId */ callId, mContext, mCallsManager, mLock, Loading @@ -355,13 +348,26 @@ public class CallsManagerTest extends TelecomTestCase { TEST_ADDRESS, null /* GatewayInfo */, null /* connectionManagerPhoneAccountHandle */, SIM_2_HANDLE, phoneAccountHandle, Call.CALL_DIRECTION_INCOMING, false /* shouldAttachToExistingConnection*/, false /* isConference */, mClockProxy, mToastFactory); ongoingCall.setState(CallState.ACTIVE, "just cuz"); return ongoingCall; } /** * Verify behavior for multisim devices where we want to ensure that the active sim is used for * placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception { setupMsimAccounts(); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( Loading @@ -384,6 +390,47 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(2, phoneAccountHandles.size()); } /** * For DSDA-enabled multisim devices with an ongoing call, verify that both SIMs' * PhoneAccountHandles are constructed while placing a new call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible() throws Exception { setupMsimAccounts(); setMaxActiveVoiceSubscriptions(2); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( TEST_ADDRESS, null, false, false); assertEquals(2, phoneAccountHandles.size()); } /** * For DSDA-enabled multisim devices with an ongoing call, verify that only the active SIMs' * PhoneAccountHandle is constructed while placing an emergency call. * @throws Exception */ @MediumTest @Test public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible_emergencyCall() throws Exception { setupMsimAccounts(); setMaxActiveVoiceSubscriptions(2); Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE); mCallsManager.addCall(ongoingCall); List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts( TEST_ADDRESS, null, false, true /* isEmergency */); assertEquals(1, phoneAccountHandles.size()); assertEquals(SIM_2_HANDLE, phoneAccountHandles.get(0)); } private void setupCallerInfoLookupHelper() { doAnswer(invocation -> { Uri handle = invocation.getArgument(0); Loading Loading @@ -2866,4 +2913,10 @@ public class CallsManagerTest extends TelecomTestCase { when(mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser()).thenReturn( new ArrayList<>(Arrays.asList(SIM_1_HANDLE, SIM_2_HANDLE))); } private void setMaxActiveVoiceSubscriptions(int num) { TelephonyManager mockTelephonyManager = mComponentContextFixture.getTelephonyManager(); when(mockTelephonyManager.getPhoneCapability()).thenReturn(mPhoneCapability); when(mPhoneCapability.getMaxActiveVoiceSubscriptions()).thenReturn(num); } }