yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] LieDanG:
I'm using LOS 16 right now and noticed that if the earphones support AAC then it uses that instead of SBC HD, it's that the intended behavior? I was under the idea that AAC wasn't recommended since it could use FDK AAC or the SoC encoder which could be worse
[Android Software/Hacking General [Developers Only]] ValdikSS:
That's an intended behavior. The patchset does not touch codec preference.
[Android Software/Hacking General [Developers Only]] abhifx:
done!

would love to see this in AOSP
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
How should I patch the ROM I'm using myself? I use Pixel Experience and it doesn't have these. My laptop is not enough to build a ROM, thanks.
[Android Software/Hacking General [Developers Only]] ValdikSS:
You'll need to apply the patch to the source code and build full firmware.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
I suppose an Xposed module is possible?
[Android Software/Hacking General [Developers Only]] ValdikSS:
It should be possible but nobody did a proper module. It might be harder than a usual Xposed module due to binary module modification requirement.
[Android Software/Hacking General [Developers Only]] d3vyarth:
Only 46 stars yet, need to spread this.
[Android Software/Hacking General [Developers Only]] gnanam8:
Aosp Extender for whyred

Aosp Extender for whyred ROM. please modify best audio quality in sbc

https://drive.google.com/file/d/1z2SZM7R31fE9kpWHkUz4vBTOl70FLu8Q/view?usp=drivesdk
[Android Software/Hacking General [Developers Only]] ValdikSS:
I don't know how can I make it even bolder for people to see this message.

The test is over. I'm no longer accepting libraries to patch.
[Android Software/Hacking General [Developers Only]] gnanam8:
I am not a developer. Please modified this file otherwise how modified .so files tell us tutorials

---------- Post added at 09:58 AM ---------- Previous post was at 09:53 AM ----------

I am not a developer please provide how to modified .so file tutorials then I modified those things.
[Android Software/Hacking General [Developers Only]] LieDanG:
It's there any way to check if it's using software or hardware encoder for AAC? Wasn't the point of the patch to use SBC at higher bitrates instead of AAC in this case?
[Android Software/Hacking General [Developers Only]] ValdikSS:
There could be some information in logcat, try to read it.
[Android Software/Hacking General [Developers Only]] rdsu:
SBC HD works great with Human Headphones...
[Android Software/Hacking General [Developers Only]] gnanam8:
Anyway thank you for your support.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
I have the Redmi Airdots (SBC HD) and Haylou GT1 (AAC, SBC HD). Which is objectively better on paper? Thanks.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
Here are the technical details
[Android Software/Hacking General [Developers Only]] LazerL0rd:
Great work, gonna be using these patches on my ROM.

Not sure why AOSP is ignoring this, however.
[Android Software/Hacking General [Developers Only]] ThaBlacMamba:
[MENTION=685332]ValdikSS[/MENTION] I know you arent doing any bluetooth default.so edits but my phone is unstable on lineage. I have a lg v30 so I use a stock rom. Could you edit the files to enable dual channel mode and sbc as default?

---------- Post added at 03:33 PM ---------- Previous post was at 03:33 PM ----------

