MediaBrowserProtocol.java revision f4cbb97f8aefa6707cd5f13d3cff14d79ec48e60
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    public static final String DATA_SEARCH_EXTRAS = "data_search_extras";
33    public static final String DATA_SEARCH_QUERY = "data_search_query";
34    public static final String DATA_CUSTOM_ACTION = "data_custom_action";
35    public static final String DATA_CUSTOM_ACTION_EXTRAS = "data_custom_action_extras";
36
37    public static final String EXTRA_CLIENT_VERSION = "extra_client_version";
38    public static final String EXTRA_SERVICE_VERSION = "extra_service_version";
39    public static final String EXTRA_MESSENGER_BINDER = "extra_messenger";
40    public static final String EXTRA_SESSION_BINDER = "extra_session_binder";
41
42    /**
43     * MediaBrowserCompat will check the version of the connected MediaBrowserServiceCompat,
44     * and it will not send messages if they are introduced in the higher version of the
45     * MediaBrowserServiceCompat.
46     */
47    public static final int SERVICE_VERSION_1 = 1;
48    public static final int SERVICE_VERSION_CURRENT = SERVICE_VERSION_1;
49
50    /*
51     * Messages sent from the media browser service compat to the media browser compat.
52     * (Compat implementation for IMediaBrowserServiceCallbacks)
53     * DO NOT RENUMBER THESE!
54     */
55
56    /** (service v1)
57     * Sent after {@link MediaBrowserCompat#connect()} when the request has successfully
58     * completed.
59     * - arg1 : The service version
60     * - data
61     *     DATA_MEDIA_ITEM_ID : A string for the root media item id
62     *     DATA_MEDIA_SESSION_TOKEN : Media session token
63     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
64     */
65    public static final int SERVICE_MSG_ON_CONNECT = 1;
66
67    /** (service v1)
68     * Sent after {@link MediaBrowserCompat#connect()} when the connection to the media browser
69     * failed.
70     * - arg1 : service version
71     */
72    public static final int SERVICE_MSG_ON_CONNECT_FAILED = 2;
73
74    /** (service v1)
75     * Sent when the list of children is loaded or updated.
76     * - arg1 : The service version
77     * - data
78     *     DATA_MEDIA_ITEM_ID : A string for the parent media item id
79     *     DATA_MEDIA_ITEM_LIST : An array list for the media item children
80     *     DATA_OPTIONS : A bundle of service-specific arguments sent from the media browse to
81     *                    the media browser service
82     */
83    public static final int SERVICE_MSG_ON_LOAD_CHILDREN = 3;
84
85    /**
86     * MediaBrowserServiceCompat will check the version of the MediaBrowserCompat, and it will not
87     * send messages if they are introduced in the higher version of the MediaBrowserCompat.
88     */
89    public static final int CLIENT_VERSION_1 = 1;
90    public static final int CLIENT_VERSION_CURRENT = CLIENT_VERSION_1;
91
92    /*
93     * Messages sent from the media browser compat to the media browser service compat.
94     * (Compat implementation for IMediaBrowserService)
95     * DO NOT RENUMBER THESE!
96     */
97
98    /** (client v1)
99     * Sent to connect to the media browse service compat.
100     * - arg1 : The client version
101     * - data
102     *     DATA_PACKAGE_NAME : A string for the package name of MediaBrowserCompat
103     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
104     * - replyTo : Callback messenger
105     */
106    public static final int CLIENT_MSG_CONNECT = 1;
107
108    /** (client v1)
109     * Sent to disconnect from the media browse service compat.
110     * - arg1 : The client version
111     * - replyTo : Callback messenger
112     */
113    public static final int CLIENT_MSG_DISCONNECT = 2;
114
115    /** (client v1)
116     * Sent to subscribe for changes to the children of the specified media id.
117     * - arg1 : The client version
118     * - data
119     *     DATA_MEDIA_ITEM_ID : A string for a media item id
120     *     DATA_OPTIONS : A bundle of service-specific arguments sent from the media browser to
121     *                    the media browser service
122     *     DATA_CALLBACK_TOKEN : An IBinder of service-specific arguments sent from the media
123     *                           browser to the media browser service
124     * - replyTo : Callback messenger
125     */
126    public static final int CLIENT_MSG_ADD_SUBSCRIPTION = 3;
127
128    /** (client v1)
129     * Sent to unsubscribe for changes to the children of the specified media id.
130     * - arg1 : The client version
131     * - data
132     *     DATA_MEDIA_ITEM_ID : A string for a media item id
133     *     DATA_CALLBACK_TOKEN : An IBinder of service-specific arguments sent from the media
134     *                           browser to the media browser service
135     * - replyTo : Callback messenger
136     */
137    public static final int CLIENT_MSG_REMOVE_SUBSCRIPTION = 4;
138
139    /** (client v1)
140     * Sent to retrieve a specific media item from the connected service.
141     * - arg1 : The client version
142     * - data
143     *     DATA_MEDIA_ITEM_ID : A string for a media item id
144     *     DATA_RESULT_RECEIVER : Result receiver to get the result
145     * - replyTo : Callback messenger
146     */
147    public static final int CLIENT_MSG_GET_MEDIA_ITEM = 5;
148
149    /** (client v1)
150     * Sent to register the client messenger
151     * - arg1 : The client version
152     * - data
153     *     DATA_ROOT_HINTS : An optional root hints bundle of service-specific arguments
154     * - replyTo : Callback messenger
155     */
156    public static final int CLIENT_MSG_REGISTER_CALLBACK_MESSENGER = 6;
157
158    /** (client v1)
159     * Sent to unregister the client messenger
160     * - arg1 : The client version
161     * - replyTo : Callback messenger
162     */
163    public static final int CLIENT_MSG_UNREGISTER_CALLBACK_MESSENGER = 7;
164
165    /** (client v1)
166     * Sent to retrieve a specific media item from the connected service.
167     * - arg1 : The client version
168     * - data
169     *     DATA_SEARCH_QUERY : A string for search query that contains keywords separated by space.
170     *     DATA_SEARCH_EXTRAS : A bundle of service-specific arguments to send to the media browser
171     *                          service.
172     *     DATA_RESULT_RECEIVER : Result receiver to get the result.
173     * - replyTo : Callback messenger
174     */
175    public static final int CLIENT_MSG_SEARCH = 8;
176
177    /** (client v1)
178     * Sent to request a custom action from the media browser.
179     * - arg1 : The client version
180     * - data
181     *     DATA_CUSTOM_ACTION : A string for the custom action.
182     *     DATA_CUSTOM_ACTION_EXTRAS : A bundle of service-specific arguments to send to the media
183     *                                 browser service.
184     *     DATA_RESULT_RECEIVER : Result receiver to get the result.
185     * - replyTo : Callback messenger
186     */
187    public static final int CLIENT_MSG_SEND_CUSTOM_ACTION = 9;
188}
189