[Treble-Enabled Device Development A/AB ROMS] linuxct:
Hello,

After a few weeks of having Project Treble GISs running in my Razer Phone, I had one big issue to solve, and that was the in-call audio. I stumbled upon a few people in #phh-treble Telegram group that suggested me to use ZUK (MSM8996) patches to get it to work, but unfortunately they weren't fully working... because of a missing apk from my device's stock image (which I didn't know until 2 or 3 days ago). Starting from there, I worked on it quite a lot of time until almost giving up, to then finally getting it to work just now.

Steps I followed:

1. Pull from your device's stock image the following files (they may not be in /system and instead be located in /vendor, depends on your OEM's Treble implementation)

- app/QtiSystemService

- app/QtiTelephonyService

- framework/qcrilhook.jar

- framework/QtiTelephonyServicelibrary.jar

- etc/permissions/privapp-permissions-qti.xml

- etc/permissions/qcrilhook.xml

- etc/permissions/qti_permissions.xml

- etc/permissions/telephonyservice.xml

- priv-app/qcrilmsgtunnel

2. Fortunately, those APKs will contain a .dex inside of them, but in case they didn't, you'd need to first deodex your rom based on the vdex files located in /system/framework/oat. However, the jars will definitely and for sure won't have the inner .dex classes. You'll need to use a tool such as vdexExtractor to get the final .dex files for qcrilhook.jar and QtiTelephonyServicelibrary.jar. Then, open the metioned .jar's as zip files, embed the .dex inside and done.

3. The tricky part comes now: With a tool such as APKTool, decompile the qcrilmsgtunnel.apk file you've extracted from your Stock ROM image. I'm not going to go throught the steps to perform that. Now, open up the AndroidManifest.xml and find the line:

<uses-library android:name="android.hidl.manager@1.0-java" />

and replace it with

<uses-library android:name="android.hidl.manager@1.0-java" android:required="false" />

Recompile the apk and, without signing it yet, put it in a safe place.

4. Open up the other APKs and remove the META-INF folders from inside of them (the signatures). Now, download a copy of SignAPK and sign every apk (including the ones we've removed the signature from, plus the modded version of qcrilmsgtunnel.apk with the platform keys (platform.*) from Android AOSP.

You can do so by using the following command:

java -jar /path/to/signapk.jar /path/to/platform.x509.pem /path/to/platform.pk8 NameOfTheApk.apk NameOfTheApk_signed.apk

5. Open up the files qcrilhook.xml and telephonyservice.xml and ensure that the file="" path points to /vendor. i.e:

file="/vendor/framework/qcrilhook.jar"

6. Move the files to your device according to this table:

- app/QtiSystemService -> /system_root/system/app/QtiSystemService (replace)

- app/QtiTelephonyService -> /system_root/system/app/QtiTelephonyService (replace)

- framework/qcrilhook.jar -> /vendor/framework/qcrilhook.jar (delete the original file wherever you found it)

- framework/QtiTelephonyServicelibrary.jar -> /vendor/framework/QtiTelephonyServicelibrary.jar (delete the original file wherever you found it)

- etc/permissions/privapp-permissions-qti.xml -> /system_root/system/etc/permissions/privapp-permissions-qti.xml (delete the original file wherever you found it)

- etc/permissions/qcrilhook.xml -> /system_root/system/etc/permissions/qcrilhook.xml (delete the original file wherever you found it)

- etc/permissions/qti_permissions.xml -> /system_root/system/etc/permissions/qti_permissions.xml (delete the original file wherever you found it)

- etc/permissions/telephonyservice.xml -> /system_root/system/etc/permissions/telephonyservice.xml (delete the original file wherever you found it)

- priv-app/qcrilmsgtunnel -> /system_root/system/priv-app/qcrilmsgtunnel (replace)

Reboot and profit.