[Samsung Galaxy S10/S10+/S10 5G/E Cross Device Deve] Phosphoros:
Linage with MicroG and Signature Spoofing

Hi :)

First of all, thanks a lot [MENTION=4297219]modpunk[/MENTION], [MENTION=4063475]derf elot[/MENTION] and [MENTION=10467607]Linux4[/MENTION] for this ROM :) I'm very new to all the custom Android ROM stuff, but I hope this might help some people.

This post is about my quest to get a S10e relatively google-free, while keeping it as daily-usable as possible. I decided to go with LineageOS and MicroG to replace most of Goolags tracking apps. Also I don't really want to root the phone (I do want my banking apps to work and I don't know what I'd need a root for).

The simplest way to get MicroG enabled seemed to be flashing NanoDroid (22.9.20200910) after switching the Phone to LinageOS. Unfortunately that didn't work for me (that means: signature spoofing didn't get enabled, which is apparently needed for things like push notifications).

As I didn't find any other simple solutions, I decided to try to add the signature spoofing patch myself and build the ROM with it.

These are the steps I took, that resulted in an installable, generally working build (I use Linux unless otherwise noted):

1. Get the current firmware (older firmwares cannot be acquired this way)

I used Frija ( https://xdaforums.com/s10-plus/how-to/tool-frija-samsung-firmware-downloader-t3910594 ) to download the firmware, since I already had LineageOS on my phone, so I couldn't use the official update mechanism. (as Frija is some VisualBlah Program, I did use Windows for this step)

2. Extract the firmware

Well, extract the hell out of that firmware file:

2a. extract the zip

2b. extract the AP*.tar.md5 file (I used the tar program which prints a warning message like data after the end of the archive - I guess that's just the md5-hash)

2c. extract system.img.lz4 and verndor.img.lz4 - at this point you have .img files that are apparently filesystem images. Unfortunately they cannot be mounted right away, because their emtpy spaces are optimized away (=sparse images), you need to desparse them

2d. desparse - I used "SparseConverter.exe /decompress system.img system-desparsed.img", the exe is available here: http://rootjunkysdl.com/files/?dir=Android Programs (YouTube vid: https://www.youtube.com/watch?v=IgkD0idT7EI ), there is also a linux tool (I didn't yet test it): https://github.com/anestisb/android-simg2img

3. Mount the extraced firmware images

My mountpoints might be wrong, but it worked, so here it is:

sudo mount -o loop,users -t ext4 system-desparsed.img /mnt/<somewhere>
sudo mount -o loop,users -t ext4 vendor-desparsed.img /mnt/<somewhere>/vendor

So far the preparation. Now I did as instructed on https://github.com/whatawurst/android_device_samsung_beyond0lte with the following modifications:

After Step "Sync the repo"

After syncing I needed to setup a python 2.7 environment for the "repo" directory, or my build would fail (I use gentoo as a distribution and their way of installing python is probably non-standard, so you might not need this):

<install package virtualenv>
cd ~/lineageos
virtualenv -p /usr/bin/python2.7 repo/
cd repo
source bin/activate

I had to use an old version of virtualenv (16.7.10), in newer versions the command to setup the virtual environment might just be "virtualenv -p 2.7 repo/" (untested).

As there is apparently also a need for python3 (see https://xdaforums.com/lineage/help/linageos-17-1-build-faild-python-error-t4094265 ), I also had to symlink a python3-installation to make the build work:

cd ~/lineageos/repo/bin
ln -s /usr/bin/python3.7 python3

Step "Extract vendor blobs":

As I don't want to pull the firmware blobs from the device, but the mounted images (see above), I first needed to copy one file in the image to another location (it was the only blob not found - I don't know why):

cd /mnt/<system.img>
sudo cp init.rilmptcp.rc system/etc/init/
sudo chown root:root system/etc/init/init.rilmptcp.rc
sudo chmod 0644 system/etc/init/init.rilmptcp.rc

And then alter the extract-files.sh line:

cd device/samsung/beyond0lte
./extract-files.sh /mnt/<somewhere>

Also there are two reports of blobs not used from the firmware: system/lib64/libaptXHD_encoder.so and system/lib64/libaptX_encoder.so - I guess that's okay.

Step "Build LineageOS":

I had to specifically set JAVAC to the supplied Java installation, else it'd detect mismatches (might be linux distribution specific):

JAVAC="prebuilts/jdk/jdk9/linux-x86/bin/javac" m -j20 bacon

Well, with that I could build me a working ROM :)

So last would be the patch for signature spoofing:

I couldn't find a patch for Android 10 (Q), but (with some warnings) the patch for Android 9 (P) applies and seems to work.

I got the patch here: https://github.com/microg/android_packages_apps_GmsCore/tree/master/patches

cd ~/lineageos/repo/frameworks/base
patch -p1 --no-backup-if-mismatch -i "path/to/where/you/saved/the/patch"

Build again and you should get working signature spoofing :)

I did use the MicroG installer from here to install it via TWRP in system: https://github.com/FriendlyNeighborhoodShane/MinMicroG_releases/releases

What doesn't work:

- Threema (instant messenger) complains that the google services are not installed and cannot register for push notifications (my banking app does work though).

- Play store doesn't open (but it might be a broken version that shipped with the MicroG installer I used)

Open questions for me are for now:

- Does "LineageOS for MicroG" include more patches than the one I used? If yes, is it easily possible to apply those patches on top of modpunk's work?

- When I update my repo (via "repo sync"), how can I select a specific version for all the stuff that is downoaded (I'd like to use modpunk's versions as a base)

That's it - I hope this might help someone and if there are questions, I'll try to answer then :cyclops:

Phosphoros