• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 static com.google.common.truth.Truth.assertThat;
20 
21 import androidx.test.runner.AndroidJUnit4;
22 
23 import com.google.common.truth.Expect;
24 
25 import org.junit.Rule;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 
29 /** Test cases for {@link BluetoothCodecConfig}. */
30 @RunWith(AndroidJUnit4.class)
31 public class BluetoothCodecConfigTest {
32 
33     @Rule public Expect expect = Expect.create();
34 
35     private static final int[] sCodecTypeArray =
36             new int[] {
37                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
38                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
39                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
40                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
41                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
42                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS,
43                 BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID,
44             };
45     private static final int[] sCodecPriorityArray =
46             new int[] {
47                 BluetoothCodecConfig.CODEC_PRIORITY_DISABLED,
48                 BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
49                 BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
50             };
51     private static final int[] sSampleRateArray =
52             new int[] {
53                 BluetoothCodecConfig.SAMPLE_RATE_NONE,
54                 BluetoothCodecConfig.SAMPLE_RATE_44100,
55                 BluetoothCodecConfig.SAMPLE_RATE_48000,
56                 BluetoothCodecConfig.SAMPLE_RATE_88200,
57                 BluetoothCodecConfig.SAMPLE_RATE_96000,
58                 BluetoothCodecConfig.SAMPLE_RATE_176400,
59                 BluetoothCodecConfig.SAMPLE_RATE_192000,
60             };
61     private static final int[] sBitsPerSampleArray =
62             new int[] {
63                 BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
64                 BluetoothCodecConfig.BITS_PER_SAMPLE_16,
65                 BluetoothCodecConfig.BITS_PER_SAMPLE_24,
66                 BluetoothCodecConfig.BITS_PER_SAMPLE_32,
67             };
68     private static final int[] sChannelModeArray =
69             new int[] {
70                 BluetoothCodecConfig.CHANNEL_MODE_NONE,
71                 BluetoothCodecConfig.CHANNEL_MODE_MONO,
72                 BluetoothCodecConfig.CHANNEL_MODE_STEREO,
73             };
74     private static final long[] sCodecSpecific1Array =
75             new long[] {
76                 1000, 1001, 1002, 1003,
77             };
78     private static final long[] sCodecSpecific2Array =
79             new long[] {
80                 2000, 2001, 2002, 2003,
81             };
82     private static final long[] sCodecSpecific3Array =
83             new long[] {
84                 3000, 3001, 3002, 3003,
85             };
86     private static final long[] sCodecSpecific4Array =
87             new long[] {
88                 4000, 4001, 4002, 4003,
89             };
90 
91     private static final int sTotalConfigs =
92             sCodecTypeArray.length
93                     * sCodecPriorityArray.length
94                     * sSampleRateArray.length
95                     * sBitsPerSampleArray.length
96                     * sChannelModeArray.length
97                     * sCodecSpecific1Array.length
98                     * sCodecSpecific2Array.length
99                     * sCodecSpecific3Array.length
100                     * sCodecSpecific4Array.length;
101 
selectCodecType(int configId)102     private int selectCodecType(int configId) {
103         int left = sCodecTypeArray.length;
104         int right = sTotalConfigs / left;
105         int index = configId / right;
106         index = index % sCodecTypeArray.length;
107         return sCodecTypeArray[index];
108     }
109 
selectCodecPriority(int configId)110     private int selectCodecPriority(int configId) {
111         int left = sCodecTypeArray.length * sCodecPriorityArray.length;
112         int right = sTotalConfigs / left;
113         int index = configId / right;
114         index = index % sCodecPriorityArray.length;
115         return sCodecPriorityArray[index];
116     }
117 
selectSampleRate(int configId)118     private int selectSampleRate(int configId) {
119         int left = sCodecTypeArray.length * sCodecPriorityArray.length * sSampleRateArray.length;
120         int right = sTotalConfigs / left;
121         int index = configId / right;
122         index = index % sSampleRateArray.length;
123         return sSampleRateArray[index];
124     }
125 
selectBitsPerSample(int configId)126     private int selectBitsPerSample(int configId) {
127         int left =
128                 sCodecTypeArray.length
129                         * sCodecPriorityArray.length
130                         * sSampleRateArray.length
131                         * sBitsPerSampleArray.length;
132         int right = sTotalConfigs / left;
133         int index = configId / right;
134         index = index % sBitsPerSampleArray.length;
135         return sBitsPerSampleArray[index];
136     }
137 
selectChannelMode(int configId)138     private int selectChannelMode(int configId) {
139         int left =
140                 sCodecTypeArray.length
141                         * sCodecPriorityArray.length
142                         * sSampleRateArray.length
143                         * sBitsPerSampleArray.length
144                         * sChannelModeArray.length;
145         int right = sTotalConfigs / left;
146         int index = configId / right;
147         index = index % sChannelModeArray.length;
148         return sChannelModeArray[index];
149     }
150 
selectCodecSpecific1(int configId)151     private long selectCodecSpecific1(int configId) {
152         int left =
153                 sCodecTypeArray.length
154                         * sCodecPriorityArray.length
155                         * sSampleRateArray.length
156                         * sBitsPerSampleArray.length
157                         * sChannelModeArray.length
158                         * sCodecSpecific1Array.length;
159         int right = sTotalConfigs / left;
160         int index = configId / right;
161         index = index % sCodecSpecific1Array.length;
162         return sCodecSpecific1Array[index];
163     }
164 
selectCodecSpecific2(int configId)165     private long selectCodecSpecific2(int configId) {
166         int left =
167                 sCodecTypeArray.length
168                         * sCodecPriorityArray.length
169                         * sSampleRateArray.length
170                         * sBitsPerSampleArray.length
171                         * sChannelModeArray.length
172                         * sCodecSpecific1Array.length
173                         * sCodecSpecific2Array.length;
174         int right = sTotalConfigs / left;
175         int index = configId / right;
176         index = index % sCodecSpecific2Array.length;
177         return sCodecSpecific2Array[index];
178     }
179 
selectCodecSpecific3(int configId)180     private long selectCodecSpecific3(int configId) {
181         int left =
182                 sCodecTypeArray.length
183                         * sCodecPriorityArray.length
184                         * sSampleRateArray.length
185                         * sBitsPerSampleArray.length
186                         * sChannelModeArray.length
187                         * sCodecSpecific1Array.length
188                         * sCodecSpecific2Array.length
189                         * sCodecSpecific3Array.length;
190         int right = sTotalConfigs / left;
191         int index = configId / right;
192         index = index % sCodecSpecific3Array.length;
193         return sCodecSpecific3Array[index];
194     }
195 
selectCodecSpecific4(int configId)196     private long selectCodecSpecific4(int configId) {
197         int left =
198                 sCodecTypeArray.length
199                         * sCodecPriorityArray.length
200                         * sSampleRateArray.length
201                         * sBitsPerSampleArray.length
202                         * sChannelModeArray.length
203                         * sCodecSpecific1Array.length
204                         * sCodecSpecific2Array.length
205                         * sCodecSpecific3Array.length
206                         * sCodecSpecific4Array.length;
207         int right = sTotalConfigs / left;
208         int index = configId / right;
209         index = index % sCodecSpecific4Array.length;
210         return sCodecSpecific4Array[index];
211     }
212 
213     @Test
testBluetoothCodecConfig_valid_get_methods()214     public void testBluetoothCodecConfig_valid_get_methods() {
215         for (int config_id = 0; config_id < sTotalConfigs; config_id++) {
216             int codec_type = selectCodecType(config_id);
217             int codec_priority = selectCodecPriority(config_id);
218             int sample_rate = selectSampleRate(config_id);
219             int bits_per_sample = selectBitsPerSample(config_id);
220             int channel_mode = selectChannelMode(config_id);
221             long codec_specific1 = selectCodecSpecific1(config_id);
222             long codec_specific2 = selectCodecSpecific2(config_id);
223             long codec_specific3 = selectCodecSpecific3(config_id);
224             long codec_specific4 = selectCodecSpecific4(config_id);
225 
226             BluetoothCodecConfig bcc =
227                     buildBluetoothCodecConfig(
228                             codec_type,
229                             codec_priority,
230                             sample_rate,
231                             bits_per_sample,
232                             channel_mode,
233                             codec_specific1,
234                             codec_specific2,
235                             codec_specific3,
236                             codec_specific4);
237 
238             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) {
239                 expect.that(bcc.isMandatoryCodec()).isTrue();
240             } else {
241                 expect.that(bcc.isMandatoryCodec()).isFalse();
242             }
243 
244             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) {
245                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("SBC");
246             }
247             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) {
248                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("AAC");
249             }
250             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX) {
251                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("aptX");
252             }
253             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD) {
254                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("aptX HD");
255             }
256             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) {
257                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("LDAC");
258             }
259             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS) {
260                 expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("Opus");
261             }
262             if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
263                 expect.that(BluetoothCodecConfig.getCodecName(codec_type))
264                         .isEqualTo("INVALID CODEC");
265             }
266 
267             expect.that(bcc.getCodecType()).isEqualTo(codec_type);
268             expect.that(bcc.getCodecPriority()).isEqualTo(codec_priority);
269             expect.that(bcc.getSampleRate()).isEqualTo(sample_rate);
270             expect.that(bcc.getBitsPerSample()).isEqualTo(bits_per_sample);
271             expect.that(bcc.getChannelMode()).isEqualTo(channel_mode);
272             expect.that(bcc.getCodecSpecific1()).isEqualTo(codec_specific1);
273             expect.that(bcc.getCodecSpecific2()).isEqualTo(codec_specific2);
274             expect.that(bcc.getCodecSpecific3()).isEqualTo(codec_specific3);
275             expect.that(bcc.getCodecSpecific4()).isEqualTo(codec_specific4);
276         }
277     }
278 
279     @Test
testBluetoothCodecConfig_same()280     public void testBluetoothCodecConfig_same() {
281         BluetoothCodecConfig bcc1 =
282                 buildBluetoothCodecConfig(
283                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
284                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
285                         BluetoothCodecConfig.SAMPLE_RATE_44100,
286                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
287                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
288                         1000,
289                         2000,
290                         3000,
291                         4000);
292 
293         BluetoothCodecConfig bcc2_same =
294                 buildBluetoothCodecConfig(
295                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
296                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
297                         BluetoothCodecConfig.SAMPLE_RATE_44100,
298                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
299                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
300                         1000,
301                         2000,
302                         3000,
303                         4000);
304         assertThat(bcc2_same).isEqualTo(bcc1);
305     }
306 
307     @Test
testBluetoothCodecConfig_different_codec_type()308     public void testBluetoothCodecConfig_different_codec_type() {
309         BluetoothCodecConfig bcc1 =
310                 buildBluetoothCodecConfig(
311                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
312                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
313                         BluetoothCodecConfig.SAMPLE_RATE_44100,
314                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
315                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
316                         1000,
317                         2000,
318                         3000,
319                         4000);
320 
321         BluetoothCodecConfig bcc3_codec_type =
322                 buildBluetoothCodecConfig(
323                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
324                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
325                         BluetoothCodecConfig.SAMPLE_RATE_44100,
326                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
327                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
328                         1000,
329                         2000,
330                         3000,
331                         4000);
332         assertThat(bcc3_codec_type).isNotEqualTo(bcc1);
333     }
334 
335     @Test
testBluetoothCodecConfig_different_codec_priority()336     public void testBluetoothCodecConfig_different_codec_priority() {
337         BluetoothCodecConfig bcc1 =
338                 buildBluetoothCodecConfig(
339                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
340                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
341                         BluetoothCodecConfig.SAMPLE_RATE_44100,
342                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
343                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
344                         1000,
345                         2000,
346                         3000,
347                         4000);
348 
349         BluetoothCodecConfig bcc4_codec_priority =
350                 buildBluetoothCodecConfig(
351                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
352                         BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
353                         BluetoothCodecConfig.SAMPLE_RATE_44100,
354                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
355                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
356                         1000,
357                         2000,
358                         3000,
359                         4000);
360         assertThat(bcc4_codec_priority).isNotEqualTo(bcc1);
361     }
362 
363     @Test
testBluetoothCodecConfig_different_sample_rate()364     public void testBluetoothCodecConfig_different_sample_rate() {
365         BluetoothCodecConfig bcc1 =
366                 buildBluetoothCodecConfig(
367                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
368                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
369                         BluetoothCodecConfig.SAMPLE_RATE_44100,
370                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
371                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
372                         1000,
373                         2000,
374                         3000,
375                         4000);
376 
377         BluetoothCodecConfig bcc5_sample_rate =
378                 buildBluetoothCodecConfig(
379                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
380                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
381                         BluetoothCodecConfig.SAMPLE_RATE_48000,
382                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
383                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
384                         1000,
385                         2000,
386                         3000,
387                         4000);
388         assertThat(bcc5_sample_rate).isNotEqualTo(bcc1);
389     }
390 
391     @Test
testBluetoothCodecConfig_different_bits_per_sample()392     public void testBluetoothCodecConfig_different_bits_per_sample() {
393         BluetoothCodecConfig bcc1 =
394                 buildBluetoothCodecConfig(
395                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
396                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
397                         BluetoothCodecConfig.SAMPLE_RATE_44100,
398                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
399                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
400                         1000,
401                         2000,
402                         3000,
403                         4000);
404 
405         BluetoothCodecConfig bcc6_bits_per_sample =
406                 buildBluetoothCodecConfig(
407                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
408                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
409                         BluetoothCodecConfig.SAMPLE_RATE_44100,
410                         BluetoothCodecConfig.BITS_PER_SAMPLE_24,
411                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
412                         1000,
413                         2000,
414                         3000,
415                         4000);
416         assertThat(bcc6_bits_per_sample).isNotEqualTo(bcc1);
417     }
418 
419     @Test
testBluetoothCodecConfig_different_channel_mode()420     public void testBluetoothCodecConfig_different_channel_mode() {
421         BluetoothCodecConfig bcc1 =
422                 buildBluetoothCodecConfig(
423                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
424                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
425                         BluetoothCodecConfig.SAMPLE_RATE_44100,
426                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
427                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
428                         1000,
429                         2000,
430                         3000,
431                         4000);
432 
433         BluetoothCodecConfig bcc7_channel_mode =
434                 buildBluetoothCodecConfig(
435                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
436                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
437                         BluetoothCodecConfig.SAMPLE_RATE_44100,
438                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
439                         BluetoothCodecConfig.CHANNEL_MODE_MONO,
440                         1000,
441                         2000,
442                         3000,
443                         4000);
444         assertThat(bcc7_channel_mode).isNotEqualTo(bcc1);
445     }
446 
447     @Test
testBluetoothCodecConfig_different_code_specific_1()448     public void testBluetoothCodecConfig_different_code_specific_1() {
449         BluetoothCodecConfig bcc1 =
450                 buildBluetoothCodecConfig(
451                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
452                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
453                         BluetoothCodecConfig.SAMPLE_RATE_44100,
454                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
455                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
456                         1000,
457                         2000,
458                         3000,
459                         4000);
460 
461         BluetoothCodecConfig bcc8_codec_specific1 =
462                 buildBluetoothCodecConfig(
463                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
464                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
465                         BluetoothCodecConfig.SAMPLE_RATE_44100,
466                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
467                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
468                         1001,
469                         2000,
470                         3000,
471                         4000);
472         assertThat(bcc8_codec_specific1).isNotEqualTo(bcc1);
473     }
474 
475     @Test
testBluetoothCodecConfig_different_code_specific_2()476     public void testBluetoothCodecConfig_different_code_specific_2() {
477         BluetoothCodecConfig bcc1 =
478                 buildBluetoothCodecConfig(
479                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
480                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
481                         BluetoothCodecConfig.SAMPLE_RATE_44100,
482                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
483                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
484                         1000,
485                         2000,
486                         3000,
487                         4000);
488 
489         BluetoothCodecConfig bcc9_codec_specific2 =
490                 buildBluetoothCodecConfig(
491                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
492                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
493                         BluetoothCodecConfig.SAMPLE_RATE_44100,
494                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
495                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
496                         1000,
497                         2002,
498                         3000,
499                         4000);
500         assertThat(bcc9_codec_specific2).isNotEqualTo(bcc1);
501     }
502 
503     @Test
testBluetoothCodecConfig_different_code_specific_3()504     public void testBluetoothCodecConfig_different_code_specific_3() {
505         BluetoothCodecConfig bcc1 =
506                 buildBluetoothCodecConfig(
507                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
508                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
509                         BluetoothCodecConfig.SAMPLE_RATE_44100,
510                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
511                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
512                         1000,
513                         2000,
514                         3000,
515                         4000);
516 
517         BluetoothCodecConfig bcc10_codec_specific3 =
518                 buildBluetoothCodecConfig(
519                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
520                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
521                         BluetoothCodecConfig.SAMPLE_RATE_44100,
522                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
523                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
524                         1000,
525                         2000,
526                         3003,
527                         4000);
528         assertThat(bcc10_codec_specific3).isNotEqualTo(bcc1);
529     }
530 
531     @Test
testBluetoothCodecConfig_different_code_specific_4()532     public void testBluetoothCodecConfig_different_code_specific_4() {
533         BluetoothCodecConfig bcc1 =
534                 buildBluetoothCodecConfig(
535                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
536                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
537                         BluetoothCodecConfig.SAMPLE_RATE_44100,
538                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
539                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
540                         1000,
541                         2000,
542                         3000,
543                         4000);
544 
545         BluetoothCodecConfig bcc11_codec_specific4 =
546                 buildBluetoothCodecConfig(
547                         BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
548                         BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
549                         BluetoothCodecConfig.SAMPLE_RATE_44100,
550                         BluetoothCodecConfig.BITS_PER_SAMPLE_16,
551                         BluetoothCodecConfig.CHANNEL_MODE_STEREO,
552                         1000,
553                         2000,
554                         3000,
555                         4004);
556         assertThat(bcc11_codec_specific4).isNotEqualTo(bcc1);
557     }
558 
buildBluetoothCodecConfig( int sourceCodecType, int codecPriority, int sampleRate, int bitsPerSample, int channelMode, long codecSpecific1, long codecSpecific2, long codecSpecific3, long codecSpecific4)559     private BluetoothCodecConfig buildBluetoothCodecConfig(
560             int sourceCodecType,
561             int codecPriority,
562             int sampleRate,
563             int bitsPerSample,
564             int channelMode,
565             long codecSpecific1,
566             long codecSpecific2,
567             long codecSpecific3,
568             long codecSpecific4) {
569         return new BluetoothCodecConfig.Builder()
570                 .setCodecType(sourceCodecType)
571                 .setCodecPriority(codecPriority)
572                 .setSampleRate(sampleRate)
573                 .setBitsPerSample(bitsPerSample)
574                 .setChannelMode(channelMode)
575                 .setCodecSpecific1(codecSpecific1)
576                 .setCodecSpecific2(codecSpecific2)
577                 .setCodecSpecific3(codecSpecific3)
578                 .setCodecSpecific4(codecSpecific4)
579                 .build();
580     }
581 }
582