Fix bluetooth audio & APTX in Treble-GSI

Search This thread

Craftingmod

Member
Dec 20, 2016
24
67
it's for Treble-GSI only :)

Tested in AospExtended V6.3 (B partition)

1. Bluetooth audio connection fix

Simply remove /vendor/overlay/BluetoothResCommon.apk via root explorer

2. AptX-HD

1) Install "Bluetooth stack audio bitrate changer for SBC + aptX & aptX-HD enabler" from Download of Magisk Manager (APTX for Android Oreo & Pie NOT WORK)

2) Remove /vendor/overlay/RazerAuraBluetoothRes.apk (There's content of aptx and I don't know why it is in here)
!:?촒 resources.arsc5? ?com.android.bluetooth.overlay.razer.aura X 8$attrinteger?,"Gra2dp_source_codec_priority_aptx""a2dp_source_codec_priority_aptx_hd((a2dp_source_codec_priority_aptx_adaptive##a2dp_source_codec_priority_aptx_tws [email protected] 0   PK !:AndroidManifest.xml븪켷 A ?總?bp굛 ?C(??*

3) Open /vendor/build.prop and find "persist.vendor.bt.a2dp_offload_cap=sbc-aac" and replace "sbc-aac" to "sbc-aac-aptx-aptXHD" (Add -aptx-aptXHD)

4) Profit! :)

I've only tested in AOSPExtended GSI v6.3 so if you are in stock only try living in the edge :p
 

Attachments

  • photo_2019-04-06_22-07-45.jpg
    photo_2019-04-06_22-07-45.jpg
    38.9 KB · Views: 2,583
Last edited:

Nomyth

Member
Feb 17, 2019
18
3
This definitely doesn't work on stock. Something keeps restoring RazerAuraBluetoothRes.apk (and BluetoothResCommon.apk reappears after the magisk mod is installed, if that matters).
 

CurtisMJ

Senior Member
May 23, 2013
635
535
This definitely doesn't work on stock. Something keeps restoring RazerAuraBluetoothRes.apk (and BluetoothResCommon.apk reappears after the magisk mod is installed, if that matters).
There are kernel protections in stock that disable modification of the vendor partition. Arter97's kernel has these disabled but I strongly recommend NOT modifying the vendor partition(it pisses off the bootloader). Learning how to make a custom Magisk module would be a better option here...
 

CurtisMJ

Senior Member
May 23, 2013
635
535
I tried it in stock but don't work at stock :( (Enabled aptx but connect failed)
Hmm. If I remember right stock needs aptx libs to work. I tried that at one point and it actually connected, but only succeeded in making my ears bleed with a horrible static screeching when trying to play audio. Maybe both the libs and this thread are required...
 

popeye2468

Senior Member
Sep 6, 2014
68
13
Xiaomi Mi 11
This does not work in the ROM suggested too, the Bluetooth fails to work, doesn't even turn on, its something to do with BluetoothResCommon.apk
 

CalebQ42

Senior Member
Jan 4, 2014
168
129
OnePlus 7 Pro
Last edited:

CurtisMJ

Senior Member
May 23, 2013
635
535
Not AptX, but apparently LDAC just works on the stock ROM simply by adding it to the offload prop. It's supposedly just part of a standard Android build now, but needs a certification process for the OEM to be allowed to turn it on.
 
  • Like
Reactions: elyod

elyod

Member
Jul 17, 2008
15
4
Not AptX, but apparently LDAC just works on the stock ROM simply by adding it to the offload prop. It's supposedly just part of a standard Android build now, but needs a certification process for the OEM to be allowed to turn it on.

Has anyone tried this method? I just got a bluetooth device which can use the advanced codecs so I want to get ldac working.
 

CurtisMJ

Senior Member
May 23, 2013
635
535
Has anyone tried this method? I just got a bluetooth device which can use the advanced codecs so I want to get ldac working.
I had tried before posting actually sorry, so I can confirm LDAC works fine. I remember there was more than one prop though. I'll try find the ones I changed...
 
  • Like
