LineageOS 18.1 for Sony Xperia 1/5

Hello, first time writing a blog :)

Sony Open Devices offers you the chance to port new operating systems onto Sony devices by trying to keep the system blob-free and make the Android ecosystem somewhat sustainable.

They also provide instructions on how to build AOSP and downloadable binaries which is pretty neat.

Because I hate XDA, I built LOS from SODP sources and published the builds here.

I would like to thank @MartinX3 (for the initial 17.1 port) and the SODP team for making all of this possible :)

Pre flashing

As usual when installing a ROM, be sure your bootloader is unlocked and you have a backup of your data if you want to restore it or in case something goes wrong.

I cannot guarantee that this ROM will work for you, you have been warned

Before using this ROM you need to do the following because of this bug:

If you think you are safe by having all of the 55.1.xxx firmware bits installed you are wrong, because various things like bluetooth will be broken.

Flashing

You can download the build for your phone here (there are both microG and vanilla LineageOS builds) and flash it with the following instructions.

Building

You need to be familiar with building LineageOS in the first place; there are some quirks in this port that need to be resolved before starting to compile.

The manifests you need are located here.

The build you will obtain will not include features like LiveDisplay, Night Light or microG: you will have to add these features yourself.

Now you will need to:

project vendor/oss/repo_update/
diff --git a/repo_update.sh b/repo_update.sh
index 24769b1..dd45d1d 100755
--- a/repo_update.sh
+++ b/repo_update.sh
@@ -59,12 +59,6 @@ if [ "${SKIP_SYNC:-}" != "TRUE" ]; then
     repo sync -j8 --current-branch --no-tags
 fi
 
-enter_aosp_dir bionic
-# Add inaddr.h header file
-# Change-Id: Iad92c39fb729538cf51bf9d9037b15515104b453
-apply_gerrit_cl_commit refs/changes/84/1582884/1 5efdad358c77795bef6c011d87625b0a46b0bd0d
-popd
-
 enter_aosp_dir vendor/qcom/opensource/data/ipacfg-mgr/sdm845 hardware/qcom/sdm845/data/ipacfg-mgr
 # guard use of kernel sources
 # Change-Id: Ie8e892c5a7cca28cc58cbead88a9796ebc80a9f8
@@ -83,27 +77,6 @@ enter_aosp_dir hardware/qcom/wlan
 apply_gerrit_cl_commit refs/changes/49/1532349/1 c889ca2c5503fb955f276c4899924c324effd8cc
 popd
 
-enter_aosp_dir frameworks/base
-# Fix bug Device that can't support adoptable storage cannot read the sdcard.
-# Change-Id: I7afe5078650fe646e79fced7456f90d4af8a449a
-apply_gerrit_cl_commit refs/changes/48/1295748/1 6ec651f12a9b67a9d2e41c2fe4d9a71c29d1cf34
-# SystemUI: Implement burn-in protection for status-bar/nav-bar items
-# Change-Id: I828dbd4029b4d3b1f2c86b682a03642e3f9aeeb9
-apply_gerrit_cl_commit refs/changes/40/824340/3 fcc013282943c935af8225a914a525e996d42866
-popd
-
-enter_aosp_dir build/make build
-# releasetools: Use du -b
-# Change-Id: I1955261de0f6323518b214e2731ef4879c3304e0
-apply_gerrit_cl_commit refs/changes/03/1269603/1 96a913e7f4eceb705b4e6862068117670ce31b79
-popd
-
-enter_aosp_dir system/vold
-# Switch to exfatprogs compatible fsck parameter
-# Change-Id: I2c436816a293a36fc9f0cd635cdb9ca3b5f88bfc
-apply_gerrit_cl_commit refs/changes/37/1441937/1 2035a83916914ec8c6ecaacb6f23ea5256be2edd
-popd
-
 # because "set -e" is used above, when we get to this point, we know
 # all patches were applied successfully.
 echo "+++ all patches applied successfully! +++"
diff --git a/snippets/lineage.xml b/snippets/lineage.xml
index 673d28a..f623e97 100644
--- a/snippets/lineage.xml
+++ b/snippets/lineage.xml
@@ -70,19 +70,19 @@
     <!-- add guard for AOSP hardware/qcom dir -->
     <linkfile src="os_pickup_aosp.mk" dest="hardware/qcom/Android.mk" />
     <!-- for AOSP sdm845 and sm8150, we override os_pickup.mk -->
-    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom/sdm845/Android.mk" />-->
-    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom/sm8150/Android.mk" />-->
+    <linkfile src="os_pickup.mk" dest="hardware/qcom/sdm845/Android.mk" />
+    <linkfile src="os_pickup.mk" dest="hardware/qcom/sm8150/Android.mk" />
     <!-- add guards for CAF repositories -->
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/apq8084/Android.mk" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8916/Android.mk" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8952/Android.mk" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8960/Android.mk" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8974/Android.mk" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8994/Android.mk" />
-    <linkfile src="os_pickup.bp" dest="hardware/qcom-caf/msm8996/Android.bp" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8996/Android.mk" />
-    <linkfile src="os_pickup.bp" dest="hardware/qcom-caf/msm8998/Android.bp" />
-    <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8998/Android.mk" />
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/apq8084/Android.mk" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8916/Android.mk" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8952/Android.mk" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8960/Android.mk" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8974/Android.mk" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8994/Android.mk" />-->
+    <!--<linkfile src="os_pickup.bp" dest="hardware/qcom-caf/msm8996/Android.bp" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8996/Android.mk" />-->
+    <!--<linkfile src="os_pickup.bp" dest="hardware/qcom-caf/msm8998/Android.bp" />-->
+    <!--<linkfile src="os_pickup.mk" dest="hardware/qcom-caf/msm8998/Android.mk" />-->
     <linkfile src="os_pickup_qssi.bp" dest="hardware/qcom-caf/sdm845/Android.bp" />
     <linkfile src="os_pickup.mk" dest="hardware/qcom-caf/sdm845/Android.mk" />
     <linkfile src="os_pickup_qssi.bp" dest="hardware/qcom-caf/sm8150/Android.bp" />

You should now be ready to build.

As an example, here's how to build for the J8210 (Xperia 5 single SIM):

source build/envsetup.sh
breakfast lineage_j8210-userdebug
make -j4 dist # or whatever is your number of threads

Bugs