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