[/COLOR [MENTION=685332]ValdikSS[/MENTION] I know you arent doing any bluetooth default.so edits but my phone is unstable on lineage. I have a lg v30 so I use a stock rom. Could you edit the files to enable dual channel mode and sbc as default?
[Android Software/Hacking General [Developers Only]] ValdikSS:
No I won't.
[Android Software/Hacking General [Developers Only]] UserXProfile:
appuals . com / how-to-modify-bluetooth-stacks-on-android-for-greatly-enhanced-bluetooth-audio-quality /

If I follow this instruction, will I create a working mod for my Redmi Note 7?
[Android Software/Hacking General [Developers Only]] ValdikSS:
This is exactly the same reposted instruction you can found in the first messages of this topic.
[Android Software/Hacking General [Developers Only]] layman806:
Thanks for including this in Lineage OS, OP

Came across this:

https://lineageos.org/engineering/Bluetooth-SBC-XQ/

Thanks a lot, [MENTION=685332]ValdikSS[/MENTION] :D

I mean flipping just a switch in bluetooth settings to transform the sound to HD in SBC? Wow!

I think you need to put this info on top of the first post for kiddos asking you to patch their ROM:

"Lineage OS 15.1 and above builds from 31 March 2019 all have this patched in. Enable HD Audio: SBC for individual Bluetooth device in settings."

:fingers-crossed:
[Android Software/Hacking General [Developers Only]] boonthongw@gmail.com:
Is it possible to implement this to Samsung Galaxy note 10 exynos?
[Android Software/Hacking General [Developers Only]] ValdikSS:
Check if your smartphone has LineageOS available.
[Android Software/Hacking General [Developers Only]] ValdikSS:
Done.
[Android Software/Hacking General [Developers Only]] abhifx:
is there a patch for Lineage 17? Now that android 10 custom roms are popping up, this might be of great help.
[Android Software/Hacking General [Developers Only]] ValdikSS:
No, not yet. It's been ported by other Lineage developers and waiting for my approval. I'll test it this weekend.
[Android Software/Hacking General [Developers Only]] abhifx:
I have seen the open patches, finger crossed if this gets integrated soon.
[Android Software/Hacking General [Developers Only]] d3vyarth:
So I've bought a new neckband Bluetooth headphone "Wings Glide. It is a well designed product at a very pocket friendly price(best at it's price). I was hoping that it would support HD Audio - SBC, as It does to my Blaupunkt BT51 speaker, but unfortunately it doesn't. Maybe due to BT 4.2?

Can anything be done for it to support? It uses fairly simple Bluetooth module, nothing fancy such as custom welcome/goodbye sound, just beep.

Here is a link if anyone wanna checkout

https://www.amazon.in/Wings-Neckban...and&qid=1570477738&sprefix=Wings+glide&sr=8-1

Please at least can you check if it can? It is such a nice product.
[Android Software/Hacking General [Developers Only]] d3vyarth:
No nothing? [MENTION=685332]ValdikSS[/MENTION]?
[Android Software/Hacking General [Developers Only]] cacio_confusa:
thank you for your work. but just a single wish: it should be possible to select SBC HD even if other codecs are supported by the receiver. specifically talking about those realtek 5.0 TWS headphones which do have SBC & AAC, but SBC HD option is not avalible in LOS 16 if AAC is supported. but SBC HD > AAC. thx
[Android Software/Hacking General [Developers Only]] ValdikSS:
The patchset needs rework. I've tested it some weeks ago and it does not work as intended. I'll take a look into it in my free time.
[Android Software/Hacking General [Developers Only]] ValdikSS:
There is a patch for that on Russian forum 4pda.ru, but the author of the patch doesn't seem to want to integrate it into mainline LineageOS for some reason.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
You can install an overlay that will override SBC over AAC.

I have a QCY T2C and I have this so that SBC will be used.
[Android Software/Hacking General [Developers Only]] cacio_confusa:
how should be this installed ? system/app? And will this allow SBC HD or just "normal" SBC?

EDIT: yeah installed as system APP and it works :svetius:
[Android Software/Hacking General [Developers Only]] gorman42:
[MENTION=685332]ValdikSS[/MENTION] would you consider implementing this through a Magisk mod? Or would it be impossible to achieve?

Thanks for this awesome development.

Edit: after using the search function, apparently there should already be a Magisk module with similar functionality.
[Android Software/Hacking General [Developers Only]] klaberte:
Dual Channel

I've read thru your post on habr and think I understand your thinking. However, by adding dual channel (instead of using joint stereo) to SBC, does the extra bandwidth really only help if there are large differences between L and R channels?

Sure, if you had two completely different tracks on L and R (no correlation between the two), I can see how having the extra bits to represent each channel separately would be helpful. On the other hand, if you had a single instrument/voice on a recording, it seems that dual channel will use more bits, but the channels will have only small variation between them. I guess this is more of a communication theory argument: the value of the extra bits are only as valuable if the original signal has enough entropy to require the extra bits.

In the extreme, if you have identical R and L channels, would the extra bandwidth of forced dual channel make any difference?
[Android Software/Hacking General [Developers Only]] ValdikSS:
Yes, high bitrate Dual Channel produces much higher quality audio than Joint Stereo with less bitrate, in all tests I've performed. This is mostly due to max bitpool limitation on the devices. If there's no max bitpool limits, Joint Stereo with the same bitrate would be more effective.

Typical maximum bitpool value is 53, which gives 328 kbps bitrate for Joint Stereo and 617 kbps for Dual Channel.

