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

Commit 5b53148a authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge changes I1cbdff1d,I23906b4c

* changes:
  Handle headsethook voice launching
  Add 5s timeout to wakelock
parents afe18ed6 9a9d0b5f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.os.ResultReceiver;
 */
oneway interface ISessionCallback {
    void onCommand(String command, in Bundle extras, in ResultReceiver cb);
    void onMediaButton(in Intent mediaButtonIntent, in ResultReceiver cb);
    void onMediaButton(in Intent mediaButtonIntent, int sequenceNumber, in ResultReceiver cb);
    void onRequestRouteChange(in RouteInfo route);
    void onRouteConnected(in RouteInfo route, in RouteOptions options);
    void onRouteDisconnected(in RouteInfo route, int reason);
+9 −13
Original line number Diff line number Diff line
@@ -119,13 +119,6 @@ public final class MediaSession {
     */
    public static final int DISCONNECT_REASON_SESSION_DESTROYED = 5;

    /**
     * Status code indicating the call was handled.
     *
     * @hide
     */
    public static final int RESULT_SUCCESS = 0;

    private static final int MSG_MEDIA_BUTTON = 1;
    private static final int MSG_COMMAND = 2;
    private static final int MSG_ROUTE_CHANGE = 3;
@@ -563,14 +556,17 @@ public final class MediaSession {
        }

        @Override
        public void onMediaButton(Intent mediaButtonIntent, ResultReceiver cb)
        public void onMediaButton(Intent mediaButtonIntent, int sequenceNumber, ResultReceiver cb)
                throws RemoteException {
            MediaSession session = mMediaSession.get();
            try {
                if (session != null) {
                    session.postMediaButton(mediaButtonIntent);
                }
            } finally {
                if (cb != null) {
                cb.send(RESULT_SUCCESS, null);
                    cb.send(sequenceNumber, null);
                }
            }
        }

+2 −0
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ public class MediaSessionLegacyHelper {
            return;
        }
        holder.mMediaButtonListener = new MediaButtonListener(pi, context);
        // TODO determine if handling transport performer commands should also
        // set this flag
        holder.mFlags |= MediaSession.FLAG_HANDLES_MEDIA_BUTTONS;
        holder.mSession.setFlags(holder.mFlags);
        holder.mSession.getTransportPerformer().addListener(holder.mMediaButtonListener, mHandler);
+23 −15
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.IAudioService;
import android.media.session.MediaSessionLegacyHelper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -39,6 +40,9 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
    private static String TAG = "PhoneFallbackEventHandler";
    private static final boolean DEBUG = false;

    // Use the new sessions APIs
    private static final boolean USE_SESSIONS = true;

    Context mContext;
    View mView;

@@ -290,6 +294,9 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
    }

    private void handleMediaKeyEvent(KeyEvent keyEvent) {
        if (USE_SESSIONS) {
            MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(keyEvent, false);
        } else {
            IAudioService audioService = IAudioService.Stub.asInterface(
                    ServiceManager.checkService(Context.AUDIO_SERVICE));
            if (audioService != null) {
@@ -303,4 +310,5 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler {
            }
        }
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -365,8 +365,8 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
        return mSessionCb.mCb;
    }

    public void sendMediaButton(KeyEvent ke, ResultReceiver cb) {
        mSessionCb.sendMediaButton(ke, cb);
    public void sendMediaButton(KeyEvent ke, int sequenceId, ResultReceiver cb) {
        mSessionCb.sendMediaButton(ke, sequenceId, cb);
    }

    public void dump(PrintWriter pw, String prefix) {
@@ -649,11 +649,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
            mCb = cb;
        }

        public void sendMediaButton(KeyEvent keyEvent, ResultReceiver cb) {
        public void sendMediaButton(KeyEvent keyEvent, int sequenceId, ResultReceiver cb) {
            Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
            try {
                mCb.onMediaButton(mediaButtonIntent, cb);
                mCb.onMediaButton(mediaButtonIntent, sequenceId, cb);
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote failure in sendMediaRequest.", e);
            }
@@ -789,7 +789,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {

        @Override
        public void sendMediaButton(KeyEvent mediaButtonIntent) {
            mSessionCb.sendMediaButton(mediaButtonIntent, null);
            mSessionCb.sendMediaButton(mediaButtonIntent, 0, null);
        }

        @Override
Loading