blob: d033f552124f53440466bed2fcb010d46bc04ee8 [file] [log] [blame]
Jaewan Kimceb6b6e2018-01-21 20:56:10 +09001/*
2 * Copyright 2018 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
17package com.android.server.media;
18
19import android.content.Context;
20import android.media.IMediaSession2;
21import android.media.MediaController2;
Jaewan Kim04de5de2018-01-25 02:24:03 +090022import android.media.SessionToken2;
Jaewan Kimceb6b6e2018-01-21 20:56:10 +090023import android.media.MediaSessionService2;
24
25/**
26 * Records a {@link MediaSessionService2}.
27 * <p>
28 * Owner of this object should handle synchronization.
29 */
30class MediaSessionService2Record extends MediaSession2Record {
31 private static final boolean DEBUG = true; // TODO(jaewan): Modify
32 private static final String TAG = "SessionService2Record";
33
34 private final int mType;
35 private final String mServiceName;
Jaewan Kim04de5de2018-01-25 02:24:03 +090036 private final SessionToken2 mToken;
Jaewan Kimceb6b6e2018-01-21 20:56:10 +090037
38 public MediaSessionService2Record(Context context,
39 SessionDestroyedListener sessionDestroyedListener, int type,
40 String packageName, String serviceName, String id) {
41 super(context, sessionDestroyedListener);
42 mType = type;
43 mServiceName = serviceName;
Jaewan Kim04de5de2018-01-25 02:24:03 +090044 mToken = new SessionToken2(mType, packageName, id, mServiceName, null);
Jaewan Kimceb6b6e2018-01-21 20:56:10 +090045 }
46
47 /**
48 * Overriden to change behavior of
49 * {@link #createSessionToken(int, String, String, IMediaSession2)}}.
50 */
51 @Override
52 MediaController2 onCreateMediaController(
53 String packageName, String id, IMediaSession2 sessionBinder) {
Jaewan Kim04de5de2018-01-25 02:24:03 +090054 SessionToken2 token = new SessionToken2(mType, packageName, id, mServiceName, sessionBinder);
Jaewan Kimceb6b6e2018-01-21 20:56:10 +090055 return createMediaController(token);
56 }
57
58 /**
59 * @return token with no session binder information.
60 */
61 @Override
Jaewan Kim04de5de2018-01-25 02:24:03 +090062 public SessionToken2 getToken() {
Jaewan Kimceb6b6e2018-01-21 20:56:10 +090063 return mToken;
64 }
65}