blob: e5991894728be9c6453ae195b908c5c354aa166c [file] [log] [blame]
RoboErik01fe6612014-02-13 14:19:04 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
RoboErik2f5b0572014-02-21 10:30:38 -080017package android.media.session;
RoboErik01fe6612014-02-13 14:19:04 -080018
RoboErik07c70772014-03-20 13:33:52 -070019import android.media.session.ISessionController;
RoboErik01fe6612014-02-13 14:19:04 -080020import android.os.Parcel;
21import android.os.Parcelable;
22
RoboErik79fa4632014-05-27 16:49:09 -070023/**
24 * Represents an ongoing session. This may be passed to apps by the session
25 * owner to allow them to create a {@link MediaController} to communicate with
26 * the session.
27 */
28public final class MediaSessionToken implements Parcelable {
RoboErik07c70772014-03-20 13:33:52 -070029 private ISessionController mBinder;
RoboErik01fe6612014-02-13 14:19:04 -080030
31 /**
32 * @hide
33 */
RoboErik2e7a9162014-06-04 16:53:45 -070034 public MediaSessionToken(ISessionController binder) {
RoboErik01fe6612014-02-13 14:19:04 -080035 mBinder = binder;
36 }
37
RoboErik42ea7ee2014-05-16 16:27:35 -070038 private MediaSessionToken(Parcel in) {
RoboErik07c70772014-03-20 13:33:52 -070039 mBinder = ISessionController.Stub.asInterface(in.readStrongBinder());
RoboErik01fe6612014-02-13 14:19:04 -080040 }
41
42 /**
43 * @hide
44 */
RoboErik07c70772014-03-20 13:33:52 -070045 ISessionController getBinder() {
RoboErik01fe6612014-02-13 14:19:04 -080046 return mBinder;
47 }
48
49 @Override
50 public int describeContents() {
51 return 0;
52 }
53
54 @Override
55 public void writeToParcel(Parcel dest, int flags) {
56 dest.writeStrongBinder(mBinder.asBinder());
57 }
58
RoboErik42ea7ee2014-05-16 16:27:35 -070059 public static final Parcelable.Creator<MediaSessionToken> CREATOR
60 = new Parcelable.Creator<MediaSessionToken>() {
RoboErik01fe6612014-02-13 14:19:04 -080061 @Override
RoboErik42ea7ee2014-05-16 16:27:35 -070062 public MediaSessionToken createFromParcel(Parcel in) {
63 return new MediaSessionToken(in);
RoboErik01fe6612014-02-13 14:19:04 -080064 }
65
66 @Override
RoboErik42ea7ee2014-05-16 16:27:35 -070067 public MediaSessionToken[] newArray(int size) {
68 return new MediaSessionToken[size];
RoboErik01fe6612014-02-13 14:19:04 -080069 }
70 };
71}