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:
@ -2127,7 +2127,7 @@ public class AudioManager {
|
|||||||
mediaButtonIntent.setComponent(eventReceiver);
|
mediaButtonIntent.setComponent(eventReceiver);
|
||||||
PendingIntent pi = PendingIntent.getBroadcast(mContext,
|
PendingIntent pi = PendingIntent.getBroadcast(mContext,
|
||||||
0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/);
|
0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/);
|
||||||
unregisterMediaButtonIntent(pi, eventReceiver);
|
unregisterMediaButtonIntent(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2139,16 +2139,16 @@ public class AudioManager {
|
|||||||
if (eventReceiver == null) {
|
if (eventReceiver == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unregisterMediaButtonIntent(eventReceiver, null);
|
unregisterMediaButtonIntent(eventReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void unregisterMediaButtonIntent(PendingIntent pi, ComponentName eventReceiver) {
|
public void unregisterMediaButtonIntent(PendingIntent pi) {
|
||||||
IAudioService service = getService();
|
IAudioService service = getService();
|
||||||
try {
|
try {
|
||||||
service.unregisterMediaButtonIntent(pi, eventReceiver);
|
service.unregisterMediaButtonIntent(pi);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e);
|
Log.e(TAG, "Dead object in unregisterMediaButtonIntent"+e);
|
||||||
}
|
}
|
||||||
|
@ -4889,7 +4889,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
mRemoteVolumeObs = null;
|
mRemoteVolumeObs = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** precondition: mediaIntent != null, eventReceiver != null */
|
/** precondition: mediaIntent != null */
|
||||||
public RemoteControlStackEntry(PendingIntent mediaIntent, ComponentName eventReceiver) {
|
public RemoteControlStackEntry(PendingIntent mediaIntent, ComponentName eventReceiver) {
|
||||||
mMediaIntent = mediaIntent;
|
mMediaIntent = mediaIntent;
|
||||||
mReceiverComponent = eventReceiver;
|
mReceiverComponent = eventReceiver;
|
||||||
@ -5062,6 +5062,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
Settings.System.MEDIA_BUTTON_RECEIVER, UserHandle.USER_CURRENT);
|
Settings.System.MEDIA_BUTTON_RECEIVER, UserHandle.USER_CURRENT);
|
||||||
if ((null != receiverName) && !receiverName.isEmpty()) {
|
if ((null != receiverName) && !receiverName.isEmpty()) {
|
||||||
ComponentName eventReceiver = ComponentName.unflattenFromString(receiverName);
|
ComponentName eventReceiver = ComponentName.unflattenFromString(receiverName);
|
||||||
|
if (eventReceiver == null) {
|
||||||
|
// an invalid name was persisted
|
||||||
|
return;
|
||||||
|
}
|
||||||
// construct a PendingIntent targeted to the restored component name
|
// construct a PendingIntent targeted to the restored component name
|
||||||
// for the media button and register it
|
// for the media button and register it
|
||||||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||||
@ -5077,7 +5081,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
* Helper function:
|
* Helper function:
|
||||||
* Set the new remote control receiver at the top of the RC focus stack.
|
* Set the new remote control receiver at the top of the RC focus stack.
|
||||||
* Called synchronized on mAudioFocusLock, then mRCStack
|
* Called synchronized on mAudioFocusLock, then mRCStack
|
||||||
* precondition: mediaIntent != null, target != null
|
* precondition: mediaIntent != null
|
||||||
*/
|
*/
|
||||||
private void pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target) {
|
private void pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target) {
|
||||||
// already at top of stack?
|
// already at top of stack?
|
||||||
@ -5106,8 +5110,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
|
|||||||
mRCStack.push(rcse); // rcse is never null
|
mRCStack.push(rcse); // rcse is never null
|
||||||
|
|
||||||
// post message to persist the default media button receiver
|
// post message to persist the default media button receiver
|
||||||
mAudioHandler.sendMessage( mAudioHandler.obtainMessage(
|
if (target != null) {
|
||||||
MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) );
|
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)
|
* see AudioManager.registerMediaButtonIntent(PendingIntent pi, ComponentName c)
|
||||||
* precondition: mediaIntent != null, target != null
|
* precondition: mediaIntent != null
|
||||||
*/
|
*/
|
||||||
public void registerMediaButtonIntent(PendingIntent mediaIntent, ComponentName eventReceiver) {
|
public void registerMediaButtonIntent(PendingIntent mediaIntent, ComponentName eventReceiver) {
|
||||||
Log.i(TAG, " Remote Control registerMediaButtonIntent() for " + mediaIntent);
|
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)
|
* see AudioManager.unregisterMediaButtonIntent(PendingIntent mediaIntent)
|
||||||
* precondition: mediaIntent != null, eventReceiver != null
|
* 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);
|
Log.i(TAG, " Remote Control unregisterMediaButtonIntent() for " + mediaIntent);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ interface IAudioService {
|
|||||||
void dispatchMediaKeyEventUnderWakelock(in KeyEvent keyEvent);
|
void dispatchMediaKeyEventUnderWakelock(in KeyEvent keyEvent);
|
||||||
|
|
||||||
void registerMediaButtonIntent(in PendingIntent pi, in ComponentName c);
|
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 registerMediaButtonEventReceiverForCalls(in ComponentName c);
|
||||||
oneway void unregisterMediaButtonEventReceiverForCalls();
|
oneway void unregisterMediaButtonEventReceiverForCalls();
|
||||||
|
Reference in New Issue
Block a user