diff options
author | Ted Wang <tedwang@google.com> | 2019-03-19 21:31:25 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-19 21:31:25 -0700 |
commit | 0078588f39ecd10e830ad2711edcef3785ddc121 (patch) | |
tree | e5037c146e2adac70e63634579b224ad10436cc2 | |
parent | a1f2af819daa3d119cca41fba952ad1e0bf9fcca (diff) | |
parent | fde8c56fe57f75c770fc258ca450648644586cf4 (diff) | |
download | sl4a-0078588f39ecd10e830ad2711edcef3785ddc121.tar.gz |
Fix not able to set bluetooth codec config with valid Codec Specific 1 am: e70e01578b
am: fde8c56fe5
Change-Id: Id5524ae3af6d1325efe89ea20afa140901d83d6b
-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 : |