Optimal bitrate for Dual Channel is 551 kbps, which is used in the modification, which is 68% more of maximum Joint Stereo bitrate.

Try it yourself on https://btcodecs.valdikss.org.ru/sbc-encoder/, with low bitrate, but with 68% coefficient.

Set Profile 1 to SBC Joint Stereo, 20 bitpool (146 kbps), and Profile 2 to Dual Channel, 19 bitpool (243 kbps, 67% more). It's clear that Dual Channel sounds much better.

This is also true for mono recordings for some reason, although the difference is from small but noticeable to negligible. Try it on Suzanne Vega. I haven't dig in dipper on the reasons, but I guess that Joint Stereo in SBC is not very effective. Just to note, I've also tested everything on Android SBC encoder and on Blackberry encoder, and got more or less the same results.
[Android Software/Hacking General [Developers Only]] klaberte:
This is a good example. Can you say more about, " I guess that Joint Stereo in SBC is not very effective"?
[Android Software/Hacking General [Developers Only]] klaberte:
Which Magisk mod?

ValdikSS, is this even possible?
[Android Software/Hacking General [Developers Only]] ValdikSS:
This is possible but require too much effort to implement properly. The mod available in magisk repository is not made by me, very simple and is not compatible with many devices.
[Android Software/Hacking General [Developers Only]] klaberte:
I so very appreciate your great support for this. I have a few more questions, and there are far too few people to ask about BT audio CODECs. Apologies in advance if I drift off-topic.

