Loading src/com/android/server/telecom/CallAudioRoutePeripheralAdapter.java +6 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,12 @@ public class CallAudioRoutePeripheralAdapter implements WiredHeadsetManager.List CallAudioRouteStateMachine.BT_AUDIO_DISCONNECTED); } @Override public void onUnexpectedBluetoothStateChange() { mCallAudioRouteStateMachine.sendMessageWithSessionInfo( CallAudioRouteStateMachine.UPDATE_SYSTEM_AUDIO_ROUTE); } /** * Updates the audio route when the headset plugged in state changes. For example, if audio is * being routed over speakerphone and a headset is plugged in then switch to wired headset. Loading src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,12 @@ public class BluetoothRouteManager extends StateMachine { void onBluetoothActiveDeviceGone(); void onBluetoothAudioConnected(); void onBluetoothAudioDisconnected(); /** * This gets called when we get an unexpected state change from Bluetooth. Their stack does * weird things sometimes, so this is really a signal for the listener to refresh their * internal state and make sure it matches up with what the BT stack is doing. */ void onUnexpectedBluetoothStateChange(); } /** Loading Loading @@ -186,6 +192,7 @@ public class BluetoothRouteManager extends StateMachine { case BT_AUDIO_LOST: Log.i(LOG_TAG, "Received HFP off for device %s while HFP off.", (String) args.arg2); mListener.onUnexpectedBluetoothStateChange(); break; case GET_CURRENT_STATE: BlockingQueue<IState> sink = (BlockingQueue<IState>) args.arg3; Loading Loading @@ -303,6 +310,7 @@ public class BluetoothRouteManager extends StateMachine { } else { Log.w(LOG_TAG, "Got HFP lost message for device %s while" + " connecting to %s.", address, mDeviceAddress); mListener.onUnexpectedBluetoothStateChange(); } break; case GET_CURRENT_STATE: Loading Loading @@ -412,6 +420,7 @@ public class BluetoothRouteManager extends StateMachine { } else { Log.w(LOG_TAG, "Got HFP lost message for device %s while" + " connected to %s.", address, mDeviceAddress); mListener.onUnexpectedBluetoothStateChange(); } break; case GET_CURRENT_STATE: Loading tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +14 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ import static org.mockito.Mockito.when; public class BluetoothRouteTransitionTests extends TelecomTestCase { private enum ListenerUpdate { DEVICE_LIST_CHANGED, ACTIVE_DEVICE_PRESENT, ACTIVE_DEVICE_GONE, AUDIO_CONNECTED, AUDIO_DISCONNECTED AUDIO_CONNECTED, AUDIO_DISCONNECTED, UNEXPECTED_STATE_CHANGE } private static class BluetoothRouteTestParametersBuilder { Loading Loading @@ -563,6 +563,19 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_OFF_STATE_NAME) .build()); result.add(new BluetoothRouteTestParametersBuilder() .setName("Device gets audio-off while in another device's audio on state") .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX) .setInitialDevice(DEVICE2) .setConnectedDevices(DEVICE2, DEVICE1) .setMessageType(BluetoothRouteManager.BT_AUDIO_LOST) .setMessageDevice(DEVICE1) .setExpectedListenerUpdates(ListenerUpdate.UNEXPECTED_STATE_CHANGE) .setExpectedBluetoothInteraction(NONE) .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX + ":" + DEVICE2) .build()); result.add(new BluetoothRouteTestParametersBuilder() .setName("Audio routing requests HFP disconnection while a device is active") .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX) Loading Loading
src/com/android/server/telecom/CallAudioRoutePeripheralAdapter.java +6 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,12 @@ public class CallAudioRoutePeripheralAdapter implements WiredHeadsetManager.List CallAudioRouteStateMachine.BT_AUDIO_DISCONNECTED); } @Override public void onUnexpectedBluetoothStateChange() { mCallAudioRouteStateMachine.sendMessageWithSessionInfo( CallAudioRouteStateMachine.UPDATE_SYSTEM_AUDIO_ROUTE); } /** * Updates the audio route when the headset plugged in state changes. For example, if audio is * being routed over speakerphone and a headset is plugged in then switch to wired headset. Loading
src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,12 @@ public class BluetoothRouteManager extends StateMachine { void onBluetoothActiveDeviceGone(); void onBluetoothAudioConnected(); void onBluetoothAudioDisconnected(); /** * This gets called when we get an unexpected state change from Bluetooth. Their stack does * weird things sometimes, so this is really a signal for the listener to refresh their * internal state and make sure it matches up with what the BT stack is doing. */ void onUnexpectedBluetoothStateChange(); } /** Loading Loading @@ -186,6 +192,7 @@ public class BluetoothRouteManager extends StateMachine { case BT_AUDIO_LOST: Log.i(LOG_TAG, "Received HFP off for device %s while HFP off.", (String) args.arg2); mListener.onUnexpectedBluetoothStateChange(); break; case GET_CURRENT_STATE: BlockingQueue<IState> sink = (BlockingQueue<IState>) args.arg3; Loading Loading @@ -303,6 +310,7 @@ public class BluetoothRouteManager extends StateMachine { } else { Log.w(LOG_TAG, "Got HFP lost message for device %s while" + " connecting to %s.", address, mDeviceAddress); mListener.onUnexpectedBluetoothStateChange(); } break; case GET_CURRENT_STATE: Loading Loading @@ -412,6 +420,7 @@ public class BluetoothRouteManager extends StateMachine { } else { Log.w(LOG_TAG, "Got HFP lost message for device %s while" + " connected to %s.", address, mDeviceAddress); mListener.onUnexpectedBluetoothStateChange(); } break; case GET_CURRENT_STATE: Loading
tests/src/com/android/server/telecom/tests/BluetoothRouteTransitionTests.java +14 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ import static org.mockito.Mockito.when; public class BluetoothRouteTransitionTests extends TelecomTestCase { private enum ListenerUpdate { DEVICE_LIST_CHANGED, ACTIVE_DEVICE_PRESENT, ACTIVE_DEVICE_GONE, AUDIO_CONNECTED, AUDIO_DISCONNECTED AUDIO_CONNECTED, AUDIO_DISCONNECTED, UNEXPECTED_STATE_CHANGE } private static class BluetoothRouteTestParametersBuilder { Loading Loading @@ -563,6 +563,19 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase { .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_OFF_STATE_NAME) .build()); result.add(new BluetoothRouteTestParametersBuilder() .setName("Device gets audio-off while in another device's audio on state") .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX) .setInitialDevice(DEVICE2) .setConnectedDevices(DEVICE2, DEVICE1) .setMessageType(BluetoothRouteManager.BT_AUDIO_LOST) .setMessageDevice(DEVICE1) .setExpectedListenerUpdates(ListenerUpdate.UNEXPECTED_STATE_CHANGE) .setExpectedBluetoothInteraction(NONE) .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX + ":" + DEVICE2) .build()); result.add(new BluetoothRouteTestParametersBuilder() .setName("Audio routing requests HFP disconnection while a device is active") .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX) Loading