Building LineageOS for an un­sup­ported de­vice

Published: Thu Jul 30 2018
This is part of the an­droid col­lec­tion.


Basically, I got a new phone. Not too many de­vel­op­ers for it yet, and I haven’t doc­u­mented my process pre­vi­ously in a co­her­ent way any­way.

Most build guides” scat­tered across the in­ter­net are only use­ful while build­ing for a de­vice which is al­ready main­tained.


I have been a long time de­vel­oper, hav­ing started with the Xperia X10 Mini Pro. I have bought Sony de­vices ever since, due to their per­ceived open source friendly at­ti­tude. This brought me in con­tact with amaz­ing devs like Myself5 and zacharias.mal­adroit on XDA, as well as the other Xperia devs.

My work (as HaoZeke) for my last phone (Xperia Z5 Dual, a.k.a sumire) in­cluded, a ker­nel, F2FS sup­port, an AOSP based cus­tom ROM (the PixN ROM), a cus­tomized LineageOS, an op­ti­mized cr­Droid build (my cur­rent daily dri­ver), and even a re­cov­ery im­age with F2FS (TWRP). For my ef­forts in bring­ing the the Z5 Dual up to the LineageOS qual­ity guide­lines (mostly by fix­ing en­cryp­tion, bring­ing the dual sim set up to speed and set­ting up the de­vice wiki), I was named a LineageOS co-man­tainer for the de­vice.

Build Setup

Selecting Similar Devices

In my par­tic­u­lar case, a quick look around GSMArena con­vinced me that the de­vice I am try­ing to build for (daisy) is sim­i­lar to an ex­ist­ing (supported) de­vice (tissot). In other words, the Mi A2 Lite is sim­i­lar to the Mi A1.

Similarity above is ba­si­cally in terms of the CPU, and the man­u­fac­turer. Also, main­tained sim­ply means that there ex­ist de­vice trees (and ven­dor con­figs) for the de­vice.

Here is a re­pro­duc­tion of the rel­e­vant parts of this GSMArena link show­ing a full com­par­i­son of the 2 phones (Mi A2 Lite vs Mi A1).

Looking For Device Trees

In par­tic­u­lar for my de­vice (henceforth known by its code-name daisy) had a close match with an older de­vice (tissot). With this I then scoured the usual sources, which are:

The most ob­vi­ous place to search for a de­vice by code-name is the of­fi­cial GitHub or­ga­ni­za­tion.
This group has been out of the lime­light for a while now but since they are still the main source for build­ing TWRP (the only vi­able re­cov­ery im­age), it helps to check their GitHub or­ga­ni­za­tion.

Importing Device Trees

At any rate, armed with this knowl­edge, I next iden­ti­fied the trees I would need.

The nec­es­sary de­vice trees and stuff are the things usu­ally pop­u­lated by com­mands like lunch, which writes a roomservice.xml file in your .repo/local_manifests/.

Basically we seek to re­pro­duce the func­tion­al­ity of a typ­i­cal de­vice roomservice.xml file, like the one gen­er­ated for our ref­er­ence de­vice, tissot:

At this point, this seems like a sim­ple enough de­vice to setup, since it has no ex­tra ven­dor pack­ages like the Sony de­vices. To prove that, con­sider the file needed for build­ing for dogo (Xperia ZR) and honami (Xperia Z1):

<?xml version="1.0" encoding="UTF-8"?>
  <project name="CyanogenMod/android_device_sony_dogo" path="device/sony/dogo" remote="github" />
  <project name="CyanogenMod/android_device_sony_fusion3-common" path="device/sony/fusion3-common" remote="github" />
  <project name="CyanogenMod/android_device_sony_common" path="device/sony/common" remote="github" />
  <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />
  <project name="CyanogenMod/android_kernel_sony_apq8064" path="kernel/sony/apq8064" remote="github" />
  <project name="CyanogenMod/android_hardware_sony_thermanager" path="hardware/sony/thermanager" remote="github" />
  <project name="CyanogenMod/android_external_stlport" path="external/stlport" remote="github" />
  <project name="CyanogenMod/android_device_sony_honami" path="device/sony/honami" remote="github" />
  <project name="CyanogenMod/android_device_sony_rhine-common" path="device/sony/rhine-common" remote="github" />
  <project name="CyanogenMod/android_device_sony_msm8974-common" path="device/sony/msm8974-common" remote="github" />
  <project name="CyanogenMod/android_kernel_sony_msm" path="kernel/sony/msm" remote="github" />
  <project name="CyanogenMod/android_hardware_sony_camera" path="hardware/sony/camera" remote="github" />
  <project name="CyanogenMod/android_hardware_sony_macaddrsetup" path="hardware/sony/macaddrsetup" remote="github" />
  <project name="CyanogenMod/android_hardware_sony_timekeep" path="hardware/sony/timekeep" remote="github" />

