24Q4: Removal of a2dp_offload_codec_extensibility_settings
Bug: 323319530 Fix: 323319530 Flag: EXEMPT removing com.android.settings.development.a2dp_offload_codec_extensibility_settings Test: atest SettingsRoboTests Merged-In: If9c710c0aaed7326b32dd2e7d5f3109de4047b97 Change-Id: I3fad2d0b5b356afd3524ef9ddc0cf1ccbaed9eb4
This commit is contained in:
@@ -16,11 +16,9 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import android.annotation.FlaggedApi;
|
||||
import android.bluetooth.BluetoothCodecConfig;
|
||||
import android.bluetooth.BluetoothCodecType;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/** Utility class for storing current Bluetooth A2DP profile values */
|
||||
@@ -38,10 +36,6 @@ public class BluetoothA2dpConfigStore {
|
||||
private long mCodecSpecific3Value;
|
||||
private long mCodecSpecific4Value;
|
||||
|
||||
public void setCodecType(int codecType) {
|
||||
mCodecTypeNative = codecType;
|
||||
}
|
||||
|
||||
public void setCodecType(@Nullable BluetoothCodecType codecType) {
|
||||
mCodecType = codecType;
|
||||
}
|
||||
@@ -82,6 +76,7 @@ public class BluetoothA2dpConfigStore {
|
||||
public BluetoothCodecConfig createCodecConfig() {
|
||||
BluetoothCodecConfig.Builder builder = new BluetoothCodecConfig.Builder()
|
||||
.setCodecPriority(mCodecPriority)
|
||||
.setExtendedCodecType(mCodecType)
|
||||
.setSampleRate(mSampleRate)
|
||||
.setBitsPerSample(mBitsPerSample)
|
||||
.setChannelMode(mChannelMode)
|
||||
@@ -89,27 +84,6 @@ public class BluetoothA2dpConfigStore {
|
||||
.setCodecSpecific2(mCodecSpecific2Value)
|
||||
.setCodecSpecific3(mCodecSpecific3Value)
|
||||
.setCodecSpecific4(mCodecSpecific4Value);
|
||||
if (Flags.a2dpOffloadCodecExtensibilitySettings()) {
|
||||
builder.setExtendedCodecType(mCodecType);
|
||||
} else {
|
||||
builder.setCodecType(mCodecTypeNative);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/** Create codec config utilizing {@link BluetoothCodecType} */
|
||||
@FlaggedApi(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS)
|
||||
public @NonNull BluetoothCodecConfig createCodecConfigFromCodecType() {
|
||||
return new BluetoothCodecConfig.Builder()
|
||||
.setExtendedCodecType(mCodecType)
|
||||
.setCodecPriority(mCodecPriority)
|
||||
.setSampleRate(mSampleRate)
|
||||
.setBitsPerSample(mBitsPerSample)
|
||||
.setChannelMode(mChannelMode)
|
||||
.setCodecSpecific1(mCodecSpecific1Value)
|
||||
.setCodecSpecific2(mCodecSpecific2Value)
|
||||
.setCodecSpecific3(mCodecSpecific3Value)
|
||||
.setCodecSpecific4(mCodecSpecific4Value)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ import com.android.settings.development.bluetooth.AbstractBluetoothDialogPrefere
|
||||
import com.android.settings.development.bluetooth.AbstractBluetoothPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothBitPerSampleDialogPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothChannelModeDialogPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothCodecDialogPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothCodecListPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothHDAudioPreferenceController;
|
||||
import com.android.settings.development.bluetooth.BluetoothQualityDialogPreferenceController;
|
||||
@@ -802,8 +801,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
controllers.add(new AutofillCategoryController(context, lifecycle));
|
||||
controllers.add(new AutofillLoggingLevelPreferenceController(context, lifecycle));
|
||||
controllers.add(new AutofillResetOptionsPreferenceController(context));
|
||||
controllers.add(new BluetoothCodecDialogPreferenceController(context, lifecycle,
|
||||
bluetoothA2dpConfigStore, fragment));
|
||||
controllers.add(
|
||||
new BluetoothCodecListPreferenceController(
|
||||
context, lifecycle, bluetoothA2dpConfigStore, fragment));
|
||||
@@ -838,8 +835,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
@Override
|
||||
public void onBluetoothCodecChanged() {
|
||||
for (AbstractPreferenceController controller : mPreferenceControllers) {
|
||||
if (controller instanceof AbstractBluetoothDialogPreferenceController
|
||||
&& !(controller instanceof BluetoothCodecDialogPreferenceController)) {
|
||||
if (controller instanceof AbstractBluetoothDialogPreferenceController) {
|
||||
((AbstractBluetoothDialogPreferenceController) controller)
|
||||
.onBluetoothCodecUpdated();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
mBluetoothA2dpConfigStore.setCodecType(config.getCodecType());
|
||||
mBluetoothA2dpConfigStore.setCodecType(config.getExtendedCodecType());
|
||||
mBluetoothA2dpConfigStore.setSampleRate(config.getSampleRate());
|
||||
mBluetoothA2dpConfigStore.setBitsPerSample(config.getBitsPerSample());
|
||||
mBluetoothA2dpConfigStore.setChannelMode(config.getChannelMode());
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 com.android.settings.development.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Dialog preference to set the Bluetooth A2DP config of codec
|
||||
*/
|
||||
public class BluetoothCodecDialogPreference extends BaseBluetoothDialogPreference implements
|
||||
RadioGroup.OnCheckedChangeListener {
|
||||
|
||||
public BluetoothCodecDialogPreference(Context context) {
|
||||
super(context);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
public BluetoothCodecDialogPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
public BluetoothCodecDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
public BluetoothCodecDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRadioButtonGroupId() {
|
||||
return R.id.bluetooth_audio_codec_radio_group;
|
||||
}
|
||||
|
||||
private void initialize(Context context) {
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_default);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_sbc);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_aac);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx_hd);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_ldac);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_lc3);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_opus);
|
||||
String[] stringArray = context.getResources().getStringArray(
|
||||
com.android.settingslib.R.array.bluetooth_a2dp_codec_titles);
|
||||
for (int i = 0; i < stringArray.length; i++) {
|
||||
mRadioButtonStrings.add(stringArray[i]);
|
||||
}
|
||||
stringArray = context.getResources()
|
||||
.getStringArray(com.android.settingslib.R.array.bluetooth_a2dp_codec_summaries);
|
||||
for (int i = 0; i < stringArray.length; i++) {
|
||||
mSummaryStrings.add(stringArray[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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 com.android.settings.development.bluetooth;
|
||||
|
||||
import android.bluetooth.BluetoothA2dp;
|
||||
import android.bluetooth.BluetoothCodecConfig;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.development.BluetoothA2dpConfigStore;
|
||||
import com.android.settings.development.Flags;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Dialog preference controller to set the Bluetooth A2DP config of codec
|
||||
*/
|
||||
public class BluetoothCodecDialogPreferenceController extends
|
||||
AbstractBluetoothDialogPreferenceController {
|
||||
|
||||
private static final String KEY = "bluetooth_audio_codec_settings";
|
||||
private static final String TAG = "BtCodecCtr";
|
||||
|
||||
@Nullable private final Callback mCallback;
|
||||
|
||||
public BluetoothCodecDialogPreferenceController(Context context, Lifecycle lifecycle,
|
||||
BluetoothA2dpConfigStore store,
|
||||
@Nullable Callback callback) {
|
||||
super(context, lifecycle, store);
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return !Flags.a2dpOffloadCodecExtensibilitySettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
((BaseBluetoothDialogPreference) mPreference).setCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getSelectableIndex() {
|
||||
List<Integer> index = new ArrayList<>();
|
||||
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
|
||||
|
||||
index.add(getDefaultIndex());
|
||||
if (bluetoothA2dp == null) {
|
||||
return index;
|
||||
}
|
||||
final BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||
if (activeDevice == null) {
|
||||
Log.d(TAG, "Unable to get selectable index. No Active Bluetooth device");
|
||||
return index;
|
||||
}
|
||||
// Check HD audio is enabled, display the available list.
|
||||
if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
|
||||
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
|
||||
List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice);
|
||||
if (configs != null) {
|
||||
return getIndexFromConfig(configs);
|
||||
}
|
||||
}
|
||||
// If HD audio is disabled, SBC is the only one available codec.
|
||||
index.add(convertCfgToBtnIndex(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC));
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeConfigurationValues(final int index) {
|
||||
int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; // default
|
||||
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
|
||||
switch (index) {
|
||||
case 0:
|
||||
final BluetoothDevice activeDevice = getA2dpActiveDevice();
|
||||
codecTypeValue = getHighestCodec(mBluetoothA2dp, activeDevice,
|
||||
getSelectableConfigs(activeDevice));
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 1:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 2:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 3:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 4:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 5:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 6:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 7:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mBluetoothA2dpConfigStore.setCodecType(codecTypeValue);
|
||||
mBluetoothA2dpConfigStore.setCodecPriority(codecPriorityValue);
|
||||
|
||||
// Once user changes codec, to reset configs with highest quality.
|
||||
final BluetoothCodecConfig config = getSelectableByCodecType(codecTypeValue);
|
||||
if (config == null) {
|
||||
Log.d(TAG, "Selectable config is null. Unable to reset");
|
||||
}
|
||||
mBluetoothA2dpConfigStore.setSampleRate(getHighestSampleRate(config));
|
||||
mBluetoothA2dpConfigStore.setBitsPerSample(getHighestBitsPerSample(config));
|
||||
mBluetoothA2dpConfigStore.setChannelMode(getHighestChannelMode(config));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCurrentIndexByConfig(BluetoothCodecConfig config) {
|
||||
if (config == null) {
|
||||
Log.e(TAG, "Unable to get current config index. Config is null.");
|
||||
}
|
||||
return convertCfgToBtnIndex(config.getCodecType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIndexUpdated(int index) {
|
||||
super.onIndexUpdated(index);
|
||||
mCallback.onBluetoothCodecChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHDAudioEnabled(boolean enabled) {
|
||||
writeConfigurationValues(/* index= */ 0);
|
||||
}
|
||||
|
||||
private List<Integer> getIndexFromConfig(List<BluetoothCodecConfig> configs) {
|
||||
List<Integer> indexArray = new ArrayList<>();
|
||||
for (BluetoothCodecConfig config : configs) {
|
||||
indexArray.add(convertCfgToBtnIndex(config.getCodecType()));
|
||||
}
|
||||
return indexArray;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int convertCfgToBtnIndex(int config) {
|
||||
int index = getDefaultIndex();
|
||||
switch (config) {
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC:
|
||||
index = 1;
|
||||
break;
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC:
|
||||
index = 2;
|
||||
break;
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX:
|
||||
index = 3;
|
||||
break;
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD:
|
||||
index = 4;
|
||||
break;
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
|
||||
index = 5;
|
||||
break;
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS:
|
||||
index = 7;
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unsupported config:" + config);
|
||||
break;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.development.BluetoothA2dpConfigStore;
|
||||
import com.android.settings.development.Flags;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -62,9 +61,7 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
boolean available = Flags.a2dpOffloadCodecExtensibilitySettings();
|
||||
Log.d(TAG, "isAvailable: " + available);
|
||||
return available;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,10 +77,6 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) {
|
||||
if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mListPreference == null) {
|
||||
Log.e(TAG, "onPreferenceChange: List preference is null");
|
||||
return false;
|
||||
@@ -115,7 +108,7 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre
|
||||
}
|
||||
|
||||
BluetoothCodecConfig codecConfig =
|
||||
mBluetoothA2dpConfigStore.createCodecConfigFromCodecType();
|
||||
mBluetoothA2dpConfigStore.createCodecConfig();
|
||||
Log.d(TAG, "onPreferenceChange: setCodecConfigPreference: " + codecConfig.toString());
|
||||
bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig);
|
||||
if (mCallback != null) {
|
||||
@@ -128,9 +121,6 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre
|
||||
@Override
|
||||
public void updateState(@Nullable Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isHDAudioEnabled()) {
|
||||
Log.d(TAG, "updateState: HD Audio is disabled");
|
||||
|
||||
Reference in New Issue
Block a user