1 /* 2 * Copyright 2018 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 android.bluetooth; 18 19 import android.test.suitebuilder.annotation.SmallTest; 20 21 import junit.framework.TestCase; 22 23 import java.util.ArrayList; 24 import java.util.List; 25 import java.util.Objects; 26 27 /** 28 * Unit test cases for {@link BluetoothCodecStatus}. 29 */ 30 public class BluetoothCodecStatusTest extends TestCase { 31 32 // Codec configs: A and B are same; C is different 33 private static final BluetoothCodecConfig CONFIG_A = 34 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 35 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 36 BluetoothCodecConfig.SAMPLE_RATE_44100, 37 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 38 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 39 1000, 2000, 3000, 4000); 40 41 private static final BluetoothCodecConfig CONFIG_B = 42 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 43 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 44 BluetoothCodecConfig.SAMPLE_RATE_44100, 45 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 46 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 47 1000, 2000, 3000, 4000); 48 49 private static final BluetoothCodecConfig CONFIG_C = 50 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 51 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 52 BluetoothCodecConfig.SAMPLE_RATE_44100, 53 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 54 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 55 1000, 2000, 3000, 4000); 56 57 // Local capabilities: A and B are same; C is different 58 private static final BluetoothCodecConfig LOCAL_CAPABILITY_1_A = 59 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 60 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 61 BluetoothCodecConfig.SAMPLE_RATE_44100 62 | BluetoothCodecConfig.SAMPLE_RATE_48000, 63 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 64 BluetoothCodecConfig.CHANNEL_MODE_STEREO 65 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 66 1000, 2000, 3000, 4000); 67 68 private static final BluetoothCodecConfig LOCAL_CAPABILITY_1_B = 69 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 70 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 71 BluetoothCodecConfig.SAMPLE_RATE_44100 72 | BluetoothCodecConfig.SAMPLE_RATE_48000, 73 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 74 BluetoothCodecConfig.CHANNEL_MODE_STEREO 75 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 76 1000, 2000, 3000, 4000); 77 78 private static final BluetoothCodecConfig LOCAL_CAPABILITY_1_C = 79 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 80 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 81 BluetoothCodecConfig.SAMPLE_RATE_44100 82 | BluetoothCodecConfig.SAMPLE_RATE_48000, 83 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 84 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 85 1000, 2000, 3000, 4000); 86 87 88 private static final BluetoothCodecConfig LOCAL_CAPABILITY_2_A = 89 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 90 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 91 BluetoothCodecConfig.SAMPLE_RATE_44100 92 | BluetoothCodecConfig.SAMPLE_RATE_48000, 93 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 94 BluetoothCodecConfig.CHANNEL_MODE_STEREO 95 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 96 1000, 2000, 3000, 4000); 97 98 private static final BluetoothCodecConfig LOCAL_CAPABILITY_2_B = 99 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 100 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 101 BluetoothCodecConfig.SAMPLE_RATE_44100 102 | BluetoothCodecConfig.SAMPLE_RATE_48000, 103 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 104 BluetoothCodecConfig.CHANNEL_MODE_STEREO 105 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 106 1000, 2000, 3000, 4000); 107 108 private static final BluetoothCodecConfig LOCAL_CAPABILITY_2_C = 109 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 110 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 111 BluetoothCodecConfig.SAMPLE_RATE_44100 112 | BluetoothCodecConfig.SAMPLE_RATE_48000, 113 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 114 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 115 1000, 2000, 3000, 4000); 116 117 private static final BluetoothCodecConfig LOCAL_CAPABILITY_3_A = 118 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 119 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 120 BluetoothCodecConfig.SAMPLE_RATE_44100 121 | BluetoothCodecConfig.SAMPLE_RATE_48000, 122 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 123 BluetoothCodecConfig.CHANNEL_MODE_STEREO 124 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 125 1000, 2000, 3000, 4000); 126 127 private static final BluetoothCodecConfig LOCAL_CAPABILITY_3_B = 128 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 129 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 130 BluetoothCodecConfig.SAMPLE_RATE_44100 131 | BluetoothCodecConfig.SAMPLE_RATE_48000, 132 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 133 BluetoothCodecConfig.CHANNEL_MODE_STEREO 134 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 135 1000, 2000, 3000, 4000); 136 137 private static final BluetoothCodecConfig LOCAL_CAPABILITY_3_C = 138 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 139 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 140 BluetoothCodecConfig.SAMPLE_RATE_44100 141 | BluetoothCodecConfig.SAMPLE_RATE_48000, 142 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 143 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 144 1000, 2000, 3000, 4000); 145 146 private static final BluetoothCodecConfig LOCAL_CAPABILITY_4_A = 147 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 148 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 149 BluetoothCodecConfig.SAMPLE_RATE_44100 150 | BluetoothCodecConfig.SAMPLE_RATE_48000, 151 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 152 BluetoothCodecConfig.CHANNEL_MODE_STEREO 153 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 154 1000, 2000, 3000, 4000); 155 156 private static final BluetoothCodecConfig LOCAL_CAPABILITY_4_B = 157 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 158 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 159 BluetoothCodecConfig.SAMPLE_RATE_44100 160 | BluetoothCodecConfig.SAMPLE_RATE_48000, 161 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 162 BluetoothCodecConfig.CHANNEL_MODE_STEREO 163 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 164 1000, 2000, 3000, 4000); 165 166 private static final BluetoothCodecConfig LOCAL_CAPABILITY_4_C = 167 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 168 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 169 BluetoothCodecConfig.SAMPLE_RATE_44100 170 | BluetoothCodecConfig.SAMPLE_RATE_48000, 171 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 172 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 173 1000, 2000, 3000, 4000); 174 175 private static final BluetoothCodecConfig LOCAL_CAPABILITY_5_A = 176 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 177 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 178 BluetoothCodecConfig.SAMPLE_RATE_44100 179 | BluetoothCodecConfig.SAMPLE_RATE_48000 180 | BluetoothCodecConfig.SAMPLE_RATE_88200 181 | BluetoothCodecConfig.SAMPLE_RATE_96000, 182 BluetoothCodecConfig.BITS_PER_SAMPLE_16 183 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 184 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 185 BluetoothCodecConfig.CHANNEL_MODE_STEREO 186 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 187 1000, 2000, 3000, 4000); 188 189 private static final BluetoothCodecConfig LOCAL_CAPABILITY_5_B = 190 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 191 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 192 BluetoothCodecConfig.SAMPLE_RATE_44100 193 | BluetoothCodecConfig.SAMPLE_RATE_48000 194 | BluetoothCodecConfig.SAMPLE_RATE_88200 195 | BluetoothCodecConfig.SAMPLE_RATE_96000, 196 BluetoothCodecConfig.BITS_PER_SAMPLE_16 197 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 198 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 199 BluetoothCodecConfig.CHANNEL_MODE_STEREO 200 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 201 1000, 2000, 3000, 4000); 202 203 private static final BluetoothCodecConfig LOCAL_CAPABILITY_5_C = 204 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 205 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 206 BluetoothCodecConfig.SAMPLE_RATE_44100 207 | BluetoothCodecConfig.SAMPLE_RATE_48000 208 | BluetoothCodecConfig.SAMPLE_RATE_88200 209 | BluetoothCodecConfig.SAMPLE_RATE_96000, 210 BluetoothCodecConfig.BITS_PER_SAMPLE_16 211 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 212 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 213 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 214 1000, 2000, 3000, 4000); 215 216 217 // Selectable capabilities: A and B are same; C is different 218 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_1_A = 219 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 220 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 221 BluetoothCodecConfig.SAMPLE_RATE_44100, 222 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 223 BluetoothCodecConfig.CHANNEL_MODE_STEREO 224 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 225 1000, 2000, 3000, 4000); 226 227 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_1_B = 228 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 229 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 230 BluetoothCodecConfig.SAMPLE_RATE_44100, 231 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 232 BluetoothCodecConfig.CHANNEL_MODE_STEREO 233 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 234 1000, 2000, 3000, 4000); 235 236 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_1_C = 237 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, 238 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 239 BluetoothCodecConfig.SAMPLE_RATE_44100, 240 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 241 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 242 1000, 2000, 3000, 4000); 243 244 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_2_A = 245 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 246 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 247 BluetoothCodecConfig.SAMPLE_RATE_44100, 248 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 249 BluetoothCodecConfig.CHANNEL_MODE_STEREO 250 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 251 1000, 2000, 3000, 4000); 252 253 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_2_B = 254 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 255 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 256 BluetoothCodecConfig.SAMPLE_RATE_44100, 257 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 258 BluetoothCodecConfig.CHANNEL_MODE_STEREO 259 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 260 1000, 2000, 3000, 4000); 261 262 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_2_C = 263 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, 264 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 265 BluetoothCodecConfig.SAMPLE_RATE_44100, 266 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 267 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 268 1000, 2000, 3000, 4000); 269 270 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_3_A = 271 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 272 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 273 BluetoothCodecConfig.SAMPLE_RATE_44100, 274 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 275 BluetoothCodecConfig.CHANNEL_MODE_STEREO 276 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 277 1000, 2000, 3000, 4000); 278 279 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_3_B = 280 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 281 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 282 BluetoothCodecConfig.SAMPLE_RATE_44100, 283 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 284 BluetoothCodecConfig.CHANNEL_MODE_STEREO 285 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 286 1000, 2000, 3000, 4000); 287 288 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_3_C = 289 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, 290 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 291 BluetoothCodecConfig.SAMPLE_RATE_44100, 292 BluetoothCodecConfig.BITS_PER_SAMPLE_16, 293 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 294 1000, 2000, 3000, 4000); 295 296 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_4_A = 297 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 298 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 299 BluetoothCodecConfig.SAMPLE_RATE_44100, 300 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 301 BluetoothCodecConfig.CHANNEL_MODE_STEREO 302 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 303 1000, 2000, 3000, 4000); 304 305 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_4_B = 306 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 307 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 308 BluetoothCodecConfig.SAMPLE_RATE_44100, 309 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 310 BluetoothCodecConfig.CHANNEL_MODE_STEREO 311 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 312 1000, 2000, 3000, 4000); 313 314 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_4_C = 315 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, 316 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 317 BluetoothCodecConfig.SAMPLE_RATE_44100, 318 BluetoothCodecConfig.BITS_PER_SAMPLE_24, 319 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 320 1000, 2000, 3000, 4000); 321 322 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_5_A = 323 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 324 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 325 BluetoothCodecConfig.SAMPLE_RATE_44100 326 | BluetoothCodecConfig.SAMPLE_RATE_48000 327 | BluetoothCodecConfig.SAMPLE_RATE_88200 328 | BluetoothCodecConfig.SAMPLE_RATE_96000, 329 BluetoothCodecConfig.BITS_PER_SAMPLE_16 330 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 331 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 332 BluetoothCodecConfig.CHANNEL_MODE_STEREO 333 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 334 1000, 2000, 3000, 4000); 335 336 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_5_B = 337 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 338 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 339 BluetoothCodecConfig.SAMPLE_RATE_44100 340 | BluetoothCodecConfig.SAMPLE_RATE_48000 341 | BluetoothCodecConfig.SAMPLE_RATE_88200 342 | BluetoothCodecConfig.SAMPLE_RATE_96000, 343 BluetoothCodecConfig.BITS_PER_SAMPLE_16 344 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 345 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 346 BluetoothCodecConfig.CHANNEL_MODE_STEREO 347 | BluetoothCodecConfig.CHANNEL_MODE_MONO, 348 1000, 2000, 3000, 4000); 349 350 private static final BluetoothCodecConfig SELECTABE_CAPABILITY_5_C = 351 buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 352 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, 353 BluetoothCodecConfig.SAMPLE_RATE_44100 354 | BluetoothCodecConfig.SAMPLE_RATE_48000 355 | BluetoothCodecConfig.SAMPLE_RATE_88200 356 | BluetoothCodecConfig.SAMPLE_RATE_96000, 357 BluetoothCodecConfig.BITS_PER_SAMPLE_16 358 | BluetoothCodecConfig.BITS_PER_SAMPLE_24 359 | BluetoothCodecConfig.BITS_PER_SAMPLE_32, 360 BluetoothCodecConfig.CHANNEL_MODE_STEREO, 361 1000, 2000, 3000, 4000); 362 363 private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_A = 364 new ArrayList() {{ 365 add(LOCAL_CAPABILITY_1_A); 366 add(LOCAL_CAPABILITY_2_A); 367 add(LOCAL_CAPABILITY_3_A); 368 add(LOCAL_CAPABILITY_4_A); 369 add(LOCAL_CAPABILITY_5_A); 370 }}; 371 372 private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_B = 373 new ArrayList() {{ 374 add(LOCAL_CAPABILITY_1_B); 375 add(LOCAL_CAPABILITY_2_B); 376 add(LOCAL_CAPABILITY_3_B); 377 add(LOCAL_CAPABILITY_4_B); 378 add(LOCAL_CAPABILITY_5_B); 379 }}; 380 381 private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_B_REORDERED = 382 new ArrayList() {{ 383 add(LOCAL_CAPABILITY_5_B); 384 add(LOCAL_CAPABILITY_4_B); 385 add(LOCAL_CAPABILITY_2_B); 386 add(LOCAL_CAPABILITY_3_B); 387 add(LOCAL_CAPABILITY_1_B); 388 }}; 389 390 private static final List<BluetoothCodecConfig> LOCAL_CAPABILITY_C = 391 new ArrayList() {{ 392 add(LOCAL_CAPABILITY_1_C); 393 add(LOCAL_CAPABILITY_2_C); 394 add(LOCAL_CAPABILITY_3_C); 395 add(LOCAL_CAPABILITY_4_C); 396 add(LOCAL_CAPABILITY_5_C); 397 }}; 398 399 private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_A = 400 new ArrayList() {{ 401 add(SELECTABE_CAPABILITY_1_A); 402 add(SELECTABE_CAPABILITY_2_A); 403 add(SELECTABE_CAPABILITY_3_A); 404 add(SELECTABE_CAPABILITY_4_A); 405 add(SELECTABE_CAPABILITY_5_A); 406 }}; 407 408 private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_B = 409 new ArrayList() {{ 410 add(SELECTABE_CAPABILITY_1_B); 411 add(SELECTABE_CAPABILITY_2_B); 412 add(SELECTABE_CAPABILITY_3_B); 413 add(SELECTABE_CAPABILITY_4_B); 414 add(SELECTABE_CAPABILITY_5_B); 415 }}; 416 417 private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_B_REORDERED = 418 new ArrayList() {{ 419 add(SELECTABE_CAPABILITY_5_B); 420 add(SELECTABE_CAPABILITY_4_B); 421 add(SELECTABE_CAPABILITY_2_B); 422 add(SELECTABE_CAPABILITY_3_B); 423 add(SELECTABE_CAPABILITY_1_B); 424 }}; 425 426 private static final List<BluetoothCodecConfig> SELECTABLE_CAPABILITY_C = 427 new ArrayList() {{ 428 add(SELECTABE_CAPABILITY_1_C); 429 add(SELECTABE_CAPABILITY_2_C); 430 add(SELECTABE_CAPABILITY_3_C); 431 add(SELECTABE_CAPABILITY_4_C); 432 add(SELECTABE_CAPABILITY_5_C); 433 }}; 434 435 private static final BluetoothCodecStatus BCS_A = 436 new BluetoothCodecStatus(CONFIG_A, LOCAL_CAPABILITY_A, SELECTABLE_CAPABILITY_A); 437 private static final BluetoothCodecStatus BCS_B = 438 new BluetoothCodecStatus(CONFIG_B, LOCAL_CAPABILITY_B, SELECTABLE_CAPABILITY_B); 439 private static final BluetoothCodecStatus BCS_B_REORDERED = 440 new BluetoothCodecStatus(CONFIG_B, LOCAL_CAPABILITY_B_REORDERED, 441 SELECTABLE_CAPABILITY_B_REORDERED); 442 private static final BluetoothCodecStatus BCS_C = 443 new BluetoothCodecStatus(CONFIG_C, LOCAL_CAPABILITY_C, SELECTABLE_CAPABILITY_C); 444 445 @SmallTest testBluetoothCodecStatus_get_methods()446 public void testBluetoothCodecStatus_get_methods() { 447 448 assertTrue(Objects.equals(BCS_A.getCodecConfig(), CONFIG_A)); 449 assertTrue(Objects.equals(BCS_A.getCodecConfig(), CONFIG_B)); 450 assertFalse(Objects.equals(BCS_A.getCodecConfig(), CONFIG_C)); 451 452 assertTrue(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_A)); 453 assertTrue(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_B)); 454 assertFalse(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_C)); 455 456 assertTrue(BCS_A.getCodecsSelectableCapabilities() 457 .equals(SELECTABLE_CAPABILITY_A)); 458 assertTrue(BCS_A.getCodecsSelectableCapabilities() 459 .equals(SELECTABLE_CAPABILITY_B)); 460 assertFalse(BCS_A.getCodecsSelectableCapabilities() 461 .equals(SELECTABLE_CAPABILITY_C)); 462 } 463 464 @SmallTest testBluetoothCodecStatus_equals()465 public void testBluetoothCodecStatus_equals() { 466 assertTrue(BCS_A.equals(BCS_B)); 467 assertTrue(BCS_B.equals(BCS_A)); 468 assertTrue(BCS_A.equals(BCS_B_REORDERED)); 469 assertTrue(BCS_B_REORDERED.equals(BCS_A)); 470 assertFalse(BCS_A.equals(BCS_C)); 471 assertFalse(BCS_C.equals(BCS_A)); 472 } 473 buildBluetoothCodecConfig(int sourceCodecType, int codecPriority, int sampleRate, int bitsPerSample, int channelMode, long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4)474 private static BluetoothCodecConfig buildBluetoothCodecConfig(int sourceCodecType, 475 int codecPriority, int sampleRate, int bitsPerSample, int channelMode, 476 long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4) { 477 return new BluetoothCodecConfig.Builder() 478 .setCodecType(sourceCodecType) 479 .setCodecPriority(codecPriority) 480 .setSampleRate(sampleRate) 481 .setBitsPerSample(bitsPerSample) 482 .setChannelMode(channelMode) 483 .setCodecSpecific1(codecSpecific1) 484 .setCodecSpecific2(codecSpecific2) 485 .setCodecSpecific3(codecSpecific3) 486 .setCodecSpecific4(codecSpecific4) 487 .build(); 488 489 } 490 } 491