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