yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] klaberte:
It is true that gathering details on our BT traffic is not painless. But I've always been able to create and find a btsnoop_hci.log on all my devices. LMK if you want to work through this on your devices. Another option is to consult https://btcodecs.valdikss.org.ru/codec-compatibility/ to see what BT connection "is likely", given your hardware.

Valdikss has shown that bitrates of 256-320 kbit/sec is very common for Android codecs (see https://habr.com/en/post/456182/). LDAC in Android allows the user to choose 330, 660, or 990 kbit/sec. However, blackhawk's interest in Samsung Scalable remains a closed box. All I have found is what Samsung says, which is that it can go between 88-512 kbit/sec, and claims to change bitrates based on real-time conditions.
[Android Software/Hacking General [Developers Only]] dandreye:
Yes please: I'd be really happy if that file (generated by means of turning on BT HCI Log in Developer Options I suppose) could also be found on mine, which is a rooted SM-A320FL running and old stock UK EE ROM as it won't autoupdate anymore since I rooted it.

Btw speaking about LDAC: whenever I try setting its bitrate to 990Kbps I always instantly get severe audio clipping. My only LDAC capable sink is a cheapo Rod Rain Audio CSR8675PRO though, and it's unclear which side the issue is at. Either way 990Kbps is not an option and although 660Kbps works fine it doesn't sound any better than SBC-HD in my opinion: in fact I think I'm getting better bass with the latter, which I don't mind at all.
[Android Software/Hacking General [Developers Only]] klaberte:
I'm happy to troubleshoot with you, but perhaps we should take that outside of the thread. then if we unlock anything worth sharing, we can always put such a summary on the thread. I'll send you a DM via xda.

I also have difficulty with LDAC 990. I use an ES100, which I wouldn't call cheap, but not cutting edge anymore. It is unclear whether LDAC 990 issues are with a lot of congestion and dropping/delaying packets, or if the processor in the receiver just doesn't have the power to process fast enough.

But above 500-600 kbits/sec, I think most any A2DP codec should sound fairly transparent. If not, I think I'd recommend wired headphones :cool: .
[Android Software/Hacking General [Developers Only]] dandreye:
Sure: I implied the same actually.
[Android Software/Hacking General [Developers Only]] ParkourPaul:
@ValdikSS Did you get a dev device for this purpose yet? If you're still having issues with postage, I'd be happy to arrange if the community would chip in for the cost of the device and postage.

Perhaps it would be better if a more trusted member of xda set this up but I'm happy to oblige if others are happy to donate? Would love to see this feature on new builds or a functioning magisk module for 9+ ROMS.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Bluetooth stack from 9.0 looks different from 8.0. Will see closer tomorrow.
[Android Software/Hacking General [Developers Only]] AxelCocaine:
Hi, I want to test this out!

I'm running a pair of Marshall Major II on a Huawei P9 lite with Resurrection Remix Nougat 7.1.2

Unfortunately the P9 file doesn't work for me, here's the file I have on my phone, hopefully you will be able to unlock the whole potential of my Marshall's.
[Android Software/Hacking General [Developers Only]] bmg1001:
I've got the files here from the Essential Phone running 9.0 Pie as well. I've got some SoundPEATS Wireless Headset and an older headset from Insignia (Best Buy's in-house brand) to test. I think the Sony MDRXB950BT is already on the list, but never hurts to double test. :good:

https://drive.google.com/file/d/1hxu-GuFW_nva5c3fV5OTddYcJgCsfYbG/view?usp=sharing
[Android Software/Hacking General [Developers Only]] PhantomGamers:
I'm running an LG V20 and have a Brightplay Car HD Receiver I can test out. Oddly the stock LG ROM (Android 7.0) doesn't have a bluetooth.default.so but it does have an audio.a2dp.default.so which I assume is the same thing? I've attached all of the audio binaries just in case, but that's the one that I figure has the limits.

EDIT: I seem to have had a brain malfunction and somehow put the 64bit binaries in both folders, I've reuploaded a corrected zip file.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Done, please check the second post.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Are you sure you checked /system/lib/hw/ folder?
[Android Software/Hacking General [Developers Only]] ValdikSS:
Please get patched Pixel 2 XL libraries from the second post.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Please see the second post.
[Android Software/Hacking General [Developers Only]] lambroslnk:
Hey there great guide and information.

I am on Redmi 3S (LineageOS 15.1 with 9.5.8.0 MALMIFD firmware and Magisk). I run the bluetooth HCI log, and I attached for you both the lib and lib64 default bluetooth files and my HCI snoop log, connected with Creative Muvo 2c Bluetooth Speaker.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Done, check the second post.
[Android Software/Hacking General [Developers Only]] lambroslnk:
Thanks a lot, unfortunately the 486 and the 576 files produce heavy crackling.

I have attached the new logs for 486 and 576. I did not test the unrestricted since I assumed it would be the same,

Do you think a lower value could work or does it have something to do with the Creative Muvo 2c? I do not have any other bluetooth device to test sadly.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Try this one, with 352 kbit/s limit.
[Android Software/Hacking General [Developers Only]] seanhassars:
Here's the regular Pixel 2 pie files.
[Android Software/Hacking General [Developers Only]] shadowstep:
[MENTION=685332]ValdikSS[/MENTION] Please find attached the requested libraries from OnePlus 5's OxygenOS 5.1.5. Thank you! :)
[Android Software/Hacking General [Developers Only]] lambroslnk:
Still crackling. :/ Oh well at least we tried :)
[Android Software/Hacking General [Developers Only]] anirudhnyg:
Oneplus 6 lib files

Hi [MENTION=685332]ValdikSS[/MENTION]

Please find the OP6 stock lib files.
[Android Software/Hacking General [Developers Only]] ValdikSS:
That's strange, I assume the problem is in my patch. Could you please try a PC method?
[Android Software/Hacking General [Developers Only]] ValdikSS:
Thanks, both tests are correct, both headphones support SBC 617 kbit/s.
[Android Software/Hacking General [Developers Only]] PhantomGamers:
Yep, there's no bluetooth.default.so anywhere in my system folder.

Here's all of the files in my /system/lib/hw folder:

Directory of C:\Users\Phantom\Desktop\system\lib\hw

06/17/2018 05:30 PM <DIR> .
06/17/2018 05:30 PM <DIR> ..
06/07/2018 08:21 PM 34,464 audio.a2dp.default.so
06/07/2018 08:21 PM 18,072 audio.primary.default.so
06/07/2018 08:21 PM 352,528 audio.primary.msm8996.so
06/07/2018 08:21 PM 34,456 audio.r_submix.default.so
06/07/2018 08:21 PM 22,168 audio.usb.default.so
06/07/2018 08:21 PM 96,016 audio_policy.default.so
06/07/2018 08:21 PM 1,813,888 bplus.default.so
06/07/2018 08:21 PM 1,132,960 camera.msm8996.so
06/07/2018 08:21 PM 14,012 consumerir.msm8996.so
06/07/2018 08:21 PM 30,360 copybit.msm8996.so
06/07/2018 08:21 PM 26,268 fingerprint.msm8996.so
06/07/2018 08:21 PM 34,464 gps.default.so
06/07/2018 08:21 PM 22,488 gralloc.default.so
06/07/2018 08:21 PM 30,676 gralloc.msm8996.so
06/07/2018 08:21 PM 112,336 hwcomposer.msm8996.so
06/07/2018 08:21 PM 13,896 keystore.default.so
06/07/2018 08:21 PM 18,072 lgkm.default.so
06/07/2018 08:21 PM 13,976 lgkm.msm8996.so
06/07/2018 08:21 PM 13,976 lights.msm8996.so
06/07/2018 08:21 PM 13,976 local_time.default.so
06/07/2018 08:21 PM 14,000 memtrack.msm8996.so
06/07/2018 08:21 PM 197,456 nfc_lg.default.so
06/07/2018 08:21 PM 14,000 power.default.so
06/07/2018 08:21 PM 39,044 power.msm8996.so
06/07/2018 08:21 PM 725,760 sensors.msm8996.so
06/07/2018 08:21 PM 18,096 thermal.elsa.so
06/07/2018 08:21 PM 13,976 vibrator.default.so

The only other file I see that could be related is system/vendor/lib/mmi_bluetooth.so
[Android Software/Hacking General [Developers Only]] klaberte:
I just recently got a phone working in Dual Channel Mode, a Pixel (1st Gen) running LineageOS v16.0. When I run it with a speaker that only supports SBC, I was able to get Dual Channel SBC without problems. However, when paired with a more capable device, an EarStudio100, I cannot seem to select SBC in the developer options. Or more precisely, I can choose SBC and Dual channel in the Dev Options, but when I capture some audio playing, the btsnoop_hci.log makes it clear that it sent only LDAC packets.

I know in the past, when someone asked how they could change the priority, or remove options from consideration, valdikss himself wrote (post 253):

Option 1: remove aptX libraries.

Option 2: Edit codec priority in res/values/config.xml inside frameworks-res.apk.

Unfortunately, I don't know how to do either of those things. Can someone give me a bit more detail on how to do these options, or any other good option?
[Android Software/Hacking General [Developers Only]] dandreye:
Not sure if it helps but with (rooted) Samsung stock ROM - can't remember 7 on SM-A310F or 8 on SM-A320FL or both - I did #1 just by means of renaming (to anything else - doesn't matter) or deleting all the files with aptx in their names that I found under /system/lib , /system/lib64/ , /system/vendor/lib , /system/vendor/lib64 , obviously after backing them all up just in case. Perhaps LOS16 keeps its AptX/LDAC/etc libraries elsewhere but the idea is the same and so it's just the matter of finding them. In fact even "breaking" in such way a single library for a particular codec should be enough to mask its support upon device boot up (unless of course it notices that and restores it automatically right away). I didn't experiment with it that much though: I had like 2-3 libs for AptX, so renaming them all did the trick. The root is implied of course, but afaik with LOS it's there anyway since inception.
[Android Software/Hacking General [Developers Only]] zyhk:
I recommend you to install a GSI (crDrom11 or Bless v12.12), instead of using Lineage v16.0 which has a bug for SBC HD. crDrom11 is capable of using SBC HD without problem but has a bug of a codec selection till now. See also DRC remover.
[Android Software/Hacking General [Developers Only]] klaberte:
I have a Pixel 1, and cannot find any instructions on how to install. The download pages show a variety of builds, but I would have expected something specifically for my hardware (sailfish). Any help or pointers would be great!

