Android 9 native settings about Bluetooth settings (6)

Bluetooth A2DP Sink connection

Insert image description here
  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:
Insert image description here
Insert image description here
  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()
Insert image description here
  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:
Insert image description here
  the status is Pending at this time:
Insert image description here
  processAudioConfigEvent() is called to notify the change of audio format.
  

  Then com_android_bluetooth_a2dp_sink.cpp bta2dp_connection_state_callback() is called again:
Insert image description here
at this time the state is Pending:
Insert image description here
Insert image description here
Insert image description here
  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.
Insert image description here
A broadcast is sent, but the native setup code does not handle it.

Guess you like

Origin blog.csdn.net/suwen8100/article/details/126706805