Loading src/com/android/server/telecom/CallEndpointController.java +11 −1 Original line number Diff line number Diff line Loading @@ -64,12 +64,14 @@ public class CallEndpointController extends CallsManagerListenerBase { mRouteToTypeMap.put(CallAudioState.ROUTE_BLUETOOTH, CallEndpoint.TYPE_BLUETOOTH); mRouteToTypeMap.put(CallAudioState.ROUTE_WIRED_HEADSET, CallEndpoint.TYPE_WIRED_HEADSET); mRouteToTypeMap.put(CallAudioState.ROUTE_SPEAKER, CallEndpoint.TYPE_SPEAKER); mRouteToTypeMap.put(CallAudioState.ROUTE_STREAMING, CallEndpoint.TYPE_STREAMING); mTypeToRouteMap = new HashMap<>(5); mTypeToRouteMap.put(CallEndpoint.TYPE_EARPIECE, CallAudioState.ROUTE_EARPIECE); mTypeToRouteMap.put(CallEndpoint.TYPE_BLUETOOTH, CallAudioState.ROUTE_BLUETOOTH); mTypeToRouteMap.put(CallEndpoint.TYPE_WIRED_HEADSET, CallAudioState.ROUTE_WIRED_HEADSET); mTypeToRouteMap.put(CallEndpoint.TYPE_SPEAKER, CallAudioState.ROUTE_SPEAKER); mTypeToRouteMap.put(CallEndpoint.TYPE_STREAMING, CallAudioState.ROUTE_STREAMING); } @VisibleForTesting Loading Loading @@ -207,7 +209,15 @@ public class CallEndpointController extends CallsManagerListenerBase { mRouteToTypeMap.forEach((route, type)->{ if ((state.getSupportedRouteMask() & route) != 0) { if (type == CallEndpoint.TYPE_BLUETOOTH) { if (type == CallEndpoint.TYPE_STREAMING) { if (state.getRoute() == CallAudioState.ROUTE_STREAMING) { if (mActiveCallEndpoint == null || mActiveCallEndpoint.getEndpointType() != type) { mActiveCallEndpoint = new CallEndpoint(getEndpointName(type) != null ? getEndpointName(type) : "", type); } } } else if (type == CallEndpoint.TYPE_BLUETOOTH) { for (BluetoothDevice device : state.getSupportedBluetoothDevices()) { CallEndpoint endpoint = findMatchingBluetoothEndpoint(device); if (endpoint == null) { Loading tests/src/com/android/server/telecom/tests/CallEndpointControllerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -78,6 +79,8 @@ public class CallEndpointControllerTest extends TelecomTestCase { private static final CallAudioState audioState6 = new CallAudioState(false, CallAudioState.ROUTE_EARPIECE, CallAudioState.ROUTE_EARPIECE, null, availableBluetooth1); private static final CallAudioState audioState7 = new CallAudioState(false, CallAudioState.ROUTE_STREAMING, CallAudioState.ROUTE_ALL, null, availableBluetooth1); private CallEndpointController mCallEndpointController; Loading Loading @@ -132,6 +135,27 @@ public class CallEndpointControllerTest extends TelecomTestCase { verify(mConnectionService, never()).onMuteStateChanged(any(), anyBoolean()); } @Test public void testCurrentEndpointChangedToStreaming() throws Exception { mCallEndpointController.onCallAudioStateChanged(audioState1, audioState7); CallEndpoint endpoint = mCallEndpointController.getCurrentCallEndpoint(); Set<CallEndpoint> availableEndpoints = mCallEndpointController.getAvailableEndpoints(); // Only Streaming is available, but it will not be reported via the available endpoints list assertEquals(0, availableEndpoints.size()); assertNotNull(availableEndpoints); // type of current CallEndpoint is Streaming assertEquals(CallEndpoint.TYPE_STREAMING, endpoint.getEndpointType()); verify(mCallsManager).updateCallEndpoint(eq(endpoint)); verify(mConnectionService, times(1)).onCallEndpointChanged(eq(mCall), eq(endpoint)); verify(mCallsManager).updateAvailableCallEndpoints(eq(availableEndpoints)); verify(mConnectionService, times(1)).onAvailableCallEndpointsChanged(eq(mCall), eq(availableEndpoints)); verify(mCallsManager, never()).updateMuteState(anyBoolean()); verify(mConnectionService, never()).onMuteStateChanged(any(), anyBoolean()); } @Test public void testCurrentEndpointChangedBetweenBluetooth() throws Exception { mCallEndpointController.onCallAudioStateChanged(audioState2, audioState3); Loading Loading
src/com/android/server/telecom/CallEndpointController.java +11 −1 Original line number Diff line number Diff line Loading @@ -64,12 +64,14 @@ public class CallEndpointController extends CallsManagerListenerBase { mRouteToTypeMap.put(CallAudioState.ROUTE_BLUETOOTH, CallEndpoint.TYPE_BLUETOOTH); mRouteToTypeMap.put(CallAudioState.ROUTE_WIRED_HEADSET, CallEndpoint.TYPE_WIRED_HEADSET); mRouteToTypeMap.put(CallAudioState.ROUTE_SPEAKER, CallEndpoint.TYPE_SPEAKER); mRouteToTypeMap.put(CallAudioState.ROUTE_STREAMING, CallEndpoint.TYPE_STREAMING); mTypeToRouteMap = new HashMap<>(5); mTypeToRouteMap.put(CallEndpoint.TYPE_EARPIECE, CallAudioState.ROUTE_EARPIECE); mTypeToRouteMap.put(CallEndpoint.TYPE_BLUETOOTH, CallAudioState.ROUTE_BLUETOOTH); mTypeToRouteMap.put(CallEndpoint.TYPE_WIRED_HEADSET, CallAudioState.ROUTE_WIRED_HEADSET); mTypeToRouteMap.put(CallEndpoint.TYPE_SPEAKER, CallAudioState.ROUTE_SPEAKER); mTypeToRouteMap.put(CallEndpoint.TYPE_STREAMING, CallAudioState.ROUTE_STREAMING); } @VisibleForTesting Loading Loading @@ -207,7 +209,15 @@ public class CallEndpointController extends CallsManagerListenerBase { mRouteToTypeMap.forEach((route, type)->{ if ((state.getSupportedRouteMask() & route) != 0) { if (type == CallEndpoint.TYPE_BLUETOOTH) { if (type == CallEndpoint.TYPE_STREAMING) { if (state.getRoute() == CallAudioState.ROUTE_STREAMING) { if (mActiveCallEndpoint == null || mActiveCallEndpoint.getEndpointType() != type) { mActiveCallEndpoint = new CallEndpoint(getEndpointName(type) != null ? getEndpointName(type) : "", type); } } } else if (type == CallEndpoint.TYPE_BLUETOOTH) { for (BluetoothDevice device : state.getSupportedBluetoothDevices()) { CallEndpoint endpoint = findMatchingBluetoothEndpoint(device); if (endpoint == null) { Loading
tests/src/com/android/server/telecom/tests/CallEndpointControllerTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -78,6 +79,8 @@ public class CallEndpointControllerTest extends TelecomTestCase { private static final CallAudioState audioState6 = new CallAudioState(false, CallAudioState.ROUTE_EARPIECE, CallAudioState.ROUTE_EARPIECE, null, availableBluetooth1); private static final CallAudioState audioState7 = new CallAudioState(false, CallAudioState.ROUTE_STREAMING, CallAudioState.ROUTE_ALL, null, availableBluetooth1); private CallEndpointController mCallEndpointController; Loading Loading @@ -132,6 +135,27 @@ public class CallEndpointControllerTest extends TelecomTestCase { verify(mConnectionService, never()).onMuteStateChanged(any(), anyBoolean()); } @Test public void testCurrentEndpointChangedToStreaming() throws Exception { mCallEndpointController.onCallAudioStateChanged(audioState1, audioState7); CallEndpoint endpoint = mCallEndpointController.getCurrentCallEndpoint(); Set<CallEndpoint> availableEndpoints = mCallEndpointController.getAvailableEndpoints(); // Only Streaming is available, but it will not be reported via the available endpoints list assertEquals(0, availableEndpoints.size()); assertNotNull(availableEndpoints); // type of current CallEndpoint is Streaming assertEquals(CallEndpoint.TYPE_STREAMING, endpoint.getEndpointType()); verify(mCallsManager).updateCallEndpoint(eq(endpoint)); verify(mConnectionService, times(1)).onCallEndpointChanged(eq(mCall), eq(endpoint)); verify(mCallsManager).updateAvailableCallEndpoints(eq(availableEndpoints)); verify(mConnectionService, times(1)).onAvailableCallEndpointsChanged(eq(mCall), eq(availableEndpoints)); verify(mCallsManager, never()).updateMuteState(anyBoolean()); verify(mConnectionService, never()).onMuteStateChanged(any(), anyBoolean()); } @Test public void testCurrentEndpointChangedBetweenBluetooth() throws Exception { mCallEndpointController.onCallAudioStateChanged(audioState2, audioState3); Loading