diff options
author | Ted Wang <tedwang@google.com> | 2019-02-12 14:11:21 +0800 |
---|---|---|
committer | Ted Wang <tedwang@google.com> | 2019-03-19 02:49:51 +0000 |
commit | e70e01578b9fd6b4e76f9dc70e367cdd27608b4d (patch) | |
tree | e5037c146e2adac70e63634579b224ad10436cc2 | |
parent | 184e4a4bca5708f2a737db4e0902deb4ff74c34c (diff) | |
download | sl4a-e70e01578b9fd6b4e76f9dc70e367cdd27608b4d.tar.gz |
Fix not able to set bluetooth codec config with valid Codec Specific 1
Avoid codec specific 1 value check when comparing with codecs selectable capabilities,
since codec specific 1 is always 0 in codecs selectable capabilities.
Bug: 120083042
Test: SL4A
Change-Id: I31a5840af603335ca1428762e8ef365dc77ea909
-rw-r--r-- | Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothA2dpFacade.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothA2dpFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothA2dpFacade.java index e460c0b1..5e847b34 100644 --- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothA2dpFacade.java +++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothA2dpFacade.java @@ -233,8 +233,7 @@ public class BluetoothA2dpFacade extends RpcReceiver { return target.getCodecType() == capability.getCodecType() && (target.getSampleRate() & capability.getSampleRate()) != 0 && (target.getBitsPerSample() & capability.getBitsPerSample()) != 0 - && (target.getChannelMode() & capability.getChannelMode()) != 0 - && target.getCodecSpecific1() == capability.getCodecSpecific1(); + && (target.getChannelMode() & capability.getChannelMode()) != 0; } /** @@ -252,9 +251,10 @@ public class BluetoothA2dpFacade extends RpcReceiver { @RpcParameter(name = "sampleRate") Integer sampleRate, @RpcParameter(name = "bitsPerSample") Integer bitsPerSample, @RpcParameter(name = "channelMode") Integer channelMode, - @RpcParameter(name = "codecSpecific1") Long codecSpecific1) { - if (sA2dpProfile == null) { - return false; + @RpcParameter(name = "codecSpecific1") Long codecSpecific1) + throws Exception { + while (!sIsA2dpReady) { + continue; } BluetoothCodecConfig codecConfig = new BluetoothCodecConfig( codecType, @@ -264,10 +264,16 @@ public class BluetoothA2dpFacade extends RpcReceiver { channelMode, codecSpecific1, 0L, 0L, 0L); - BluetoothCodecStatus currentCodecStatus = sA2dpProfile.getCodecStatus( - sA2dpProfile.getActiveDevice()); - if (isSelectableCodec(codecConfig, currentCodecStatus.getCodecConfig())) { - Log.e("Same as current codec configuration " + currentCodecStatus.getCodecConfig()); + BluetoothDevice activeDevice = sA2dpProfile.getActiveDevice(); + if (activeDevice == null) { + Log.e("No active device"); + throw new Exception("No active device"); + } + BluetoothCodecStatus currentCodecStatus = sA2dpProfile.getCodecStatus(activeDevice); + BluetoothCodecConfig currentCodecConfig = currentCodecStatus.getCodecConfig(); + if (isSelectableCodec(codecConfig, currentCodecConfig) + && codecConfig.getCodecSpecific1() == currentCodecConfig.getCodecSpecific1()) { + Log.e("Same as current codec configuration " + currentCodecConfig); return false; } for (BluetoothCodecConfig selectable : |