Reactions: elyod

elyod

Member
Jul 17, 2008
15
4
I had tried before posting actually sorry, so I can confirm LDAC works fine. I remember there was more than one prop though. I'll try find the ones I changed...

Thanks I appreciate it. I spent quite a while trying to find other resources for it, best I could find was people porting ldac on Sony phones and I was hesitant to try it on the razer.
 

CurtisMJ

Senior Member
May 23, 2013
635
535
Thanks I appreciate it. I spent quite a while trying to find other resources for it, best I could find was people porting ldac on Sony phones and I was hesitant to try it on the razer.
Ok, so the following prop change is needed:

persist.vendor.bt.a2dp_offload_cap=sbc-aac-ldac

I can't seem to find the other one I changed, I suspect it didn't exist. I'll try to get back to my scripts tommorow to check. There are various ways to change props. I think there's a Magisk module to do custom ones (I just have my own boot scripts for this kind of stuff).
No porting needed as the LDAC libs are part of Android 9.
 
  • Like
Reactions: elyod

elyod

Member
Jul 17, 2008
15
4
Ok, so the following prop change is needed:

persist.vendor.bt.a2dp_offload_cap=sbc-aac-ldac

I can't seem to find the other one I changed, I suspect it didn't exist. I'll try to get back to my scripts tommorow to check. There are various ways to change props. I think there's a Magisk module to do custom ones (I just have my own boot scripts for this kind of stuff).
No porting needed as the LDAC libs are part of Android 9.

Cool, I've modified the build.prop several times using a text editor so that's what I'm comfortable with. I'll give it a shot.
 

elyod

Member
Jul 17, 2008
15
4
Okay, so I found a magisk module that enabled ldac.

Confirmed working using the companion app for my ES100 bt dac.
 

Attachments

  • Screenshot_20190516-223143.jpg
    Screenshot_20190516-223143.jpg
    211.3 KB · Views: 794
  • Screenshot_20190516-223108.png
    Screenshot_20190516-223108.png
    128.8 KB · Views: 792
  • Like
