Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5514aff4 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android Git Automerger
Browse files

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

* commit 'c3c7b92a':
  Clean up role of component name in media button event receiver
parents 30373c5b c3c7b92a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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);
        }
+12 −6
Original line number Diff line number Diff line
@@ -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,9 +5110,11 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
        mRCStack.push(rcse); // rcse is never null

        // post message to persist the default media button receiver
        if (target != null) {
            mAudioHandler.sendMessage( mAudioHandler.obtainMessage(
                    MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) );
        }
    }

    /**
     * Helper function:
@@ -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);

+1 −1
Original line number Diff line number Diff line
@@ -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();