Don't reuse AVDTP internal state for different purposes
A number of issues were exposed by carkits that proactively try
to discover the codecs supported by the Phone and explicitly select
the A2DP codec.
* Don't reuse p_scb->p_cap for storing the most recent fetched capability
and for storing the result configuration while reconfiguring the stream.
Instead, use p_scb->cfg for storing the result configuration.
* Don't try to reconfigure the audio stream before all peer's capabilities
have been retrieved.
* Don't reset p_scb->sep_info_idx after fetching all capabilities inside
bta_av_save_caps(), otherwise the stream reconfiguration logic is
confused. Apparently, p_scb->sep_info_idx is overused for both:
(a) Pointing where to store the next capability while fetching the
capabilities.
(b) Storing the selected the SEP after the codec selection is completed.
Resetting p_scb->sep_info_idx to 0 creates logical confusion when the
actual selected SEP index is 0.
* Add extra debug log messages
Test: Connecting to and streaming with various carkits
Bug:
64128712
Change-Id: I5f57e9069d5402bcbb17613470ac0d29c8e45069