am c3c7b92a: Merge "Clean up role of component name in media button event receiver" into jb-mr2-dev

* commit 'c3c7b92a8128831445d2a185b0986c60d929b150':
  Clean up role of component name in media button event receiver
This commit is contained in:
Jean-Michel Trivi
2013-04-02 08:56:57 -07:00
committed by Android Git Automerger
3 changed files with 17 additions and 11 deletions

View File

@ -2127,7 +2127,7 @@ public class AudioManager {
mediaButtonIntent.setComponent(eventReceiver);
PendingIntent pi = PendingIntent.getBroadcast(mContext,
0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/);
unregisterMediaButtonIntent(pi, eventReceiver);
unregisterMediaButtonIntent(pi);
}
/**
@ -2139,16 +2139,16 @@ public class AudioManager {
if (eventReceiver == null) {
return;
}
unregisterMediaButtonIntent(eventReceiver, null);
unregisterMediaButtonIntent(eventReceiver);
}
/**
* @hide
*/
public void unregisterMediaButtonIntent(PendingIntent pi, ComponentName eventReceiver) {
public void unregisterMediaButtonIntent(PendingIntent pi) {
IAudioService service = getService();
try {
service.unregisterMediaButtonIntent(pi, eventReceiver);
service.unregisterMediaButtonIntent(pi);
} catch (RemoteException e) {
Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e);
}

View File

@ -4889,7 +4889,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
mRemoteVolumeObs = null;
}
/** precondition: mediaIntent != null, eventReceiver != null */
/** precondition: mediaIntent != null */
public RemoteControlStackEntry(PendingIntent mediaIntent, ComponentName eventReceiver) {
mMediaIntent = mediaIntent;
mReceiverComponent = eventReceiver;
@ -5062,6 +5062,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
Settings.System.MEDIA_BUTTON_RECEIVER, UserHandle.USER_CURRENT);
if ((null != receiverName) && !receiverName.isEmpty()) {
ComponentName eventReceiver = ComponentName.unflattenFromString(receiverName);
if (eventReceiver == null) {
// an invalid name was persisted
return;
}
// construct a PendingIntent targeted to the restored component name
// for the media button and register it
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
@ -5077,7 +5081,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
* Helper function:
* Set the new remote control receiver at the top of the RC focus stack.
* Called synchronized on mAudioFocusLock, then mRCStack
* precondition: mediaIntent != null, target != null
* precondition: mediaIntent != null
*/
private void pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target) {
// already at top of stack?
@ -5106,8 +5110,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
mRCStack.push(rcse); // rcse is never null
// post message to persist the default media button receiver
mAudioHandler.sendMessage( mAudioHandler.obtainMessage(
MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) );
if (target != null) {
mAudioHandler.sendMessage( mAudioHandler.obtainMessage(
MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) );
}
}
/**
@ -5407,7 +5413,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
/**
* see AudioManager.registerMediaButtonIntent(PendingIntent pi, ComponentName c)
* precondition: mediaIntent != null, target != null
* precondition: mediaIntent != null
*/
public void registerMediaButtonIntent(PendingIntent mediaIntent, ComponentName eventReceiver) {
Log.i(TAG, " Remote Control registerMediaButtonIntent() for " + mediaIntent);
@ -5425,7 +5431,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
* see AudioManager.unregisterMediaButtonIntent(PendingIntent mediaIntent)
* precondition: mediaIntent != null, eventReceiver != null
*/
public void unregisterMediaButtonIntent(PendingIntent mediaIntent, ComponentName eventReceiver)
public void unregisterMediaButtonIntent(PendingIntent mediaIntent)
{
Log.i(TAG, " Remote Control unregisterMediaButtonIntent() for " + mediaIntent);

View File

@ -121,7 +121,7 @@ interface IAudioService {
void dispatchMediaKeyEventUnderWakelock(in KeyEvent keyEvent);
void registerMediaButtonIntent(in PendingIntent pi, in ComponentName c);
oneway void unregisterMediaButtonIntent(in PendingIntent pi, in ComponentName c);
oneway void unregisterMediaButtonIntent(in PendingIntent pi);
oneway void registerMediaButtonEventReceiverForCalls(in ComponentName c);
oneway void unregisterMediaButtonEventReceiverForCalls();