Reactions: rogeriskira

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    it's for Treble-GSI only :)

    Tested in AospExtended V6.3 (B partition)

    1. Bluetooth audio connection fix

    Simply remove /vendor/overlay/BluetoothResCommon.apk via root explorer

    2. AptX-HD

    1) Install "Bluetooth stack audio bitrate changer for SBC + aptX & aptX-HD enabler" from Download of Magisk Manager (APTX for Android Oreo & Pie NOT WORK)

    2) Remove /vendor/overlay/RazerAuraBluetoothRes.apk (There's content of aptx and I don't know why it is in here)
    !:?촒 resources.arsc5? ?com.android.bluetooth.overlay.razer.aura X 8$attrinteger?,"Gra2dp_source_codec_priority_aptx""a2dp_source_codec_priority_aptx_hd((a2dp_source_codec_priority_aptx_adaptive##a2dp_source_codec_priority_aptx_tws [email protected] 0   PK !:AndroidManifest.xml븪켷 A ?總?bp굛 ?C(??*

    3) Open /vendor/build.prop and find "persist.vendor.bt.a2dp_offload_cap=sbc-aac" and replace "sbc-aac" to "sbc-aac-aptx-aptXHD" (Add -aptx-aptXHD)

    4) Profit! :)

    I've only tested in AOSPExtended GSI v6.3 so if you are in stock only try living in the edge :p
    3
    To fix music on GSI (not aptx or anything, , just functionality), delete the BluetoothResCommon.apk, make a duplicate copy of RazerAuraBluetoothRes.apk, and rename it BluetoothResCommon.apk just like the one you deleted. Working for me in Pie AOSiP.

    *Update*
    With the fake BluetoothResCommon.apk in place, you can flash that APTX Magisk module referenced in OP and make the same build.prop changes without ripping out the Razer overlay and APTX HD is working splendidly.
    2
    Reflash the gsi rom that you are using. Flash it using fastboot and both partitions. That's what I did and all is good. However it could be the rom but my nfc isn't working. Which isn't a big deal since I never use it.

    It seems deleting BluetoothResCommon.apk prevented bluetooth from starting up with logcats complaining about HID-related issues. It's possible that the vendor partition might not have the drivers and related stuffs meant to support HID devices (maybe this means gamepads won't work, I need to confirm this as I do have a gamepad that I intend to use it with).

    The decompiled BluetoothResCommon.apk contained these in bools.xml, which seems to indicate that it doesn't support connecting HID devices.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <bool name="profile_supported_hfpclient">false</bool>
        <bool name="profile_supported_avrcp_controller">true</bool>
        <bool name="profile_supported_a2dp_sink">true</bool>
        <bool name="profile_supported_sap">true</bool>
        <bool name="profile_supported_ba">true</bool>
        <bool name="profile_supported_hid_device">false</bool>
    </resources>

    And as for RazerAuraBluetoothRes.apk, the decompiled content has an integers.xml which contained values setting the codec priority for aptX-related ones to -1 (which probably means it would never try to use them).
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <integer name="a2dp_source_codec_priority_aptx">-1</integer>
        <integer name="a2dp_source_codec_priority_aptx_hd">-1</integer>
        <integer name="a2dp_source_codec_priority_aptx_adaptive">-1</integer>
        <integer name="a2dp_source_codec_priority_aptx_tws">-1</integer>
    </resources>

    I tried reflashing the GSI (Havoc 2.9, 20190914) after deleting BluetoothResCommon.apk and still cannot turn on Bluetooth.

    Bluetooth can be turned on if BluetoothResCommon.apk is kept, but my aptX-capable headset (CX SPORT) can only handle phone calls, media audio cannot be routed as a2dp initialization failed somewhere (and nothing apparent shows up in the logcats I captured).

    Maybe instead of deleting the overlays, hacking them (by changing their values so things can work) might be a better idea...

    EDIT: DO NOT DELETE BluetoothResCommon.apk, but you can hack it by setting all the values mentioned to true (with the help of apktool). Not sure about before, but with the hacked BluetoothResCommon.apk, I can turn on Bluetooth and pair my FeiZhiWee 2T bluetooth gamepad just fine (although it won't be of too much use since I cannot toggle SELinux to permissive with arter97's kernel).

    Note that if you intend to hack the overlays, you need to pay attention to this after rebuilding with apktool (that you need to copy the original META-INF and AndroidManifest.xml), or you may get a bootloop.

    However, with or without RazerAuraBluetoothRes.apk, the issue that I cannot route media audio to Bluetooth headset, only phone calls, on Havoc 2.9 GSI, is still there. It seems toggling media audio also takes a long time (and logcat showed something about timeout). The toggle itself works as usual but in reality media audio doesn't work.


    EDIT 2: I'm new to the A/B partitioning scheme. Can the contents in the inactive slot affect the other? I only flashed the kernel and GSI (and modified vendor contents) in active slot (A) while keeping the inactive slot (B) intact (with stock stuffs just in case).

    EDIT 3: I have confirmed that deleting both BluetoothResCommon.apk and RazerAuraBluetoothRes.apk does fix the media audio, but it must be done before first GSI boot. If you have booted, you won't be able to turn on Bluetooth anymore once you delete BluetoothResCommon.apk. You'll need to do a factory reset (wipe data from TWRP) and clean flash the GSI.
    1
    Not AptX, but apparently LDAC just works on the stock ROM simply by adding it to the offload prop. It's supposedly just part of a standard Android build now, but needs a certification process for the OEM to be allowed to turn it on.
    1
    Has anyone tried this method? I just got a bluetooth device which can use the advanced codecs so I want to get ldac working.
    I had tried before posting actually sorry, so I can confirm LDAC works fine. I remember there was more than one prop though. I'll try find the ones I changed...