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