Loading src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java +26 −5 Original line number Diff line number Diff line Loading @@ -83,7 +83,11 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { setCodecConfigPreference(null, codecConfig); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return false; } setCodecConfigPreference(activeDevice, codecConfig); } } // Because the setting is not persisted into permanent storage, we cannot call update state Loading @@ -102,13 +106,17 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @Override public void updateState(Preference preference) { if (getCodecConfig(null) == null || mPreference == null) { // Use current active device if (mBluetoothA2dp == null) { return; } BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null || getCodecConfig(activeDevice) == null || mPreference == null) { return; } BluetoothCodecConfig codecConfig; synchronized (mBluetoothA2dpConfigStore) { codecConfig = getCodecConfig(null); // Use current active device codecConfig = getCodecConfig(activeDevice); } final int index = getCurrentA2dpSettingIndex(codecConfig); Loading Loading @@ -178,13 +186,26 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @VisibleForTesting void setCodecConfigPreference(BluetoothDevice device, BluetoothCodecConfig config) { mBluetoothA2dp.setCodecConfigPreference(device, config); if (mBluetoothA2dp == null) { return; } BluetoothDevice bluetoothDevice = (device != null) ? device : mBluetoothA2dp.getActiveDevice(); if (bluetoothDevice == null) { return; } mBluetoothA2dp.setCodecConfigPreference(bluetoothDevice, config); } @VisibleForTesting BluetoothCodecConfig getCodecConfig(BluetoothDevice device) { if (mBluetoothA2dp != null) { BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(device); BluetoothDevice bluetoothDevice = (device != null) ? device : mBluetoothA2dp.getActiveDevice(); if (bluetoothDevice == null) { return null; } BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(bluetoothDevice); if (codecStatus != null) { return codecStatus.getCodecConfig(); } Loading src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java +11 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.settings.development; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothDevice; import android.content.Context; import com.android.settings.R; Loading Loading @@ -109,14 +110,22 @@ public class BluetoothAudioCodecPreferenceController extends case 6: synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { mBluetoothA2dp.enableOptionalCodecs(null); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return; } mBluetoothA2dp.enableOptionalCodecs(activeDevice); } } return; case 7: synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { mBluetoothA2dp.disableOptionalCodecs(null); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return; } mBluetoothA2dp.disableOptionalCodecs(activeDevice); } } return; Loading Loading
src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java +26 −5 Original line number Diff line number Diff line Loading @@ -83,7 +83,11 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig(); synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { setCodecConfigPreference(null, codecConfig); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return false; } setCodecConfigPreference(activeDevice, codecConfig); } } // Because the setting is not persisted into permanent storage, we cannot call update state Loading @@ -102,13 +106,17 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @Override public void updateState(Preference preference) { if (getCodecConfig(null) == null || mPreference == null) { // Use current active device if (mBluetoothA2dp == null) { return; } BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null || getCodecConfig(activeDevice) == null || mPreference == null) { return; } BluetoothCodecConfig codecConfig; synchronized (mBluetoothA2dpConfigStore) { codecConfig = getCodecConfig(null); // Use current active device codecConfig = getCodecConfig(activeDevice); } final int index = getCurrentA2dpSettingIndex(codecConfig); Loading Loading @@ -178,13 +186,26 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends @VisibleForTesting void setCodecConfigPreference(BluetoothDevice device, BluetoothCodecConfig config) { mBluetoothA2dp.setCodecConfigPreference(device, config); if (mBluetoothA2dp == null) { return; } BluetoothDevice bluetoothDevice = (device != null) ? device : mBluetoothA2dp.getActiveDevice(); if (bluetoothDevice == null) { return; } mBluetoothA2dp.setCodecConfigPreference(bluetoothDevice, config); } @VisibleForTesting BluetoothCodecConfig getCodecConfig(BluetoothDevice device) { if (mBluetoothA2dp != null) { BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(device); BluetoothDevice bluetoothDevice = (device != null) ? device : mBluetoothA2dp.getActiveDevice(); if (bluetoothDevice == null) { return null; } BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(bluetoothDevice); if (codecStatus != null) { return codecStatus.getCodecConfig(); } Loading
src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java +11 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.settings.development; import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothDevice; import android.content.Context; import com.android.settings.R; Loading Loading @@ -109,14 +110,22 @@ public class BluetoothAudioCodecPreferenceController extends case 6: synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { mBluetoothA2dp.enableOptionalCodecs(null); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return; } mBluetoothA2dp.enableOptionalCodecs(activeDevice); } } return; case 7: synchronized (mBluetoothA2dpConfigStore) { if (mBluetoothA2dp != null) { mBluetoothA2dp.disableOptionalCodecs(null); // Use current active device BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice(); if (activeDevice == null) { return; } mBluetoothA2dp.disableOptionalCodecs(activeDevice); } } return; Loading