/* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.bluetooth; import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * Unit test cases for {@link BluetoothCodecStatus}. *
* To run this test, use:
* runtest --path core/tests/bluetoothtests/src/android/bluetooth/BluetoothCodecStatusTest.java
*/
public class BluetoothCodecStatusTest extends TestCase {
// Codec configs: A and B are same; C is different
private static final BluetoothCodecConfig config_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig config_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig config_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
// Local capabilities: A and B are same; C is different
private static final BluetoothCodecConfig local_capability1_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability1_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability1_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability2_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability2_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability2_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability3_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability3_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability3_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability4_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability4_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability4_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability5_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability5_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig local_capability5_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
// Selectable capabilities: A and B are same; C is different
private static final BluetoothCodecConfig selectable_capability1_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability1_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability1_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability2_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability2_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability2_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability3_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability3_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability3_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_16,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability4_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability4_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability4_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100,
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability5_A =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability5_B =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO |
BluetoothCodecConfig.CHANNEL_MODE_MONO,
1000, 2000, 3000, 4000);
private static final BluetoothCodecConfig selectable_capability5_C =
buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
BluetoothCodecConfig.SAMPLE_RATE_44100 |
BluetoothCodecConfig.SAMPLE_RATE_48000 |
BluetoothCodecConfig.SAMPLE_RATE_88200 |
BluetoothCodecConfig.SAMPLE_RATE_96000,
BluetoothCodecConfig.BITS_PER_SAMPLE_16 |
BluetoothCodecConfig.BITS_PER_SAMPLE_24 |
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
1000, 2000, 3000, 4000);
private static final List