Naturally the Xiaomi de­vice seems to have less hard­ware de­pen­den­cies. At this point we note the fol­low­ing about the XML file en­tries:

  1. Each en­try is a project in a manifest block.
  2. The name refers to the repos­i­tory name.
  3. The path key is the di­rec­tory of sync which is rel­a­tive to the source.
  4. remote is de­fined else­where, typ­i­cally at-least github will be de­fined.
  5. Though it is not shown here, revision is of­ten spec­i­fied while pulling from non-stan­dard sources.

Furthermore we note that the file may be de­com­posed to fit the fol­low­ing struc­ture:

At this point we pos­tu­late the fol­low­ing tar­get xml file:

However that’s not go­ing to work*, ob­vi­ously. Eventually if every­thing goes well and your build is sta­ble and fea­ture com­plete, and you take the time and ef­fort to con­tribute the build to a pro­ject (like LOS), yes some poor new­bie will get a roomservice.xml like that by us­ing lunch.

For the re­main­der of this doc­u­ment and post col­lec­tion, it is im­por­tant to re­al­ize that the roomservice.xml file should be re­served for use by lunch, and that repo picks up all valid xml in .repo/local_manifests.

Hence we shall now do the fol­low­ing:

Now we shall pop­u­late the blank xml file with our own per­sonal test repos­i­to­ries. Mine looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Remotes -->
<remote name="bitbucket"
        fetch="" />
<remote  name="omnirom"
         fetch="" />
<remote  name="gitlab"  fetch="" />
<!-- Daisy Tree Stuff -->
<project name="LineageOS/android_packages_resources_devicesettings" path="packages/resources/devicesettings" remote="github" />
<!-- Kernel -->
<project name="hzDroidBits/android_kernel_xiaomi_msm8953" path="kernel/xiaomi/msm8953" remote="github" revision="lineage-15.1" />
<!-- The original is provided by Xiaomi. Lineage might also have an interesting take. -->
<!-- Actually the Lineage code is maybe a better bet. -->
<!-- <project name="MiCode/Xiaomi_Kernel_OpenSource" path="kernel/xiaomi/msm8953" remote="github" revision="daisy-o-oss" /> -->
<!-- Device -->
<project name="hzDroidBits/android_device_xiaomi_msm8953-common" path="device/xiaomi/msm8953-common" remote="github" revision="lineage-15.1" />
<project name="hzDroidBits/android_device_xiaomi_daisy" path="device/xiaomi/daisy" remote="github" revision="lineage-15.1" />
<!-- Older Source -->
<!-- Tissot also has Lineage Trees -->
<!-- <project name="TheScarastic/android_device_xiaomi_msm8953-common" path="device/xiaomi/msm8953-common" remote="github" revision="lineage-15.1" /> -->
<!-- <project name="TheScarastic/android_device_xiaomi_tissot" path="device/xiaomi/daisy" remote="github" revision="lineage-15.1" /> -->
<project name="TheScarastic/proprietary_vendor_xiaomi" path="vendor/xiaomi" remote="github" revision="lineage-16.0" />

My tree in­cludes some re­motes which will even­tu­ally be used to pull in tool-chains and other good­ies.

It is of­ten best to setup an or­ga­ni­za­tion for your an­droid ROM needs (excluding the ker­nel) as most of them need mi­nor changes and will even­tu­ally be merged — HaoZeke