MediaBrowserProtocol.java revision c39d9c75590eca86a5e7e32a8824ba04a0d42e9b
1/*
2 * Copyright (C) 2015 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 */
16package android.support.v4.media;
17
18/**
19 * Defines the communication protocol for media browsers and media browser services.
20 */
21class MediaBrowserProtocol {
22
23    public static final String DATA_CALLBACK_TOKEN = "data_callback_token";
24    public static final String DATA_CALLING_UID = "data_calling_uid";
25    public static final String DATA_MEDIA_ITEM_ID = "data_media_item_id";
26    public static final String DATA_MEDIA_ITEM_LIST = "data_media_item_list";
27    public static final String DATA_MEDIA_SESSION_TOKEN = "data_media_session_token";
28    public static final String DATA_OPTIONS = "data_options";
29    public static final String DATA_PACKAGE_NAME = "data_package_name";
30    public static final String DATA_RESULT_RECEIVER = "data_result_receiver";
31    public static final String DATA_ROOT_HINTS = "data_root_hints";
32
33    public static final String EXTRA_CLIENT_VERSION = "extra_client_version";
34    public static final String EXTRA_SERVICE_VERSION = "extra_service_version";
35    public static final String EXTRA_MESSENGER_BINDER = "extra_messenger";
36
37    /**
38     * MediaBrowserCompat will check the version of the connected MediaBrowserServiceCompat,
39     * and it will not send messages if they are introduced in the higher version of the
40     * MediaBrowserServiceCompat.
41     */
42    public static final int SERVICE_VERSION_1 = 1;
43    public static final int SERVICE_VERSION_CURRENT = SERVICE_VERSION_1;
44
45    /*
46     * Messages sent from the media browser service compat to the media browser compat.
47     * (Compat implementation for IMediaBrowserServiceCallbacks)
48     * DO NOT RENUMBER THESE!
49     */
50
51    /** (service v1)
52     * Sent after {@link MediaBrowserCompat#connect()} when the request has successfully
53     * completed.
54     * - arg1 : The service version
55     * - data
56     *     DATA_MEDIA_ITEM_ID : A string for the root media item id
57     *     DATA_MEDIA_SESSION_TOKEN : Media session token
58     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
59     */
60    public static final int SERVICE_MSG_ON_CONNECT = 1;
61
62    /** (service v1)
63     * Sent after {@link MediaBrowserCompat#connect()} when the connection to the media browser
64     * failed.
65     * - arg1 : service version
66     */
67    public static final int SERVICE_MSG_ON_CONNECT_FAILED = 2;
68
69    /** (service v1)
70     * Sent when the list of children is loaded or updated.
71     * - arg1 : The service version
72     * - data
73     *     DATA_MEDIA_ITEM_ID : A string for the parent media item id
74     *     DATA_MEDIA_ITEM_LIST : An array list for the media item children
75     *     DATA_OPTIONS : A bundle of service-specific arguments sent from the media browse to
76     *                    the media browser service
77     */
78    public static final int SERVICE_MSG_ON_LOAD_CHILDREN = 3;
79
80    /**
81     * MediaBrowserServiceCompat will check the version of the MediaBrowserCompat, and it will not
82     * send messages if they are introduced in the higher version of the MediaBrowserCompat.
83     */
84    public static final int CLIENT_VERSION_1 = 1;
85    public static final int CLIENT_VERSION_CURRENT = CLIENT_VERSION_1;
86
87    /*
88     * Messages sent from the media browser compat to the media browser service compat.
89     * (Compat implementation for IMediaBrowserService)
90     * DO NOT RENUMBER THESE!
91     */
92
93    /** (client v1)
94     * Sent to connect to the media browse service compat.
95     * - arg1 : The client version
96     * - data
97     *     DATA_PACKAGE_NAME : A string for the package name of MediaBrowserCompat
98     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
99     * - replyTo : Callback messenger
100     */
101    public static final int CLIENT_MSG_CONNECT = 1;
102
103    /** (client v1)
104     * Sent to disconnect from the media browse service compat.
105     * - arg1 : The client version
106     * - replyTo : Callback messenger
107     */
108    public static final int CLIENT_MSG_DISCONNECT = 2;
109
110    /** (client v1)
111     * Sent to subscribe for changes to the children of the specified media id.
112     * - arg1 : The client version
113     * - data
114     *     DATA_MEDIA_ITEM_ID : A string for a media item id
115     *     DATA_OPTIONS : A bundle of service-specific arguments sent from the media browser to
116     *                    the media browser service
117     *     DATA_CALLBACK_TOKEN : An IBinder of service-specific arguments sent from the media
118     *                           browser to the media browser service
119     * - replyTo : Callback messenger
120     */
121    public static final int CLIENT_MSG_ADD_SUBSCRIPTION = 3;
122
123    /** (client v1)
124     * Sent to unsubscribe for changes to the children of the specified media id.
125     * - arg1 : The client version
126     * - data
127     *     DATA_MEDIA_ITEM_ID : A string for a media item id
128     *     DATA_CALLBACK_TOKEN : An IBinder of service-specific arguments sent from the media
129     *                           browser to the media browser service
130     * - replyTo : Callback messenger
131     */
132    public static final int CLIENT_MSG_REMOVE_SUBSCRIPTION = 4;
133
134    /** (client v1)
135     * Sent to retrieve a specific media item from the connected service.
136     * - arg1 : The client version
137     * - data
138     *     DATA_MEDIA_ITEM_ID : A string for a media item id
139     *     DATA_RESULT_RECEIVER : Result receiver to get the result
140     * - replyTo : Callback messenger
141     */
142    public static final int CLIENT_MSG_GET_MEDIA_ITEM = 5;
143
144    /** (client v1)
145     * Sent to register the client messenger
146     * - arg1 : The client version
147     * - data
148     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
149     * - replyTo : Callback messenger
150     */
151    public static final int CLIENT_MSG_REGISTER_CALLBACK_MESSENGER = 6;
152
153    /** (client v1)
154     * Sent to unregister the client messenger
155     * - arg1 : The client version
156     * - replyTo : Callback messenger
157     */
158    public static final int CLIENT_MSG_UNREGISTER_CALLBACK_MESSENGER = 7;
159}
160