Merge "Bluetooth Codec Settings: Assure flag enabled" into main

This commit is contained in:
Fan Wu
2024-04-16 01:27:55 +00:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 1 deletions

View File

@@ -78,6 +78,10 @@ public class BluetoothCodecListPreferenceController
@Override @Override
public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) { public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) {
if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
return false;
}
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue); Log.d(TAG, "onPreferenceChange: newValue=" + (String) newValue);
} }
@@ -120,6 +124,10 @@ public class BluetoothCodecListPreferenceController
@Override @Override
public void updateState(@Nullable Preference preference) { public void updateState(@Nullable Preference preference) {
super.updateState(preference); super.updateState(preference);
if (!Flags.a2dpOffloadCodecExtensibilitySettings()) {
return;
}
final List<String> codecIds = new ArrayList<>(); final List<String> codecIds = new ArrayList<>();
final List<String> labels = new ArrayList<>(); final List<String> labels = new ArrayList<>();
String selectedCodecId = mDefaultValue; String selectedCodecId = mDefaultValue;

View File

@@ -35,12 +35,14 @@ import android.bluetooth.BluetoothCodecType;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProfile;
import android.content.Context; import android.content.Context;
import android.platform.test.annotations.RequiresFlagsEnabled;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.development.BluetoothA2dpConfigStore; import com.android.settings.development.BluetoothA2dpConfigStore;
import com.android.settings.development.Flags;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before; import org.junit.Before;
@@ -57,7 +59,6 @@ import java.util.List;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class BluetoothCodecListPreferenceControllerTest { public class BluetoothCodecListPreferenceControllerTest {
private static final String DEVICE_ADDRESS = "00:11:22:33:44:55"; private static final String DEVICE_ADDRESS = "00:11:22:33:44:55";
@Mock private BluetoothA2dp mBluetoothA2dp; @Mock private BluetoothA2dp mBluetoothA2dp;
@@ -245,6 +246,7 @@ public class BluetoothCodecListPreferenceControllerTest {
} }
@Test @Test
@RequiresFlagsEnabled(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS)
public void onPreferenceChange_notifyPreference() { public void onPreferenceChange_notifyPreference() {
assertFalse( assertFalse(
mController.onPreferenceChange( mController.onPreferenceChange(