Loading src/com/android/server/telecom/Call.java +1 −1 Original line number Diff line number Diff line Loading @@ -2518,7 +2518,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * networks at least), so we still enable this feature even though * SMSes to that number will silently fail. */ boolean isRespondViaSmsCapable() { public boolean isRespondViaSmsCapable() { if (mState != CallState.RINGING) { return false; } Loading src/com/android/server/telecom/CallsManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1945,7 +1945,7 @@ public class CallsManager extends Call.ListenerBase } else { // Hold or disconnect the active call and request call focus for the incoming call. Call activeCall = (Call) mConnectionSvrFocusMgr.getCurrentFocusCall(); Log.d(this, "Incoming call = %s Ongoing call %s", call, activeCall); Log.d(this, "answerCall: Incoming call = %s Ongoing call %s", call, activeCall); holdActiveCallForNewCall(call); mConnectionSvrFocusMgr.requestFocus( call, Loading Loading @@ -4449,7 +4449,7 @@ public class CallsManager extends Call.ListenerBase } private boolean canHold(Call call) { return call.can(Connection.CAPABILITY_HOLD); return call.can(Connection.CAPABILITY_HOLD) && call.getState() != CallState.DIALING; } private boolean supportsHold(Call call) { Loading testapps/src/com/android/server/telecom/testapps/SelfManagedConnectionService.java +2 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,8 @@ public class SelfManagedConnectionService extends ConnectionService { if (isIncoming) { connection.setIsIncomingCallUiShowing(request.shouldShowIncomingCallUi()); connection.setRinging(); } else { connection.setDialing(); } Bundle requestExtras = request.getExtras(); if (requestExtras != null) { Loading tests/src/com/android/server/telecom/tests/CallsManagerTest.java +34 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public class CallsManagerTest extends TelecomTestCase { private static final PhoneAccountHandle VOIP_1_HANDLE = new PhoneAccountHandle( ComponentName.unflattenFromString("com.voip/.Stuff"), "Voip1"); private static final PhoneAccountHandle SELF_MANAGED_HANDLE = new PhoneAccountHandle( ComponentName.unflattenFromString("com.foo/.Self"), "Self"); ComponentName.unflattenFromString("com.baz/.Self"), "Self"); private static final PhoneAccount SIM_1_ACCOUNT = new PhoneAccount.Builder(SIM_1_HANDLE, "Sim1") .setCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION | PhoneAccount.CAPABILITY_CALL_PROVIDER) Loading Loading @@ -820,6 +820,39 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(CallState.ACTIVE, newCall.getState()); } @SmallTest @Test public void testDisconnectDialingCallOnIncoming() { // GIVEN a CallsManager with a self-managed call which is dialing, and this call can be held Call ongoingCall = addSpyCall(SELF_MANAGED_HANDLE); ongoingCall.setState(CallState.DIALING, "test"); doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_HOLD); doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_SUPPORT_HOLD); doReturn(true).when(ongoingCall).isSelfManaged(); doReturn(ongoingCall).when(mConnectionSvrFocusMgr).getCurrentFocusCall(); // and a new incoming managed call Call newCall = addSpyCall(); doReturn(false).when(newCall).isRespondViaSmsCapable(); newCall.setState(CallState.RINGING, "test"); // WHEN answering the new call mCallsManager.answerCall(newCall, VideoProfile.STATE_AUDIO_ONLY); // THEN the ongoing call is disconnected verify(ongoingCall).disconnect(); // AND focus is requested for the new call ArgumentCaptor<CallsManager.RequestCallback> requestCaptor = ArgumentCaptor.forClass(CallsManager.RequestCallback.class); verify(mConnectionSvrFocusMgr).requestFocus(eq(newCall), requestCaptor.capture()); // since we're mocking the focus manager, we'll just pretend it did its thing. requestCaptor.getValue().onRequestFocusDone(newCall); // and the new call is marked answered assertEquals(CallState.ANSWERED, newCall.getState()); } @SmallTest @Test public void testNoFilteringOfSelfManagedCalls() { Loading Loading
src/com/android/server/telecom/Call.java +1 −1 Original line number Diff line number Diff line Loading @@ -2518,7 +2518,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, * networks at least), so we still enable this feature even though * SMSes to that number will silently fail. */ boolean isRespondViaSmsCapable() { public boolean isRespondViaSmsCapable() { if (mState != CallState.RINGING) { return false; } Loading
src/com/android/server/telecom/CallsManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1945,7 +1945,7 @@ public class CallsManager extends Call.ListenerBase } else { // Hold or disconnect the active call and request call focus for the incoming call. Call activeCall = (Call) mConnectionSvrFocusMgr.getCurrentFocusCall(); Log.d(this, "Incoming call = %s Ongoing call %s", call, activeCall); Log.d(this, "answerCall: Incoming call = %s Ongoing call %s", call, activeCall); holdActiveCallForNewCall(call); mConnectionSvrFocusMgr.requestFocus( call, Loading Loading @@ -4449,7 +4449,7 @@ public class CallsManager extends Call.ListenerBase } private boolean canHold(Call call) { return call.can(Connection.CAPABILITY_HOLD); return call.can(Connection.CAPABILITY_HOLD) && call.getState() != CallState.DIALING; } private boolean supportsHold(Call call) { Loading
testapps/src/com/android/server/telecom/testapps/SelfManagedConnectionService.java +2 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,8 @@ public class SelfManagedConnectionService extends ConnectionService { if (isIncoming) { connection.setIsIncomingCallUiShowing(request.shouldShowIncomingCallUi()); connection.setRinging(); } else { connection.setDialing(); } Bundle requestExtras = request.getExtras(); if (requestExtras != null) { Loading
tests/src/com/android/server/telecom/tests/CallsManagerTest.java +34 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public class CallsManagerTest extends TelecomTestCase { private static final PhoneAccountHandle VOIP_1_HANDLE = new PhoneAccountHandle( ComponentName.unflattenFromString("com.voip/.Stuff"), "Voip1"); private static final PhoneAccountHandle SELF_MANAGED_HANDLE = new PhoneAccountHandle( ComponentName.unflattenFromString("com.foo/.Self"), "Self"); ComponentName.unflattenFromString("com.baz/.Self"), "Self"); private static final PhoneAccount SIM_1_ACCOUNT = new PhoneAccount.Builder(SIM_1_HANDLE, "Sim1") .setCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION | PhoneAccount.CAPABILITY_CALL_PROVIDER) Loading Loading @@ -820,6 +820,39 @@ public class CallsManagerTest extends TelecomTestCase { assertEquals(CallState.ACTIVE, newCall.getState()); } @SmallTest @Test public void testDisconnectDialingCallOnIncoming() { // GIVEN a CallsManager with a self-managed call which is dialing, and this call can be held Call ongoingCall = addSpyCall(SELF_MANAGED_HANDLE); ongoingCall.setState(CallState.DIALING, "test"); doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_HOLD); doReturn(true).when(ongoingCall).can(Connection.CAPABILITY_SUPPORT_HOLD); doReturn(true).when(ongoingCall).isSelfManaged(); doReturn(ongoingCall).when(mConnectionSvrFocusMgr).getCurrentFocusCall(); // and a new incoming managed call Call newCall = addSpyCall(); doReturn(false).when(newCall).isRespondViaSmsCapable(); newCall.setState(CallState.RINGING, "test"); // WHEN answering the new call mCallsManager.answerCall(newCall, VideoProfile.STATE_AUDIO_ONLY); // THEN the ongoing call is disconnected verify(ongoingCall).disconnect(); // AND focus is requested for the new call ArgumentCaptor<CallsManager.RequestCallback> requestCaptor = ArgumentCaptor.forClass(CallsManager.RequestCallback.class); verify(mConnectionSvrFocusMgr).requestFocus(eq(newCall), requestCaptor.capture()); // since we're mocking the focus manager, we'll just pretend it did its thing. requestCaptor.getValue().onRequestFocusDone(newCall); // and the new call is marked answered assertEquals(CallState.ANSWERED, newCall.getState()); } @SmallTest @Test public void testNoFilteringOfSelfManagedCalls() { Loading