1 /* 2 * Copyright (C) 2021 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.le_audio; 18 19 import android.bluetooth.BluetoothLeAudioCodecConfig; 20 import android.content.Context; 21 import android.media.AudioManager; 22 import android.util.Log; 23 24 /* 25 * LeAudio Codec Configuration setup. 26 */ 27 class LeAudioCodecConfig { 28 private static final String TAG = "LeAudioCodecConfig"; 29 30 private Context mContext; 31 private BluetoothLeAudioCodecConfig[] mCodecConfigOffloading = 32 new BluetoothLeAudioCodecConfig[0]; 33 LeAudioCodecConfig(Context context)34 LeAudioCodecConfig(Context context) { 35 Log.i(TAG, "LeAudioCodecConfig init"); 36 mContext = context; 37 38 AudioManager audioManager = mContext.getSystemService(AudioManager.class); 39 if (audioManager == null) { 40 Log.w(TAG, "Can't obtain the codec offloading prefernece from null AudioManager"); 41 return; 42 } 43 44 mCodecConfigOffloading = 45 audioManager 46 .getHwOffloadFormatsSupportedForLeAudio() 47 .toArray(mCodecConfigOffloading); 48 49 Log.i(TAG, "mCodecConfigOffloading size for le -> " + mCodecConfigOffloading.length); 50 51 for (int idx = 0; idx < mCodecConfigOffloading.length; idx++) { 52 Log.i( 53 TAG, 54 String.format( 55 "mCodecConfigOffloading[%d] -> %s", 56 idx, mCodecConfigOffloading[idx].toString())); 57 } 58 } 59 getCodecConfigOffloading()60 BluetoothLeAudioCodecConfig[] getCodecConfigOffloading() { 61 return mCodecConfigOffloading; 62 } 63 } 64