AudioDeviceBroker: fix speakerphone state reporting
Send ACTION_SPEAKERPHONE_STATE_CHANGED only when the speakerphone
is actually turned ON/OFF instead of when requested ON/OFF.
Make sure we update the active communication device after the message
requesting the preferred phone strategy device is processed: when no
device is preferred, the actual active device is read back from audio
policy manager.
Also:
- Factored in and use consistent naming for methods dealing with communication
device selection
- Use cached SCO ON state for volume related decisions to avoid lock
contention
Bug: 171177848
Test: AudioManagerTest.testRouting AudioManagerTest.testSpeakerphoneIntent
Test: AudioCommunicationDeviceTest
Change-Id: Ic5e84a1f85f0fa5dac2abed34fc85a58f41e4816
2 files changed