Don't mix internal AVDTP state when connecting to two devices
There is a race condition when connecting to two devices, and
the connection to one of the devices is not powered on.
Because of the race condition, the wrong tBTA_AV_LCB entry inside
bta_av_sig_chg() might be allocated for the connection to
the device that is powered on. As a result of that, when
the connection attempt to the powered off device times out,
we will use the wrong bta_handle to close the existing AVDTP connection to
the device that is connected.
Also:
- Add a new function BTA_AvObtainPeerChannelIndex() to select the
appropriate AvdtpCcb entry if there an outgoing connection request
while an incoming connection is received.
- Added/updated log messages to help debugging similar issues in the future
- Removed unnecessary SetActivePeer() call inside the BtifAv state
machine for A2DP Source to avoid additional internal/transient glitches
Test: Manual
Bug:
79697137
Change-Id: Ie55e3dcf6c6a15637ce3631f2828548a2423d881
Merged-In: Ie55e3dcf6c6a15637ce3631f2828548a2423d881
(cherry picked from commit
1e2cab39a42542f12862df1cd47bf6d90853138b)