librepods-org / librepods-org/librepods

L2CAP connection fails on A16 GrapheneOS

Open
#211 20 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

android bug good first issue
Dominant language
Kotlin
Stars
29.9k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Commented on #188 as well, but creating a new issue as I have gathered some more potentially helpful info.

As zygisk does not work on rooted GrapheneOS, I can't (correct me if I'm wrong) use the Xposed framework. Thus I'm installing the btl2capfix module with Magisk.

I tried the module from #61 using the nightly build and got the same error mentioned in #188. I then tried investigating the module to see if it does what it has to. Android is not my expertise so my assumptions might be wrong but here are my findings (looking at the phones filesystem after module install and reboot):

  1. My phones bluetooth library is located at /apex/com.android.bt/lib64/libbluetooth_jni.so.
  2. post-data-fs.sh creates an overlay mount from /data/adb/modules_update/btl2capfix/apex/com.android.bt/lib64 to /apex/com.android.bt/lib64
    Contents of post-data-fs.sh:
    #!/system/bin/sh
    mount -t overlay overlay -o lowerdir=/apex/com.android.bt/lib64,upperdir=/data/adb/modules_update/btl2capfix/apex/com.android.bt/lib64,workdir=/data/adb/modules_update/btl2capfix/apex/com.android.bt/work /apex/com.android.bt/lib64
    
  3. /data/adb/modules_update/ does not exist, but /data/adb/modules/btl2capfix/ does
  4. With this info I tried patching the module to instead mount /data/adb/modules/btl2capfix/apex/com.android.bt/lib64 to /apex/.../lib64
  5. After installing the modified module I checked the sha512 hashes for both files and they didn't match +
    mount | grep overlay | grep bluetooth and mount | grep apex.*bt didn't return anything to indicate an overlay mount to /apex/.../lib64
  6. I then tried to instead create a bind mount, that did not work as well. Then I tried the bind mount, but in service.sh instead of post-data-fs.sh. This finally worked
    By worked I mean the sha512 hashes of /data/adb/modules/btl2capfix/apex/com.android.bt/lib64/libbluetooth_jni.so and /apex/com.android.bt/lib64/libbluetooth_jni.so matched. I'm not sure that's the correct way to measure success in this case, but there was a change.
  7. I copied the patched libbluetooth_jni.so file over to my computer to check if the patches were successful. I looked at the addresses dispalyed for both functions is the Magisk install log and both had a return at the start of the function - matching the hex in customize.sh
  8. Even with the now confirmed patched libbluetooth_jni.so bind mounted into /apex/.../lib64, the same error of L2CAP connection failing persisted.

I captured troubleshooting logs with the module mentioned in #61: airpods_log_1759102497486.txt
And the modified version with bind mounting and matching file hashes: airpods_log_1759102773514.txt

I am aware that this is a massive edge case as Pixel phones with A16 seem to work when using the Xposed framework. I might be the only person trying to run Librepods on a Pixel6 running rooted GrapheneOS.

I am very thankful for your continued work on this project. Let me know if I can provide any additional information.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the btl2capfix module from #61, especially post-data-fs.sh, service.sh, and customize.sh, then compare the attached logs and mount/hash results on A16 GrapheneOS. Done means establishing whether the patched libbluetooth_jni.so is loaded correctly and resolving the persistent L2CAP connection failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, shell
Domain
mobile-dev, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.