Optimize how AudioService receives media button events

AudioService maintains a stack of registered media button event
  receivers.
This change modifies the broadcasters of ACTION_MEDIA_BUTTON intents
  let AudioService directly handle the corresponding key event instead
  of trapping the intent sent by PhoneWindowManager, KeyguardViewBase
  and PhoneFallbackEventHandler.
Because the key event may be sent through a PendingIntent,
  AudioService now also implements the OnFinished interface to be
  notified when the event was consumed so it can release the wake
  lock held if it was held when the key event needed to be sent
  (see where PassHeadsetKey was instanciated in PhoneWindowManager).

Change-Id: I2e8614df94af9d54edbf714ef443cc372d21827a
5 files changed