Update the A2DP Codec Config API
Previously, the JNI upcall would contain only the current codec config. In the new API, the upcall contains: 1. The current codec config 2. The list of codecs containing the local codecs capabilities 3. The list of codecs containing the selectable codecs capabilities. This list is the intersection of the local codecs capabilities and the capabilities of the paired device. Also, refactored the Java internals to accomodate the extra information: * Added new class BluetoothCodecStatus that contains the extra info: current codec config, local codecs capabilities and selectable codecs capabilities * Renamed method getCodecConfig() to getCodecStatus() and return the corresponding BluetoothCodecStatus object. * Updates to class BluetoothCodecConfig: new methods isValid(), getCodecName(), and updated toString() so it is more user friendly * Removed BluetoothCodecConfig.EXTRA_CODEC_CONFIG and EXTRA_PREVIOUS_CODEC_CONFIG. The former is superseded by BluetoothCodecStatus.EXTRA_CODEC_STATUS; the latter is not really used. Test: A2DP streaming with headsets and switching the codecs Change-Id: I490a70c82b686be7105862aeaeafcff495369dae
This commit is contained in:
@@ -28,6 +28,7 @@ import android.app.backup.IBackupManager;
|
|||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothCodecConfig;
|
import android.bluetooth.BluetoothCodecConfig;
|
||||||
|
import android.bluetooth.BluetoothCodecStatus;
|
||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -1819,12 +1820,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private void updateBluetoothA2dpConfigurationValues() {
|
private void updateBluetoothA2dpConfigurationValues() {
|
||||||
int index;
|
int index;
|
||||||
String[] summaries;
|
String[] summaries;
|
||||||
|
BluetoothCodecStatus codecStatus = null;
|
||||||
BluetoothCodecConfig codecConfig = null;
|
BluetoothCodecConfig codecConfig = null;
|
||||||
|
BluetoothCodecConfig[] codecsLocalCapabilities = null;
|
||||||
|
BluetoothCodecConfig[] codecsSelectableCapabilities = null;
|
||||||
String streaming;
|
String streaming;
|
||||||
|
|
||||||
synchronized (mBluetoothA2dpLock) {
|
synchronized (mBluetoothA2dpLock) {
|
||||||
if (mBluetoothA2dp != null) {
|
if (mBluetoothA2dp != null) {
|
||||||
codecConfig = mBluetoothA2dp.getCodecConfig();
|
codecStatus = mBluetoothA2dp.getCodecStatus();
|
||||||
|
codecConfig = codecStatus.getCodecConfig();
|
||||||
|
codecsLocalCapabilities = codecStatus.getCodecsLocalCapabilities();
|
||||||
|
codecsSelectableCapabilities = codecStatus.getCodecsSelectableCapabilities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (codecConfig == null)
|
if (codecConfig == null)
|
||||||
@@ -2674,8 +2681,16 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private BroadcastReceiver mBluetoothA2dpReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mBluetoothA2dpReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.d(TAG, "mBluetoothA2dpReceiver.onReceive intent=" + intent);
|
||||||
|
String action = intent.getAction();
|
||||||
|
|
||||||
|
if (BluetoothA2dp.ACTION_CODEC_CONFIG_CHANGED.equals(action)) {
|
||||||
|
BluetoothCodecStatus codecStatus =
|
||||||
|
(BluetoothCodecStatus)intent.getParcelableExtra(BluetoothCodecStatus.EXTRA_CODEC_STATUS);
|
||||||
|
Log.d(TAG, "Received BluetoothCodecStatus=" + codecStatus);
|
||||||
updateBluetoothA2dpConfigurationValues();
|
updateBluetoothA2dpConfigurationValues();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private BluetoothProfile.ServiceListener mBluetoothA2dpServiceListener =
|
private BluetoothProfile.ServiceListener mBluetoothA2dpServiceListener =
|
||||||
|
Reference in New Issue
Block a user