mardi 3 mars 2015

[Q&A] Lollipop BMW E46 Carkit Bluetooth Problem (patching bluetooth.default.so)) topic






Background: With Android 4.2 Google introduced a new Bluetooth stack which broke bluetooth connections with some older car kits (see the comment in http: // review.cyanogenmod.org/#/c/63060/). I'm the original submitter of that patch and with purchasing a new new phone (Moto X 2 2014) and Lollipop I had to revisit the issue (my car is still the same BMW E46). The patch was also submitted to Google but never made it into the offical build, but was accepted by CyanogenMod, but that is not available for my phone.

This applies to the Moto X 2 (2014) Lollipop bluetooth library, but probably the same will work for Android 4.2.2, 4.3, 4.4 and other phones (and some other cars) too.

Essentially I found that it is possible to patch the bluetooth lib on the phone directly without a complete android build environment.

Here are the steps (I'm keeping them somewhat vague to deter noobs from trying to tinker with the files):

To make Android work with those older BMW car kits, it is necessary to modify a behavior of bluetooth in some minor way. This obviously requires a rooted device.

The file in question is /system/lib/hw/bluetooth.default.so

Step 1 (make a backup):
run adb shell and copy /system/lib/hw/bluetooth.default.so to /system/lib/hw/bluetooth.default.so.orig

Step 2 (disable bluetooth and download the file to patch to your computer):
On the phone go to settings and turn bluetooth off
Issue: adb pull /system/lib/hw/bluetooth.default.so bluetooth.default.so

Step 3 (generate a hex version of the file, linux):
xxa bluetooth.default.so >bds.txt

Step 4 (edit the hex version):
Find the byte sequence b8ed a8b1 b4f8 6032 93b9 b0f8 08e0 0de0 (it should be around offset 00a1000)
Change it to b8ed a8b1 b4f8 6032 93b9 4ff0 000e 0de0

Step 5 (create a binary version of the patched file):
xxa -reverse bds.txt > bluetooth.default.so.patched

Step 6 (upload patched binary to phone):
Remount the /system partition as rw
Issue adb push bluetooth.default.so.patched /system/lib/hw/bluetooth.default.so
Use adb shell, then: su chmod 644 /system/lib/hw/bluetooth.default.so
Verify that only those four bytes changed: cmp -l /system/lib/hw/bluetooth.default.so.orig /system/lib/hw/bluetooth.default.so

Step 7 (enable bluetooth again):
on the phone set Settings > Bluetooth : on
Make sure it stays on (and doesn't give an error, otherwise make sure the file has correct permissions and/or copy the original file back)

Step 8 (check with car):
Take phone to the car, pair the device to the car-kit.
It should stay paired and making calls and access to the phone address register should work.

Done.






Aucun commentaire:

Enregistrer un commentaire