Loading src/com/android/server/telecom/CallAudioRouteStateMachine.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -1215,7 +1215,13 @@ public class CallAudioRouteStateMachine extends StateMachine { // Expected, since we just transitioned here // Expected, since we just transitioned here return HANDLED; return HANDLED; case SPEAKER_OFF: case SPEAKER_OFF: // Check if we already requested to connect to other devices and just waiting // for their response. In some cases, this SPEAKER_OFF message may come in // before the response, we can just ignore the message here to not re-evaluate // the baseline route incorrectly if (!mBluetoothRouteManager.isBluetoothAudioConnectedOrPending()) { sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE); sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE); } return HANDLED; return HANDLED; case SWITCH_FOCUS: case SWITCH_FOCUS: if (msg.arg1 == NO_FOCUS) { if (msg.arg1 == NO_FOCUS) { Loading tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java +42 −11 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Matchers.any; Loading Loading @@ -173,7 +174,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_AUTO_DETECT, CallAudioRouteStateMachine.EARPIECE_AUTO_DETECT, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -219,7 +219,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, Loading Loading @@ -263,7 +262,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(false); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(false); Loading Loading @@ -309,7 +307,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -354,7 +351,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Collection<BluetoothDevice> availableDevices = Collections.singleton(bluetoothDevice1); Collection<BluetoothDevice> availableDevices = Collections.singleton(bluetoothDevice1); Loading Loading @@ -433,7 +429,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -470,7 +465,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); setInBandRing(false); setInBandRing(false); Loading Loading @@ -526,7 +520,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); List<BluetoothDevice> availableDevices = List<BluetoothDevice> availableDevices = Loading Loading @@ -577,7 +570,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); when(mockAudioManager.isSpeakerphoneOn()).thenReturn(false); when(mockAudioManager.isSpeakerphoneOn()).thenReturn(false); Loading Loading @@ -609,7 +601,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -644,7 +635,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); List<BluetoothDevice> availableDevices = List<BluetoothDevice> availableDevices = Loading Loading @@ -798,6 +788,47 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { assertEquals(initState, stateMachine.getCurrentCallAudioState()); assertEquals(initState, stateMachine.getCurrentCallAudioState()); } } @SmallTest @Test public void testIgnoreSpeakerOffMessage() { when(mockBluetoothRouteManager.isInbandRingingEnabled()).thenReturn(true); when(mockBluetoothRouteManager.getBluetoothAudioConnectedDevice()) .thenReturn(bluetoothDevice1); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(true); CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine( mContext, mockCallsManager, mockBluetoothRouteManager, mockWiredHeadsetManager, mockStatusBarNotifier, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER | CallAudioState.ROUTE_BLUETOOTH); stateMachine.initialize(initState); doAnswer( (address) -> { stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SPEAKER_OFF); stateMachine.sendMessageDelayed(CallAudioRouteStateMachine.BT_AUDIO_CONNECTED, 5000L); return null; }).when(mockBluetoothRouteManager).connectBluetoothAudio(anyString()); stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS, CallAudioRouteStateMachine.ACTIVE_FOCUS); stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.USER_SWITCH_BLUETOOTH); CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState.ROUTE_SPEAKER | CallAudioState.ROUTE_BLUETOOTH | CallAudioState.ROUTE_EARPIECE); assertEquals(expectedState, stateMachine.getCurrentCallAudioState()); } private void initializationTestHelper(CallAudioState expectedState, private void initializationTestHelper(CallAudioState expectedState, int earpieceControl) { int earpieceControl) { when(mockWiredHeadsetManager.isPluggedIn()).thenReturn( when(mockWiredHeadsetManager.isPluggedIn()).thenReturn( Loading Loading
src/com/android/server/telecom/CallAudioRouteStateMachine.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -1215,7 +1215,13 @@ public class CallAudioRouteStateMachine extends StateMachine { // Expected, since we just transitioned here // Expected, since we just transitioned here return HANDLED; return HANDLED; case SPEAKER_OFF: case SPEAKER_OFF: // Check if we already requested to connect to other devices and just waiting // for their response. In some cases, this SPEAKER_OFF message may come in // before the response, we can just ignore the message here to not re-evaluate // the baseline route incorrectly if (!mBluetoothRouteManager.isBluetoothAudioConnectedOrPending()) { sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE); sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE); } return HANDLED; return HANDLED; case SWITCH_FOCUS: case SWITCH_FOCUS: if (msg.arg1 == NO_FOCUS) { if (msg.arg1 == NO_FOCUS) { Loading
tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java +42 −11 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Matchers.any; Loading Loading @@ -173,7 +174,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_AUTO_DETECT, CallAudioRouteStateMachine.EARPIECE_AUTO_DETECT, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -219,7 +219,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, Loading Loading @@ -263,7 +262,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(false); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(false); Loading Loading @@ -309,7 +307,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -354,7 +351,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Collection<BluetoothDevice> availableDevices = Collections.singleton(bluetoothDevice1); Collection<BluetoothDevice> availableDevices = Collections.singleton(bluetoothDevice1); Loading Loading @@ -433,7 +429,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -470,7 +465,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); setInBandRing(false); setInBandRing(false); Loading Loading @@ -526,7 +520,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); List<BluetoothDevice> availableDevices = List<BluetoothDevice> availableDevices = Loading Loading @@ -577,7 +570,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); when(mockAudioManager.isSpeakerphoneOn()).thenReturn(false); when(mockAudioManager.isSpeakerphoneOn()).thenReturn(false); Loading Loading @@ -609,7 +601,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); Loading Loading @@ -644,7 +635,6 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { mockStatusBarNotifier, mockStatusBarNotifier, mAudioServiceFactory, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); stateMachine.setCallAudioManager(mockCallAudioManager); List<BluetoothDevice> availableDevices = List<BluetoothDevice> availableDevices = Loading Loading @@ -798,6 +788,47 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase { assertEquals(initState, stateMachine.getCurrentCallAudioState()); assertEquals(initState, stateMachine.getCurrentCallAudioState()); } } @SmallTest @Test public void testIgnoreSpeakerOffMessage() { when(mockBluetoothRouteManager.isInbandRingingEnabled()).thenReturn(true); when(mockBluetoothRouteManager.getBluetoothAudioConnectedDevice()) .thenReturn(bluetoothDevice1); when(mockBluetoothRouteManager.isBluetoothAudioConnectedOrPending()).thenReturn(true); CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine( mContext, mockCallsManager, mockBluetoothRouteManager, mockWiredHeadsetManager, mockStatusBarNotifier, mAudioServiceFactory, CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED, mThreadHandler.getLooper(), Runnable::run /** do async stuff sync for test purposes */); stateMachine.setCallAudioManager(mockCallAudioManager); CallAudioState initState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER | CallAudioState.ROUTE_BLUETOOTH); stateMachine.initialize(initState); doAnswer( (address) -> { stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SPEAKER_OFF); stateMachine.sendMessageDelayed(CallAudioRouteStateMachine.BT_AUDIO_CONNECTED, 5000L); return null; }).when(mockBluetoothRouteManager).connectBluetoothAudio(anyString()); stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS, CallAudioRouteStateMachine.ACTIVE_FOCUS); stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.USER_SWITCH_BLUETOOTH); CallAudioState expectedState = new CallAudioState(false, CallAudioState.ROUTE_SPEAKER, CallAudioState.ROUTE_SPEAKER | CallAudioState.ROUTE_BLUETOOTH | CallAudioState.ROUTE_EARPIECE); assertEquals(expectedState, stateMachine.getCurrentCallAudioState()); } private void initializationTestHelper(CallAudioState expectedState, private void initializationTestHelper(CallAudioState expectedState, int earpieceControl) { int earpieceControl) { when(mockWiredHeadsetManager.isPluggedIn()).thenReturn( when(mockWiredHeadsetManager.isPluggedIn()).thenReturn( Loading