Fix bug 2724503 Persist media button receiver across reboots

Whenever a new media button receiver is registered, save it
 in the settings.

When the system audio settings are reloaded or when the
 AudioService is created, the registered media button receiver
 is restored.

Whenever a package is removed from the system, remove
 any media button receiver from the same package that are in
 the media button receiver stack. If this causes the currently
 registered receiver to change (i.e. the top of the stack),
 this will cause an update of the receiver stored in the
 system settings.

Note that unregistering a media button receiver will not
 cause the receiver saved in the settings to be updated,
 this is ON PURPOSE. This is to prevent well behaved
 application who unregister their receiver at the destruction
 of their service, to not receive the intent after a reboot,
 and to not encourage applications to never unregister
 their receiver.

Change-Id: I941b777debaa56e88de93c3b03aec40331ea9ab1
2 files changed