I am particularly interested in the connection to automobile head units. As people tend to hold their cars longer than their other personal electronics, you are usually using outdated tech in your car head unit when connecting BT audio. In your testing, how often do you see other noise sources in the BT band that cause audible distortion? Which codecs have the ability to dynamically renegotiate bitrates due to noisy conditions? Do they ever re-negotiate to a higher rate if the noise source is removed? Forcing a higher bit rate for SBC (which has to be implemented in head end units is a particularly great application for me, but I worry about the noise levels. The good news is that distances are short, and even stable if you use a phone holder.
[Android Software/Hacking General [Developers Only]] ValdikSS:
I haven't tested car head units much, but in several cars I've tested it seems that, contrary to all-digital processing in software, Bluetooth audio in cars is handled with a dedicated chip, which is connected via analog input to the amplifier. Bluetooth audio had different sound and volume in cars I've tested, but I can't say it had audible noise or distortion.

This applies to Mazdas and Hyundais.

Probably only LDAC in case of Android. SBC is technically capable of dynamic bitrates, but not on Android.

LDAC — yes.

SBC XQ don't need to be implemented in car unit (receiver), only on a phone (transmitter), as long as the receiver is fully compliant with the specification and correctly playbacks SBC in Dual Channel mode.
[Android Software/Hacking General [Developers Only]] klaberte:
App with BT details?

I am using a custom ROM that for some reason does not provide the HCI snoop log (I enable in developer options, but the log file still is not created).

It would be great if there was some app that could report the data in this log in real time, i.e. current bitpool, CODEC, bandwidth, Joint Stereo vs Dual Channel.

Anyone know of any?
[Android Software/Hacking General [Developers Only]] dandreye:
Hi All,

Is it possible that function bta_av_build_src_cfg in bluetooth.default.so responsible in particular for the mode selection never gets control? If so how do I figure out which alternative function responsible for the same (or perhaps the whole library) is used instead of it? The ROM in question (based on AOSP 5.0.1) is known as "almost stock ROM" and there don't seem to be vendor specific libraries among the needed ones in its bluetooth.default.so, so I'm really struggling to understand how that function can be avoided:

LOAD:00000000 ; File Name : C:\bluetooth.default.so

LOAD:00000000 ; Format : ELF for ARM (Shared object)

LOAD:00000000 ; Interpreter '/system/bin/linker'

LOAD:00000000 ; Needed Library 'libc.so'

LOAD:00000000 ; Needed Library 'libcutils.so'

LOAD:00000000 ; Needed Library 'libdl.so'

LOAD:00000000 ; Needed Library 'liblog.so'

LOAD:00000000 ; Needed Library 'libm.so'

LOAD:00000000 ; Needed Library 'libpower.so'

LOAD:00000000 ; Needed Library 'libstdc++.so'

LOAD:00000000 ; Shared Name 'bluetooth.default.so'

Many thanks in advance!
[Android Software/Hacking General [Developers Only]] TrantaLocked:
What do I do with Galaxy S7 SM-G930T Nougat 7.0 to modify bluetooth stack? Can't install magisk or root.
[Android Software/Hacking General [Developers Only]] d3vyarth:
Try a similar magisk module available in it's repo. Otherwise you've to flash a custom ROM with this tweak attached, such as lineage.
[Android Software/Hacking General [Developers Only]] TrantaLocked:
I can't do any of that because the bootloader is locked down for any custom roms, and afaik has been for the past 4 years since the USA snapdragon models were released. I can actually root, but I don't want the associated bugs that are known for ENG boot rooting.

https://xdaforums.com/verizon-s7-edge/how-to/root-s7-s7edge-oreo-nougat-t3819616

I've seen a guide showing how to get temporary TWRP and install Magisk through that, but that was on an S7 with Oreo and there were plenty of users saying it didn't work for them. so I don't even want to try unless it's guaranteed, otherwise it's a waste of formatting my device which I have setup with modifications and other apps that I'd need to re-do.

https://xdaforums.com/s7-edge/how-to/guide-how-to-root-android-8-0-oreo-t3840271

edit:

I actually was able to get the temp TWRP running from the second link but I ran into the not able to access /data issue for which I apparently I need to use the wipe function in TWRP to fix. I don't know exactly the process I need to do here. Do I do regular wipe, do anything in advanced settings, what do I need to flash after the wipe and/or format and will I still be able to access TWRP? Will I get the "formatted with custom software" message again like last time that forced me to re-flash my stock Android AP file through odin? Because no one guide exactly dictates what I do for my specific situation given the problems I'm having, and then the author comes in and posts random comments with bits and pieces of more information when the original guide should've been more thorough in the first place. I know this isn't a charity but I'd feel more personally invested in being thorough when I know my guide is going to be used in situations that can brick phones held by less technically talented users.
[Android Software/Hacking General [Developers Only]] gorman42:
Hi! When you say "not compatible with many devices", do you mean smartphones or bluetooth peripherals?
[Android Software/Hacking General [Developers Only]] klaberte:
He means phones. All a2dp sinks should be able to decode any valid sbc stream, even if it is higher bitrate. This is the beauty of this finding: If you are running a proper implementation of it, you should get much better audio even from older, legacy equipment
[Android Software/Hacking General [Developers Only]] klaberte:
Actually, a more precise answer is that the magisk module won't work with most ROMs. If you can find a recent Lineage ROM for your phone, it should work, as the Lineage team has adopted the OP's patches.
[Android Software/Hacking General [Developers Only]] TrantaLocked:
I was trying to get Magisk installed and failed to get that working so I decided to just not make further attempts to get SBC XQ going on my S7. The problem now is that even though I still have my original files intact, the AP flashing I did caused some minor changes but with one somewhat notable change being that I can no longer send music, now only call audio, over bluetooth to my Sony car stereo. It's not the end of the world because I'm fine using an aux cable instead, but I may miss the convenience of being able to send music over bluetooth.

I don't know why/how this happened. I didn't make any changes to the bluetooth stack, as I never got access. All I did was do some AP flashing in Odin to try and get TWRP running, which I did with a temporary TWRP, but I getting Magisk installed failed whether because it tripped phone security and locked bootup, or a special method would require formatting which I really didn't want to do. So I eventually learned that the process of re-flashing stock firmware AP alone without CSC causes some regional settings to go back to the Samsung Korean default (and flashing with CSC causes format so I will not do that). The settings menu looks different, the carrier says a Korean carrier instead of T-Mobile, when I turn off mobile data I no longer get a confirmation message, but the main downside again is that bluetooth can no longer send music audio. For some reason it can still send call audio to the stereo.
[Android Software/Hacking General [Developers Only]] klaberte:
At this point, I think you best start over. If you have rooted, you can save some time by installing Titanium Backup and use it to save your apps, but not its data or any system data.
[Android Software/Hacking General [Developers Only]] cloneman1:
Using android, how can I disable aptx and force SBC XQ for a particular device?
[Android Software/Hacking General [Developers Only]] dandreye:
One way could be removing AptX libraries (that'd be something like libbt-aptX-ARM-x.x.x.so under /system/lib/ with stock ROM - basically whatever is there with aptX in their filenames), obviously after backing it all up, and rebooting. That's what I did as I see no need in AptX anymore now that we have SBC-XQ. You'll need a rooted Android for that though.
[Android Software/Hacking General [Developers Only]] klaberte:
What ROM did you use?
[Android Software/Hacking General [Developers Only]] ValdikSS:
Option 1: remove aptX libraries.

Option 2: Edit codec priority in res/values/config.xml inside frameworks-res.apk.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
Option 3: Create an RRO overlay so that you won't have to modify the apk anymore.
[Android Software/Hacking General [Developers Only]] dandreye:
This one (Samsung A3 2016 (SM-A310F) Android 7 stock ROM).
[Android Software/Hacking General [Developers Only]] klaberte:
Sorry, I'm not a Dev of ROM cooker, so "RRO overlay" does not mean anything to me. But, if there is a way for an end user to change the order of SBC parameter negotiation, I would be very interested. For example, try first to negotiate with Block Size 8 instead of 16, or try to negotiate Stereo instead of Joint Stereo. Then have the more typical parameter bundle (BlockSize 16, Joint Stereo) as something to try to negotiate if the preferred parameters fail in their negotiation with the SNK (receiver)
[Android Software/Hacking General [Developers Only]] moscic:
Is SBC XQ available in new LineageOS (17, 17.1)?
[Android Software/Hacking General [Developers Only]] d3vyarth:
Can't say, they may be using last patch which was made months ago but Valdik said the patch is not working as intended and require some rework.
[Android Software/Hacking General [Developers Only]] cloneman1:
If anyone decides to make a patch that turns off aptX might as well turn off AAC too. This way, when a device connects, it will use only SBC-XQ, aptXHD, or LDAC.
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
For those who wants an overlay. I didn't override aptX (I don't have an aptX device)
[Android Software/Hacking General [Developers Only]] ondy182:
I just hope there's still a chance it'll work on android q! :p
[Android Software/Hacking General [Developers Only]] jamesm113:
Is there anyway to see what bitrate is used without grabbing the HCI snoop log / getting a diagnostic report?
[Android Software/Hacking General [Developers Only]] balykin_nikita:
Me too
[Android Software/Hacking General [Developers Only]] jamesm113:
Looks like there's a few requests for this patch on google's issue tracker:

https://issuetracker.google.com/issues/135711133

https://issuetracker.google.com/issues/140508489

https://issuetracker.google.com/issues/136342164

The most recent one was assigned and is still open:

https://issuetracker.google.com/issues/144517406

Anything we can do to help get google to put this in a future version of android?
[Android Software/Hacking General [Developers Only]] ValdikSS:
You can calculate it from bitpool and other SBC configuration using https://btcodecs.valdikss.org.ru/sbc-bitrate-calculator/
[Android Software/Hacking General [Developers Only]] ValdikSS:
Google explicitly told me that they are not interested in this functionality

https://issuetracker.google.com/issues/136342164#comment4
[Android Software/Hacking General [Developers Only]] ondy182:
Does it mean your patch won't ever be functional for android 10 or Is this about not getting it implemented into stock?
[Android Software/Hacking General [Developers Only]] Skittles9823:
The latter, custom roms are more than happy to add it once it's ready and merged in lineage.
[Android Software/Hacking General [Developers Only]] abhifx:
well, that sucks! it seems Google doesn't want to add functionality that would make other proprietary implementation redundant or selling premium headphones difficult.
[Android Software/Hacking General [Developers Only]] abhifx:
seems like custom ROMs is the only way for this support. Sadly this also seems neglected there also or is significantly difficult to implement in 10. I sometimes feel that i should roll back to 9 just for this feature.
[Android Software/Hacking General [Developers Only]] Skittles9823:
It's currently open on Linage OS' Gerrit. It'll be picked and merged in other roms once they merge it.
[Android Software/Hacking General [Developers Only]] abhifx:
That is correct, but it is lingering on for a while and that's why I remarked that either it is getting ignored or is tad more difficult to implement in 10.
[Android Software/Hacking General [Developers Only]] bl4dy_pt:
Is it possible to patch current android 10 Bluetooth stack?