Change optional codec status when selectable codec is valid

* Fix A2DP service change optional codec status before
  native finish query codec capabilities if remote set
  codec before us, which leads to codec change failure
  and no sound problems.
* Add logic to update optional codec status when selectable
  codec changes.
* Synchronize updateOptionalCodecs() -> setActiveDevice() flow
  by moving the logic from A2dpService to A2dpStateMachine
  Connected state. This is to prevent race condition between
  audio start output and Bluetooth codec status change.
* Add unit test for these changes.

Bug: 124254557
Bug: 125551347
Test: runtest bluetooth, manual.
Change-Id: Ie7f04ed1805114d9494d8825135995ff4c87fa26
4 files changed