@zyhk I tried to send this via private message, but it was blocked. Please send me a PM if you could.
[Android Software/Hacking General [Developers Only]] zyhk:
So, do you like PixelExperience (A11)? This ROM has the SBC HD codec too.

P.S. I don't know how to send a PM from XDA. New XDA UI is hard to use and understand for me.
[Android Software/Hacking General [Developers Only]] klaberte:
It was just pointed out to me that SBC-HD appears to be broken in Lineage 18.1, and will likely get removed unless someone can help debug it:

https://review.lineageos.org/q/topic:"revert-eleven-bt-sbc-hd-dualchannel"

and see the comments here https://review.lineageos.org/c/LineageOS/android_packages_apps_Settings/+/310235
[Android Software/Hacking General [Developers Only]] klaberte:
double post, deleted
[Android Software/Hacking General [Developers Only]] zyhk:
SBC-HD is not broken. There is a bug that all supported HD codecs are greyed out in dev settings. However, once you switch "dev settings switch" on and off immediately at the top of dev settings and set bluetooth "HD option" on in dev settings while connecting bluetooth earphones, you can see all supported HD codecs are not greyed out any more.
[Android Software/Hacking General [Developers Only]] klaberte:
Weird. There seems to be no support for PixelExperience on my Pixel! (Pixel5=redfin)

