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

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

Merge "Add a way to get the package/pid of the session" into lmp-preview-dev

parents b6b31f27 fb442b03
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.content.Intent;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.session.ISessionControllerCallback;
import android.media.session.MediaSessionInfo;
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.os.ResultReceiver;
@@ -35,6 +36,7 @@ interface ISessionController {
    void unregisterCallbackListener(in ISessionControllerCallback cb);
    boolean isTransportControlEnabled();
    void showRoutePicker();
    MediaSessionInfo getSessionInfo();

    // These commands are for the TransportController
    void play();
+15 −0
Original line number Diff line number Diff line
@@ -246,6 +246,21 @@ public final class MediaController {
        }
    }

    /**
     * Get the info for the session this controller is connected to.
     *
     * @return The session info for the connected session.
     * @hide
     */
    public MediaSessionInfo getSessionInfo() {
        try {
            return mSessionBinder.getSessionInfo();
        } catch (RemoteException e) {
            Log.e(TAG, "Error in getSessionInfo.", e);
        }
        return null;
    }

    /*
     * @hide
     */
+18 −0
Original line number Diff line number Diff line
/* Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

package android.media.session;

parcelable MediaSessionInfo;
+10 −2
Original line number Diff line number Diff line
@@ -26,18 +26,21 @@ import android.os.Parcelable;
public final class MediaSessionInfo implements Parcelable {
    private final String mId;
    private final String mPackageName;
    private final int mPid;

    /**
     * @hide
     */
    public MediaSessionInfo(String id, String packageName) {
    public MediaSessionInfo(String id, String packageName, int pid) {
        mId = id;
        mPackageName = packageName;
        mPid = pid;
    }

    private MediaSessionInfo(Parcel in) {
        mId = in.readString();
        mPackageName = in.readString();
        mPid = in.readInt();
    }

    /**
@@ -58,9 +61,13 @@ public final class MediaSessionInfo implements Parcelable {
        return mId;
    }

    public int getPid() {
        return mPid;
    }

    @Override
    public String toString() {
        return "SessionInfo {id=" + mId + ", pkg=" + mPackageName + "}";
        return "SessionInfo {id=" + mId + ", pkg=" + mPackageName + ", pid=" + mPid + "}";
    }

    @Override
@@ -72,6 +79,7 @@ public final class MediaSessionInfo implements Parcelable {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mId);
        dest.writeString(mPackageName);
        dest.writeInt(mPid);
    }

    public static final Parcelable.Creator<MediaSessionInfo> CREATOR
+7 −1
Original line number Diff line number Diff line
@@ -130,7 +130,8 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
        mOwnerPid = ownerPid;
        mOwnerUid = ownerUid;
        mUserId = userId;
        mSessionInfo = new MediaSessionInfo(UUID.randomUUID().toString(), ownerPackageName);
        mSessionInfo = new MediaSessionInfo(UUID.randomUUID().toString(), ownerPackageName,
                ownerPid);
        mTag = tag;
        mController = new ControllerStub();
        mSession = new SessionStub();
@@ -942,6 +943,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
            }
        }

        @Override
        public MediaSessionInfo getSessionInfo() {
            return mSessionInfo;
        }

        @Override
        public void play() throws RemoteException {
            mSessionCb.play();