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 17 package com.android.bluetooth.avrcp; 18 19 import android.util.Log; 20 21 import com.android.bluetooth.Utils; 22 23 import java.nio.ByteBuffer; 24 import java.nio.charset.Charset; 25 import java.util.ArrayList; 26 import java.util.Arrays; 27 import java.util.HashMap; 28 import java.util.List; 29 30 /** 31 * Provides helper classes used by other AvrcpControllerClasses. 32 * Don't change this file without changing HAL Constants in bt_rc.h 33 */ 34 35 final class AvrcpControllerConstants { 36 37 /* 38 * Debug flags 39 */ 40 public static final boolean DBG = true; 41 public static final boolean VDBG = true; 42 /* 43 * Whether to push broadcast updates about metadata. 44 */ 45 public static final int START_METADATA_BROADCASTS = 0; 46 public static final int STOP_METADATA_BROADCASTS = 1; 47 48 /* 49 * Scopes of operation 50 */ 51 public static final int AVRCP_SCOPE_NOW_PLAYING = 0; 52 public static final int AVRCP_SCOPE_VFS = 1; 53 /* 54 * Remote features 55 */ 56 public static final byte BTRC_FEAT_NONE = 0; 57 public static final byte BTRC_FEAT_METADATA = 1; 58 public static final byte BTRC_FEAT_ABSOLUTE_VOLUME = 2; 59 public static final byte BTRC_FEAT_BROWSE = 4; 60 61 /* 62 *Element Id Values for GetMetaData 63 */ 64 public static final int MEDIA_ATTRIBUTE_TITLE = 0x01; 65 public static final int MEDIA_ATTRIBUTE_ARTIST_NAME = 0x02; 66 public static final int MEDIA_ATTRIBUTE_ALBUM_NAME = 0x03; 67 public static final int MEDIA_ATTRIBUTE_TRACK_NUMBER = 0x04; 68 public static final int MEDIA_ATTRIBUTE_TOTAL_TRACK_NUMBER = 0x05; 69 public static final int MEDIA_ATTRIBUTE_GENRE = 0x06; 70 public static final int MEDIA_ATTRIBUTE_PLAYING_TIME = 0x07; 71 72 /* 73 * Default values for each of the items 74 */ 75 public static final int TRACK_NUM_INVALID = 0xFF; 76 public static final int STATUS_INVALID = 0xFF; 77 public static final String TITLE_INVALID = "NOT_SUPPORTED"; 78 public static final String ARTIST_NAME_INVALID = "NOT_SUPPORTED"; 79 public static final String ALBUM_NAME_INVALID = "NOT_SUPPORTED"; 80 public static final int TOTAL_TRACKS_INVALID = 0xFFFFFFFF; 81 public static final String GENRE_INVALID = "NOT_SUPPORTED"; 82 public static final int PLAYING_TIME_INVALID = 0xFF; 83 public static final int TOTAL_TRACK_TIME_INVALID = 0xFF; 84 public static final String REPEAT_STATUS_INVALID = "NOT_SUPPORTED"; 85 public static final String SHUFFLE_STATUS_INVALID = "NOT_SUPPORTED"; 86 public static final String SCAN_STATUS_INVALID = "NOT_SUPPORTED"; 87 public static final String EQUALIZER_STATUS_INVALID = "NOT_SUPPORTED"; 88 public static final String BATTERY_STATUS_INVALID = "NOT_SUPPORTED"; 89 public static final String SYSTEM_STATUS_INVALID = "NOT_SUPPORTED"; 90 91 /* 92 * Values for SetPlayerApplicationSettings 93 */ 94 public static final byte ATTRIB_EQUALIZER_STATUS = 0x01; 95 public static final byte ATTRIB_REPEAT_STATUS = 0x02; 96 public static final byte ATTRIB_SHUFFLE_STATUS = 0x03; 97 public static final byte ATTRIB_SCAN_STATUS = 0x04; 98 99 public static final byte EQUALIZER_STATUS_OFF = 0x01; 100 public static final byte EQUALIZER_STATUS_ON = 0x02; 101 102 public static final byte REPEAT_STATUS_OFF = 0x01; 103 public static final byte REPEAT_STATUS_SINGLE_TRACK_REPEAT = 0x02; 104 public static final byte REPEAT_STATUS_ALL_TRACK_REPEAT = 0x03; 105 public static final byte REPEAT_STATUS_GROUP_REPEAT = 0x04; 106 107 public static final byte SHUFFLE_STATUS_OFF = 0x01; 108 public static final byte SHUFFLE_STATUS_ALL_TRACK_SHUFFLE = 0x02; 109 public static final byte SHUFFLE_STATUS_GROUP_SHUFFLE = 0x03; 110 111 public static final byte SCAN_STATUS_OFF = 0x01; 112 public static final byte SCAN_STATUS_ALL_TRACK_SCAN = 0x02; 113 public static final byte SCAN_STATUS_GROUP_SCAN = 0x03; 114 115 /* 116 * Play State Values 117 */ 118 public static final int PLAY_STATUS_STOPPED = 0x00; 119 public static final int PLAY_STATUS_PLAYING = 0x01; 120 public static final int PLAY_STATUS_PAUSED = 0x02; 121 public static final int PLAY_STATUS_FWD_SEEK = 0x03; 122 public static final int PLAY_STATUS_REV_SEEK = 0x04; 123 public static final int PLAY_STATUS_ERROR = 0xFF; 124 /* 125 * System Status 126 */ 127 public static final int SYSTEM_POWER_ON = 0x00; 128 public static final int SYSTEM_POWER_OFF = 0x01; 129 public static final int SYSTEM_UNPLUGGED = 0x02; 130 public static final int SYSTEM_STATUS_UNDEFINED = 0xFF; 131 /* 132 * Battery Status 133 */ 134 public static final int BATT_POWER_NORMAL = 0x00; 135 public static final int BATT_POWER_WARNING = 0x01; 136 public static final int BATT_POWER_CRITICAL = 0x02; 137 public static final int BATT_POWER_EXTERNAL = 0x03; 138 public static final int BATT_POWER_FULL_CHARGE = 0x04; 139 public static final int BATT_POWER_UNDEFINED = 0xFF; 140 141 public static final int NOTIFICATION_RSP_TYPE_INTERIM = 0x00; 142 public static final int NOTIFICATION_RSP_TYPE_CHANGED = 0x01; 143 /* 144 * Base value for absolute volume 145 */ 146 static final int ABS_VOL_BASE = 127; 147 148 public static final int MESSAGE_SEND_PASS_THROUGH_CMD = 1; 149 public static final int MESSAGE_SEND_SET_CURRENT_PLAYER_APPLICATION_SETTINGS = 2; 150 public static final int MESSAGE_SEND_GROUP_NAVIGATION_CMD = 3; 151 152 public static final int MESSAGE_PROCESS_SUPPORTED_PLAYER_APP_SETTING = 101; 153 public static final int MESSAGE_PROCESS_PLAYER_APP_SETTING_CHANGED = 102; 154 public static final int MESSAGE_PROCESS_SET_ABS_VOL_CMD = 103; 155 public static final int MESSAGE_PROCESS_REGISTER_ABS_VOL_NOTIFICATION = 104; 156 public static final int MESSAGE_PROCESS_TRACK_CHANGED = 105; 157 public static final int MESSAGE_PROCESS_PLAY_POS_CHANGED = 106; 158 public static final int MESSAGE_PROCESS_PLAY_STATUS_CHANGED = 107; 159 160 public static final int MESSAGE_PROCESS_RC_FEATURES = 1100; 161 public static final int MESSAGE_PROCESS_CONNECTION_CHANGE = 1200; 162 163 public static final int MESSAGE_STOP_METADATA_BROADCASTS = 201; 164 public static final int MESSAGE_START_METADATA_BROADCASTS = 202; 165 166 167 public static String dumpMessageString(int message) 168 { 169 String str = "UNKNOWN"; 170 switch(message) 171 { 172 case MESSAGE_SEND_PASS_THROUGH_CMD: 173 str = "REQ_PASS_THROUGH_CMD"; 174 break; 175 case MESSAGE_SEND_SET_CURRENT_PLAYER_APPLICATION_SETTINGS: 176 str = "REQ_SET_PLAYER_APP_SETTING"; 177 break; 178 case MESSAGE_SEND_GROUP_NAVIGATION_CMD: 179 str = "REQ_GRP_NAV_CMD"; 180 break; 181 case MESSAGE_PROCESS_SUPPORTED_PLAYER_APP_SETTING: 182 str = "CB_SUPPORTED_PLAYER_APP_SETTING"; 183 break; 184 case MESSAGE_PROCESS_PLAYER_APP_SETTING_CHANGED: 185 str = "CB_PLAYER_APP_SETTING_CHANGED"; 186 break; 187 case MESSAGE_PROCESS_SET_ABS_VOL_CMD: 188 str = "CB_SET_ABS_VOL_CMD"; 189 break; 190 case MESSAGE_PROCESS_REGISTER_ABS_VOL_NOTIFICATION: 191 str = "CB_REGISTER_ABS_VOL"; 192 break; 193 case MESSAGE_PROCESS_TRACK_CHANGED: 194 str = "CB_TRACK_CHANGED"; 195 break; 196 case MESSAGE_PROCESS_PLAY_POS_CHANGED: 197 str = "CB_PLAY_POS_CHANGED"; 198 break; 199 case MESSAGE_PROCESS_PLAY_STATUS_CHANGED: 200 str = "CB_PLAY_STATUS_CHANGED"; 201 break; 202 case MESSAGE_PROCESS_RC_FEATURES: 203 str = "CB_RC_FEATURES"; 204 break; 205 case MESSAGE_PROCESS_CONNECTION_CHANGE: 206 str = "CB_CONN_CHANGED"; 207 break; 208 default: 209 str = Integer.toString(message); 210 break; 211 } 212 return str; 213 } 214 215 /* Absolute Volume Notification State */ 216 /* if we are in this state, we would send vol update to remote */ 217 public static final int SEND_VOLUME_CHANGE_RSP = 0; 218 /* if we are in this state, we would not send vol update to remote */ 219 public static final int DEFER_VOLUME_CHANGE_RSP = 1; 220 public static final int VOLUME_LABEL_UNDEFINED = 0xFF; 221 } 222