blob: bd97dbce57d1e51dc2001c69c3c4e9b1983f9b4d [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;
22import android.media.SessionToken;
23import 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;
36 private final SessionToken mToken;
37
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;
44 mToken = new SessionToken(mType, packageName, id, mServiceName, null);
45 }
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) {
54 SessionToken token = new SessionToken(mType, packageName, id, mServiceName, sessionBinder);
55 return createMediaController(token);
56 }
57
58 /**
59 * @return token with no session binder information.
60 */
61 @Override
62 public SessionToken getToken() {
63 return mToken;
64 }
65}