Bluetooth A2DP Sink connection
Turn on Bluetooth and allow Bluetooth to be detected, then use your mobile phone to connect to this device and make an A2DP Sink connection. When connecting, call com_android_bluetooth_a2dp_sink.cpp bta2dp_connection_state_callback()
-->A2dpSinkStateMachine.java onConnectionStateChanged() to send EVENT_TYPE_CONNECTION_STATE_CHANGED broadcast
-->A2dpSinkStateMachine.java Disconnected The current state of .processConnectionEvent()
is Disconnected, and the new state is CONNECTION_STATE_CONNECTING:
The above code first does some audio-related processing (it will not be analyzed here), then sends the broadcast MSG_CONNECTION_STATE_CHANGED and switches the state to Pending.
-->A2dpSinkStateMachine.java IntentBroadcastHandler.handleMessage()
-->A2dpSinkStateMachine.java IntentBroadcastHandler.onConnectionStateChanged()
sends a broadcast CONNECTION_STATE_CHANGED, but this broadcast was not processed in the end (so the Setting software interface was not updated). Finally call Profile.notifyProfileConnectionStateChanged().
Then com_android_bluetooth_a2dp_sink.cpp bta2dp_audio_config_callback() is called:
the status is Pending at this time:
processAudioConfigEvent() is called to notify the change of audio format.
Then com_android_bluetooth_a2dp_sink.cpp bta2dp_connection_state_callback() is called again:
at this time the state is Pending:
AudioManager.setBluetoothA2dpDeviceConnectionState() is called as before, but because the state becomes Connected, some audio source switching operations will be performed. Then the broadcast is sent, and the Setting application does not handle it. Finally, change the status to Connected.
A broadcast is sent, but the native setup code does not handle it.