1 /* 2 * Copyright (C) 2017 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.settings.development; 18 19 import android.bluetooth.BluetoothCodecConfig; 20 import android.bluetooth.BluetoothCodecType; 21 22 import androidx.annotation.Nullable; 23 24 /** Utility class for storing current Bluetooth A2DP profile values */ 25 public class BluetoothA2dpConfigStore { 26 27 // init default values 28 private int mCodecTypeNative = BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID; 29 @Nullable private BluetoothCodecType mCodecType = null; 30 private int mCodecPriority = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; 31 private int mSampleRate = BluetoothCodecConfig.SAMPLE_RATE_NONE; 32 private int mBitsPerSample = BluetoothCodecConfig.BITS_PER_SAMPLE_NONE; 33 private int mChannelMode = BluetoothCodecConfig.CHANNEL_MODE_NONE; 34 private long mCodecSpecific1Value; 35 private long mCodecSpecific2Value; 36 private long mCodecSpecific3Value; 37 private long mCodecSpecific4Value; 38 setCodecType(@ullable BluetoothCodecType codecType)39 public void setCodecType(@Nullable BluetoothCodecType codecType) { 40 mCodecType = codecType; 41 } 42 setCodecPriority(int codecPriority)43 public void setCodecPriority(int codecPriority) { 44 mCodecPriority = codecPriority; 45 } 46 setSampleRate(int sampleRate)47 public void setSampleRate(int sampleRate) { 48 mSampleRate = sampleRate; 49 } 50 setBitsPerSample(int bitsPerSample)51 public void setBitsPerSample(int bitsPerSample) { 52 mBitsPerSample = bitsPerSample; 53 } 54 setChannelMode(int channelMode)55 public void setChannelMode(int channelMode) { 56 mChannelMode = channelMode; 57 } 58 setCodecSpecific1Value(long codecSpecific1Value)59 public void setCodecSpecific1Value(long codecSpecific1Value) { 60 mCodecSpecific1Value = codecSpecific1Value; 61 } 62 setCodecSpecific2Value(int codecSpecific2Value)63 public void setCodecSpecific2Value(int codecSpecific2Value) { 64 mCodecSpecific2Value = codecSpecific2Value; 65 } 66 setCodecSpecific3Value(int codecSpecific3Value)67 public void setCodecSpecific3Value(int codecSpecific3Value) { 68 mCodecSpecific3Value = codecSpecific3Value; 69 } 70 setCodecSpecific4Value(int codecSpecific4Value)71 public void setCodecSpecific4Value(int codecSpecific4Value) { 72 mCodecSpecific4Value = codecSpecific4Value; 73 } 74 75 /** Create codec config utilizing {@link BluetoothCodecConfig.SourceCodecType} */ createCodecConfig()76 public BluetoothCodecConfig createCodecConfig() { 77 BluetoothCodecConfig.Builder builder = new BluetoothCodecConfig.Builder() 78 .setCodecPriority(mCodecPriority) 79 .setExtendedCodecType(mCodecType) 80 .setSampleRate(mSampleRate) 81 .setBitsPerSample(mBitsPerSample) 82 .setChannelMode(mChannelMode) 83 .setCodecSpecific1(mCodecSpecific1Value) 84 .setCodecSpecific2(mCodecSpecific2Value) 85 .setCodecSpecific3(mCodecSpecific3Value) 86 .setCodecSpecific4(mCodecSpecific4Value); 87 return builder.build(); 88 } 89 } 90