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

Commit c599ba36 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Move binder interfaces into the updatable

Test: Run all MediaComponents tests once
Change-Id: I29a7aa9d649ea212ad4728ebabff40ec0d47ecb1
parent 6d959eaa
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -429,8 +429,6 @@ java_library {
        "media/java/android/media/IMediaRouterService.aidl",
        "media/java/android/media/IMediaScannerListener.aidl",
        "media/java/android/media/IMediaScannerService.aidl",
        "media/java/android/media/IMediaSession2.aidl",
        "media/java/android/media/IMediaSession2Callback.aidl",
        "media/java/android/media/IPlaybackConfigDispatcher.aidl",
        "media/java/android/media/ISessionTokensListener.aidl",
        ":libaudioclient_aidl",
+0 −53
Original line number Diff line number Diff line
/*
 * Copyright 2018 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;

import android.media.IMediaSession2Callback;
import android.os.Bundle;
import android.os.ResultReceiver;

/**
 * Interface to MediaSession2. Framework MUST only call oneway APIs.
 *
 * @hide
 */
oneway interface IMediaSession2 {
    // TODO(jaewan): add onCommand() to send private command
    // TODO(jaewan): Due to the nature of oneway calls, APIs can be called in out of order
    //               Add id for individual calls to address this.

    // TODO(jaewan): We may consider to add another binder just for the connection
    //               not to expose other methods to the controller whose connection wasn't accepted.
    //               But this would be enough for now because it's the same as existing
    //               MediaBrowser and MediaBrowserService.
    void connect(String callingPackage, IMediaSession2Callback callback);
    void release(IMediaSession2Callback caller);

    //////////////////////////////////////////////////////////////////////////////////////////////
    // send command
    //////////////////////////////////////////////////////////////////////////////////////////////
    void sendCommand(IMediaSession2Callback caller, in Bundle command, in Bundle args);
    void sendTransportControlCommand(IMediaSession2Callback caller,
            int commandCode, in Bundle args);
    void sendCustomCommand(IMediaSession2Callback caller, in Bundle command, in Bundle args,
            in ResultReceiver receiver);

    //////////////////////////////////////////////////////////////////////////////////////////////
    // Get library service specific
    //////////////////////////////////////////////////////////////////////////////////////////////
    void getBrowserRoot(IMediaSession2Callback callback, in Bundle rootHints);
}
+0 −58
Original line number Diff line number Diff line
/*
 * Copyright 2018 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;

import android.os.Bundle;
import android.os.ResultReceiver;
import android.media.session.PlaybackState;
import android.media.IMediaSession2;

/**
 * Interface from MediaSession2 to MediaSession2Record.
 * <p>
 * Keep this interface oneway. Otherwise a malicious app may implement fake version of this,
 * and holds calls from session to make session owner(s) frozen.
 *
 * @hide
 */
oneway interface IMediaSession2Callback {
    void onPlaybackStateChanged(in Bundle state);
    void onPlaylistParamsChanged(in Bundle params);

    /**
     * Called only when the controller is created with service's token.
     *
     * @param sessionBinder {@code null} if the connect is rejected or is disconnected. a session
     *     binder if the connect is accepted.
     * @param commands initially allowed commands.
     */
    // TODO(jaewan): Also need to pass flags for allowed actions for permission check.
    //               For example, a media can allow setRating only for whitelisted apps
    //               it's better for controller to know such information in advance.
    //               Follow-up TODO: Add similar functions to the session.
    // TODO(jaewan): Is term 'accepted/rejected' correct? For permission, 'grant' is used.
    void onConnectionChanged(IMediaSession2 sessionBinder, in Bundle commandGroup);

    void onCustomLayoutChanged(in List<Bundle> commandButtonlist);

    void sendCustomCommand(in Bundle command, in Bundle args, in ResultReceiver receiver);

    //////////////////////////////////////////////////////////////////////////////////////////////
    // Browser sepcific
    //////////////////////////////////////////////////////////////////////////////////////////////
    void onGetRootResult(in Bundle rootHints, String rootMediaId, in Bundle rootExtra);
}
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.media.update.MediaSession2Provider.ControllerInfoProvider;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IInterface;
import android.os.Parcelable;
import android.os.ResultReceiver;
import android.text.TextUtils;
@@ -630,7 +631,7 @@ public class MediaSession2 implements AutoCloseable {
        // TODO(jaewan): SystemApi
        // TODO(jaewan): Also accept componentName to check notificaiton listener.
        public ControllerInfo(Context context, int uid, int pid, String packageName,
                IMediaSession2Callback callback) {
                IInterface callback) {
            mProvider = ApiLoader.getProvider(context)
                    .createMediaSession2ControllerInfoProvider(
                            context, this, uid, pid, packageName, callback);
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package android.media.session;

import android.content.ComponentName;
import android.media.IRemoteVolumeController;
import android.media.IMediaSession2;
import android.media.ISessionTokensListener;
import android.media.session.IActiveSessionsListener;
import android.media.session.ICallback;
Loading