Ensure MediaSession is ONLY made active when routed to wired headset.
In the past we always made a global MediaSession active in Telecom when
there was a call present on the device. This was to ensure that when the
device used a wired headset that we'd be able to handle the button presses.
Due to our more recent change to not inform HFP devices of DND calls, we
saw a regression in car head unit operation during calls in DND. Because
the HFP device is no longer made aware of DND calls and we were still
opening a media session, HFP car kits were not properly routing control
to an ongoing music playback session.
Modified Telecom's HeadsetMediaButton class to ONLY open a media session if
there is a call present and the audio is routed to a wired headset.
Control of calls via bluetooth headsets are always routed via the
BluetoothInCallService and never rely on keycode events. Further, when
routed to speaker or earpiece, there are never going to be "pause/resume"
media keycode events that Telecom needs to handle.
Test: Manaul test with wired headset to ensure basic operation of media
buttons on wired headset operate as expected.
Test: Added new unit test cases to ensure media session is not started until
we are routed to a wired headset.
Test: Fix existing unit tests to account for the new behavior.
Fixes: 266171157
Change-Id: I9098062299d6a6e60bc7dadd0d23c81b76d1fb6e
2 files changed