Fix issue 2265111: Loss of downlink audio while listening, and get a MT call.

The cause of the problem is that under certain circumstance the HeadsetObserver receives unexpected connection events. For instance,
when removing a bad quality 3.5mm stereo jack without mic the following events can be received:
1 connection of a headset with mic
2 removal of a headset with mic.

The result is that the no mic headset is never disconnected and audio policy manager considers it is still present. Then the music or downlink call audio is always routed to headset even if none is connected giving the impression that audio is lost, except whne you reconnect a headset of enable speaker phone.

The fix consists in adding more checks in HeadsetObserver to reject illegal transitions in headset state received from event observer.
1 file changed