:-)
[Android Software/Hacking General [Developers Only]] zyhk:
See PixelExperience's Gerrit (bluetooth merged). I don't know more than this (I don't have any Pixel5).

Edit: if you enabled "Bluetooth A2DP hardware offload", disable it. SBC HD is effective only for AOSP bluetooth stack, but Qualcomm's stack.

Edit2: I installed the latest PixelExperience GSI on my device, and reconfirmed that PE had the SBC HD (dual channel) feature, could connect to bluetooth earphones with the SBC HD codec really, and also had the bug described in #390.
[Android Software/Hacking General [Developers Only]] zyhk:
MOD EDIT: QUOTE REMOVED

I cannot understand what you mean. Any problem?
[Android Software/Hacking General [Developers Only]] klaberte:
Good news! The team has done more debugging, and SBC-HD has been re-merged:

https://review.lineageos.org/c/LineageOS/android_packages_apps_Bluetooth/+/310548
[Android Software/Hacking General [Developers Only]] LoyK:
I use a built that has been built with this change merged and I don´t think it is working already.

I can use it with LOS16.0 but no chance with 18.1 so far. Very sad as SBC-HD is sounding really good on my headphones.

Anyone got it to work?
[Android Software/Hacking General [Developers Only]] zyhk:
SBC HD has been working since March on the AOSP bluetooth stack. Check if "bluetooth A2DP hardware offload" is off in dev settings. If you select "SBC" and "dual channel" in dev settings, you could use SBC HD. (There are some earphones which cannot use dual channel mode. e.g. 1More's)
[Android Software/Hacking General [Developers Only]] LoyK:
With Lineage OS18.1 the dev settings are not working correctly:

bluetooth A2DP hardware offload is active (slider == OFF/left) and I can´t deactivate it because the slider stays the same after reboot

My device (Sony WF-1000XM3) is working with Lineage OS16.0 and SBC-HD without problems

Unfortunately new nightly build today did not fix the problem

Any idea how to get SBC-HD to work? (LOS18.1 on Sony Xperia XZ2 (Akari))
[Android Software/Hacking General [Developers Only]] klaberte:
The Lineage OS Devs are aware and are working on a solution, as you can see here:

https://review.lineageos.org/q/sbc

Lots of us are anxiously waiting.
[Android Software/Hacking General [Developers Only]] zyhk:
I'm not sure, but "setprop persist.bluetooth.bluetooth_audio_hal.disabled true" and reboot. It may help you. If this cannot help, try lineageos GSI install over your ROM (having treble capability) and set "Force-disable A2DP offload" in PHH Treble Settings.
[Android Software/Hacking General [Developers Only]] kiraryu:
You also can try "setprop persist.bluetooth.a2dp_offload.disabled true",it will load audio_policy_configuration_a2dp_offload_disabled.xml
[Android Software/Hacking General [Developers Only]] reas0n:
Does anybody have a permanent solution of keeping SBC HD turned on so I wouldn't manually switch it every time I connect? I'm on crDroid right now..
[Android Software/Hacking General [Developers Only]] zyhk:
On Android 10 ROM's like Bless 12.12, you can keep SBC HD as the default codec by using "preferred codec" and "SBC HD audio" switches in dev. settings.
[Android Software/Hacking General [Developers Only]] reas0n:
I only have 11 ROMs tho :(

Btw, did anybody experience mic issues on SBC HD or it shouldn't be a case? Just asking to be sure

Edit: Would it be possible to change AAC bitrate? It's possible to do it on MacOS with app @ValdikSS
[Android Software/Hacking General [Developers Only]] zyhk:
deleted
[Android Software/Hacking General [Developers Only]] cloneman1:
Is this working again yet? My stuff is greyed out in the developer settings.
[Android Software/Hacking General [Developers Only]] L.Lmar:
As for LineageOS 18.1 dual channel mode for SBC is not persistent and resets to stereo on disconnect. Any ideas how to automate its switching? Maybe Tasker or Magisk module or shortcut for Audio channel mode?
[Android Software/Hacking General [Developers Only]] zyhk:
I've made a root script USB SampleRate Changer (which can be used for bluetooth a2dp as well as USB DAC's) to avoid DRC (in short, compression), resampling distortions for Pixel's, Xperia's, Oneplus's, etc. "jitter-reducer.sh" in its extras folder can enhance your bluetooth experience by reducing jitter distortions related to bluetooth.

For Pixel's, etc. users, try to execute "sh ./USB_SampleRate_Changer.sh --bypass-offload" and "sh ./extras/jitter-reducer.sh --all --effect --status".

You can bypass a2dp hardware offload (48kHz resampling) and DRC now. I think you could feel SBC HD's excellence by using "jitter-reducer.sh".

Enjoy it!

Edit: Updated to use "deadline" I/O scheduler and its optimized tunable values. Probably "sh ./extras/jitter-reducer.sh --all --effect --io deadline light --status" is the optimal setting command for bluetooth a2dp. See README.md in details.

Please disable "Adaptive battery" of adaptive preferences in the battery section and battery optimizations for related apps (music player, android system, lineageOS system, bluetooth, etc. See README.md in details) to lower reverb like distortion.
[Android Software/Hacking General [Developers Only]] Disty0:
SBC dual channel finally works on LineageOS 18 with this script.

I got 600Kbps with Xiaomi Mi Note 10 Lite and Anker SoundCore Liberty 2 Pro.

Also can you make this a Magisk module so it stays persistent after reboot?

Added this script to /data/adb/service.d folder for now:

#!/system/bin/sh

while [ "$(getprop sys.boot_completed)" != 1 ];
do sleep 1;
done
sleep 10

cd /sdcard/scripts/USB_SampleRate_Changer/
sh ./USB_SampleRate_Changer.sh --bypass-offload
sleep 2

service call bluetooth_manager 8
sleep 2
service call bluetooth_manager 6
[Android Software/Hacking General [Developers Only]] zyhk:
I'm using sManager (a script manager app installed from google play store). By this app, you can do the same thing by setting "Run at boot".

By the way, "Disable Bluetooth A2DP hardware offload" in developer options is greyed-outed? Perhaps, you can enable "SBC HD" by the above switch. My script disables "a2dp & USB hardware offload" and "DRC" (compression), and sets 44.1kHz&32bit for USB DAC's, 3.5mm jack and an internal speaker.

If you like, try "extras/jitter-reducer.sh --all --effect --status". This makes the quality of AAC streaming services to be Hires. quality even through Bluetooth, I think.
[Android Software/Hacking General [Developers Only]] Disty0:
I can enable SBC dual channel without this script but i get no sound with dual channel.

I can can disable A2DP hardware offload but i get sound from the loudspeaker instead of the Bluetooth earphone or no sound at all with any codec.

Sound comes back to the earphone when i apply your script with both A2DP hardware offload enabled or disabled.

My current config is:

A2DP hardware offloading is disabled. Script runs at boot.
[Android Software/Hacking General [Developers Only]] zyhk:
I guess that your device doesn't have any configuration file for "non- A2DP hardware offload" while having "/vendor/lib{64}/hw/audio.bluetooth.default.so" (non- A2DP hardware offload bluetooth module itself) as same as Xperia XZ2, etc.

Any way, the switch you enabled is meaningless for my script. The switch changes only the configuration file name that "audioserver" loads at boot time or other times.
[Android Software/Hacking General [Developers Only]] wgt:
@zyhk I have a small issue with "jiter-reducer.sh" that I can't figure out:

After running it, my camera stops working. It just won't turn on.

I'm running it with "jiter-reducer.sh --all --effect --io deadline light --status".

When I run only the "USB_SampleRate_Changer.sh" everything works fine.

EDIT

I have found the solution: disable camera server optimizations with "++camera".
[Android Software/Hacking General [Developers Only]] klaberte:
Thank you @zyhk for all of your efforts here. I hope to try out some of your tools soon. It has been a while since I've had time to mess with my bluetooth settings!

By the way, I have a Pixel 5 running stock, but rooted with an older version of Magisk = 79ee85c0 (22001). Do I need to update Magisk before trying your solutions?
[Android Software/Hacking General [Developers Only]] zyhk:
Moreover, if you worry about "Selinux permissive" and no thermal control, add "++selinux" and "++thermal" options. Whenever you want to save battery consumption, execute the script with "++all" option.
[Android Software/Hacking General [Developers Only]] zyhk:
I'm not sure, but I think my root scripts don't have anything depending on Magisk versions. Even my root scripts can run on SuperSu by phh.
[Android Software/Hacking General [Developers Only]] klaberte:
Thanks! BTW, just to confirm, if I run your commands in an android shell, will they persist across a reboot? As you mentioned running them at boot, my intuition is they do not persist through boot, but wanted to confirm before I start experimenting with my daily driver.
[Android Software/Hacking General [Developers Only]] zyhk:
My root scripts don't persist across a reboot except disabling "WIFI suspend optimizations". Its setting is in a "settings" DB. But you can remove this "jitter-reducer.sh ++wifi". Whenever you need to restore the original state, please execute "USB_SampleRate_Changer.sh --reset" and "jitter-reducer.sh ++all ++effect --status".
[Android Software/Hacking General [Developers Only]] Eriol:
Dear all,

happy New Year!

I stumbled upon this topic only just recently. So, first of all, a BIG THANK YOU to @ValdikSS for your great work and life hack on SBC XQ!!!

I use Linux, so using SBC XQ works out of the box without any "magic": With my MPow H21 headphones and Ubuntu I have tried

pactl send-message /card/bluez_card.[...]/bluez switch-codec '"sbc_xq_552"'

and

pactl send-message /card/bluez_card.[...]/bluez switch-codec '"sbc_xq_512"'

and both settings works, with some very few minor cracks at 552 maybe. 512 works without any issues at all and brings a noticeable sound improvement.

I wish I could use this with my smartphone (Samsung A52s/stock ROM, not yet rooted ...) and my tablet Xiaomi Mi Pad 5 (stock ROM, not yet rooted).

Here is the output for the A52s:

Connection: [...] (Samsung A52s) → e0:9d:fa:4c:fe:a3 (Mpow H21)
Supported codecs: Audio SBC (16000 32000 44100 48000 | Mono DualChannel Stereo JointStereo | block: 4 8 12 16 | subbands: 4 8 | allocation: SNR Loudness | bitpool: 2..53)
Used for audio: Audio SBC (44100 | JointStereo | block: 16 | subbands: 8 | allocation: Loudness | bitpool: 2..53)

It's a pitty that dual channel cannot be set by changing developer settings (?). This would be just great! Has anyone tried to change bluetooth stack on Samsung devices?

Now, with LC3 in sight and coming, I fear that SBC XQ will not be implemented by companies, especially by Samsung, because they earn too much money with proprietary licensed codecs.

Best regards

Eriol
[Android Software/Hacking General [Developers Only]] zambeziriver:
how big of a difference does it actually make?

if it isnt a huge difference,then i'll pass
[Android Software/Hacking General [Developers Only]] klaberte:
You can listen for yourself: https://btcodecs.valdikss.org.ru/sbc-encoder/
[Android Software/Hacking General [Developers Only]] wgt:
@zyhk I have another strange issue while using your script: when I call someone, they cannot hear me. When someone calls me, we can talk just fine.

I guess it has to do with me using Skvalex Call Recorder. While using your script it doesn't record anything (regardless of who called who).

Any ideas on what I could try?
[Android Software/Hacking General [Developers Only]] zyhk:
Please make an issue on Git Hub (USB Samplerate Changer).

It's a logical consequence because you disabled noisy effects framework. Automatic gain control, echo canceller and some monitoring hooks are disabled by my script. Add "++effect" option.
[Android Software/Hacking General [Developers Only]] wgt:
That did not help. Actually even if I don'r run "jitter-reducer.sh" at all this still happens, so the problem must be with "USB_SampleRate_Changer.sh".