[ROM][8.1/9/10/11][Unofficial][EOL] LineageOS for Mi-4c/Mi-4s

Search This thread

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
DESCRIPTION
Unofficial LineageOS ROMs for Mi-4c (libra) and Mi-4s (aqua), with base-layer enhancements and performance optimizations. Version 15.1/16.0/17.1/18.1 are available for download.

FEATURE
The following items may not be available for all versions, please use the latest build!
  • Build with user variant instead of userdebug (to reduce image size and improve performance).
  • CPU/GPU is overclocked with optimized voltage/bus-cci and 300 Hz/Jiffies kernel clock frequency. [16.0 +]
  • EAS (sched cpufreq governor from linux-3.18) CPU scheduler implemented. [16.0 +]
  • Full-weight NotoSansCJK fonts included (to display East Asian characters with more font weights).
  • High screen refresh-rate (75 Hz) support for Mi-4c with "Sharp-rsp61322 LCD" screen. [16.0 +]
  • Implement ZRAM with ZSTD crypto algorithm (KSM is used after 20210116) to improve I/O performance on devices with 2GB RAM. [16.0 +]
  • Linux kernel is built by clang-12 toolchains, with Polly + LTO + -Ofast optimization to get better performance. [17.1 +]
  • Pre-dex2oat with everything filter globally (sacrificing space and first-install time to improve efficiency).
  • Remove or disable unnecessary kernel configs and modules, also includes some other optimizations. [16.0 +]
  • Remove unnecessary apps/binaries/libraries/services from system. [16.0 +]
  • Signature spoofing support (ready for MicroG, including Chinese translations).
  • User-friendly controller for special features in Settings app (like CPU overclock, Edge gesture and Screen refresh rate). [17.1 +]
  • ...

STATUS
Go to GitHub Issues for more details and give me feedback.
  • Working
    • Basic hardware
      • Baseband/SMS
      • Bluetooth
      • Camera/Flashlight
      • IR remote
      • Speaker/Microphone
      • Wi-Fi
    • Extras
      • Camera API2 (with patch) [17.1 +]
      • Edge gesture (in Settings > System > Buttons) [16.0 +]
      • Overclock control (in Settings > Battery > Battery saver and performance) [17.1 +]
      • Screen refresh rate (in Settings > Display) [17.1 +]
  • Not working
    • SELinux permissive [16.0 +]
    • VOLTE (won't fix because of no compatible IMS stacks) [16.0 +]

DOWNLOAD

SOURCE

Thanks to all developers and users (Gah0 | Mortezadadgar | Xiaomi classic dev | ...) who contributed to Mi-4c/Mi-4s (including other devices shipped with MSM8992/8994 SOC) or gave me help!
 
Last edited:

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
TIPS
Here are some tips which may improve your experience or resolve some problems.
  • Basic quality assurance: I only have one smart phone (3+32GB Mi-4c ×1), so the ROMs here should at least satisfy my daily usage.
    • This project will be kept maintained even after I bought my new mobile phone (8+128GB Mi-Mix-2 ×1) in 2021. My Mi-4c is one of the most meaningful items of my own, it's not easy to leave it behind in the drawer and say goodbye. The new battery and rear cover (thanks to yipinghuang1991) will refresh this old device and make it usable again.
  • Even though the signal icon in status bar shows "No signal" at the first minute after boot, the device is still able to receive SMS and phone calls (so the device does have signal, but the system doesn't admit it at all).
  • If the free space in /system is not enough to install GAPPs, try to delete /system/fonts/NotoSansCJK.ttc to get about 100MB free space (If Chinese/Japanese/Korean is not your main language). Removing the prebuilt Webview packages (about 120MB) after installed another one is also a solution.
  • If you found random reboot on your device with overclock enabled (or just updated to lineage-17.1-20201216 and left overclock option unchanged), please disable this feature to see if this issue is resolved. Go to Settings > System > Battery > Battery saver and performance, enable then disable "High performance mode", and reboot your device. If you are using lineage-17.1-20210209 or newer, it's no need to do such steps after a clean install (as both persist.sys.cpu_overclock and persist.vendor.edge_touch_mode are default to false by default).
  • It's highly recommended to disable system logs to reduce resource consumption (for better performance and privacy), unless you're going to collect system logs. Go to Settings > System > Developer options, and set the value of "Logger buffer sizes" to off.
  • It's not recommended to use SELinux enforcing mode even if it's supported in some builds. Also, please consider the negative effect of I/O performance before enabling disk encryption, unless you really want to.

BUILD
As all source codes and custom changes in my LineageOS ROMs are open-source, you are permitted to build your own ROM or kernel (not only for LineageOS) with my sources for non-commercial purpose.

There are many documents about how to build custom Android ROMs in Linux/OSX, so I will not post these basic steps here to reduce redundancy. However, there are still some important things which may not be included in other documents. Here are some basic steps about what you should do (using lineage-18.1 as example), you can also take a reference to other tutorials.
  • Install necessary packages
    • There are a number of "necessary" packages listed in most tutorials, but not all of them are needed. Here are the packages you need to install manually on Ubuntu or Debian.
      • sudo apt install bc bison git gnupg make repo rsync unzip zip
  • Sync Android sources
    • You need to download and update your local repo with upstream sources regularly, in order to get new changes as soon as possible (just like other open-source projects).
      • Init repo to current directory: repo init -u https://github.com/LineageOS/android.git -b lineage-18.1 --depth=1
      • Sync all repos and prune unused branches: repo sync --prune
    • If nothing wrong happened, the LineageOS sources have been downloaded to your computer (about 100GB). Here are some commands which might be useful in the future.
      • Show all local changes of your repos: repo status or repo diff
      • Perform any operations to all repos: repo forall -c "xxx"
  • Setup local manifest
    • To sync your Android sources with upstream repos easily, it's recommended to create a local manifest in ./repo/local_manifests/. The local manifest should be a XML file like the following one, any filename is accepted (file: libra.xml).
      XML:
      <?xml version="1.0" encoding="UTF-8"?>
      <manifest>
        <project name="BYZYB/android_device_xiaomi_libra" path="device/xiaomi/libra" remote="github" revision="lineage-18.1" />
        <project name="BYZYB/android_kernel_xiaomi_libra" path="kernel/xiaomi/libra" remote="github" revision="master" />
        <project name="BYZYB/android_vendor_xiaomi_libra" path="vendor/xiaomi/libra" remote="github" revision="lineage-16.0" />
        <project name="LineageOS/android_hardware_sony_timekeep" path="hardware/sony/timekeep" remote="github" revision="lineage-18.1" />
        <project name="LineageOS/android_hardware_xiaomi" path="hardware/xiaomi" remote="github" revision="lineage-18.1" />
      </manifest>
  • Resolve build errors
    • Due to some hacks in my device configurations which are conflict with Android build rules, there might be some build errors if using all my repos directly. To resolve this issue, you need to modify project build/make/manually on your disk. After that, you should be able to prepare the necessary environment for Android build without errors.
      • Setup build namespace only: . build/envsetup.sh
      • Prepare build environment for Mi-4c with a specified build variant (xxx = eng/userdebug/user): . build/envsetup.sh && lunch lineage_libra-xxx
    • If you want to build the ROM in "user" build variant instead of the default "userdebug", more changes are needed to avoid build errors or potential bootloop. The following commands are some ways to build a full ROM.
      • Build full ROM in "user" variant: brunch lineage_libra-user
      • Build full ROM in "userdebug" variant: brunch lineage_libra-userdebug
      • Build full ROM with a specified number of threads (x ≤ physical CPU cores): lunch lineage_libra-xxx && make -jx
      • If you have lunch before, here is the simplest way: m
    • As git patch files are similar to git diff, you can always do these changes manually without using git am xxx.patch && git reset HEAD^ or other shell commands.
  • Kernel build toolchains
    • The kernel supports to be built with gcc-9+ or clang-10+. As Link-Time-Optimization (LTO) for Clang is enabled by default (config: CONFIG_LTO_CLANG), building the kernel with GCC directly will result in build errors. In conclusion, it's recommended to choose Clang as your toolchains for both faster build speed and better performance.
    • As VDSO compat is enabled (config: CONFIG_COMPAT_VDSO), both arm and arm64 toolchains are needed to build the kernel. Clang could handle different cross compile targets easily (thanks to LLVM), but GCC could not. Also, though the kernel sources are compiled by clang, they will be linked by LD (included in GCC toolchains -> Binutils) with LLVM plugins. In conclusion, if the ROM you are building provides legacy gcc-4.9 toolchains (like LineageOS based projects), it should be safe to go ahead without installing GCC toolchains or Binutils. Otherwise, you need to install both Binutils and Clang packages in your computer to avoid build problems.
    • If you are using Ubuntu or Debian on your computer, please install the following packages (choose one way).
      • Using prebuilt toolchains in Android repo (recommend): sudo apt install libc6-dev libgcc-12-dev
      • Using toolchaings in your distribution: sudo apt install clang llvm-dev
      • For ROMs without legacy gcc-4.9 toolchains: sudo apt install binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf
    • Then you should be able to build the kernel without modifying build configs.
      • Build kernel image only: make bootimage
      • Build recovery image only: make recoveryimage
  • Apply custom changes (optional)
 
Last edited:

prazola

Senior Member
Jun 24, 2013
112
21
Xiaomi Mi 4C
This is great. Is signature spoofing enabled? If not, could it be? MicroG users would like it. Ty.

Edit: signature spoofing is enabled, but It seems LineageOS 17 locked my bootloader.

Edit2: LineageOS 17 do not support custom partition tables. After flashing, my 2.3gb "system" goes to 1.8gb and there's no space left for NanoDroid and other mods.
 
Last edited:

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Flashed ok, seems to be working just fine, but can't install gapps due to "insufficient space"
Any advice?

Right, there is really no enough free space in "/system" to install GAPPs (even the "pico" version). If Chinese/Japanese/Korean is not your main language, try to delete "/system/fonts/NotoSansCJK.ttc" to save 117MB free space, which seems enough for the "nano" version.
 
  • Like
Reactions: haytona

rostopira

Member
Dec 4, 2016
19
8
26
Minsk
Right, there is really no enough free space in "/system" to install GAPPs (even the "pico" version). If Chinese/Japanese/Korean is not your main language, try to delete "/system/fonts/NotoSansCJK.ttc" to save 117MB free space, which seems enough for the "nano" version.

Thanks for advice, I've removed it, but still not enough space even for pico package
Code:
/system/system # df -h
Filesystem                Size      Used Available Use% Mounted on
tmpfs                   888.2M    176.0K    888.0M   0% /dev
tmpfs                   888.2M     24.0K    888.1M   0% /tmp
/dev/block/mmcblk0p44
                         11.2G      2.9G      8.1G  26% /data
/dev/block/mmcblk0p44
                         11.2G      2.9G      8.1G  26% /sdcard
/dev/block/mmcblk0p42
                        372.0M    440.0K    363.9M   0% /cache
/dev/block/mmcblk0p41
                          1.8G      1.7G    178.0M  90% /system

UPD: Removed some other noto fonts, symlinked to roboto, deleted ringtones. Got 202M free
I really hope, that won't result in a bootloop

UPD2: It booted, immediately restarted, and booted again successfully
Feels good)
 
Last edited:

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Thanks for advice, I've removed it, but still not enough space even for pico package
Code:
/system/system # df -h
Filesystem                Size      Used Available Use% Mounted on
tmpfs                   888.2M    176.0K    888.0M   0% /dev
tmpfs                   888.2M     24.0K    888.1M   0% /tmp
/dev/block/mmcblk0p44
                         11.2G      2.9G      8.1G  26% /data
/dev/block/mmcblk0p44
                         11.2G      2.9G      8.1G  26% /sdcard
/dev/block/mmcblk0p42
                        372.0M    440.0K    363.9M   0% /cache
/dev/block/mmcblk0p41
                          1.8G      1.7G    178.0M  90% /system

UPD: Removed some other noto fonts, symlinked to roboto, deleted ringtones. Got 202M free
I really hope, that won't result in a bootloop

UPD2: It booted, immediately restarted, and booted again successfully
Feels good)

It seems you're using lineage-17.0 roms, which needs more free space than 16.0 (eg. the APEX image).
Deleting the fonts that you never used is surely a way to get more space. If you have installed "Android System Webview" (com.google.android.webview) from play store or other origins, removing the prebuilt one from "/system/product/app/webview" should be another possible solution (get another 100MB). However, make sure to choose the new webview package in "Developer settings" and prevent factory reset unless flashing the rom again, or it might result in problems.
 
Last edited:

elna.nitz

Senior Member
Oct 19, 2014
98
12
Hello, everyone.
I use TWRP 3.1.1.0 and get error 7
When I try Flash latest official TWRP / or twrp 3.3.0 from here via fastboot I can't boot to recovery.
Which version of TWRP do I need to use to flash Lineageos 17?

Thanks
 
Last edited:

elna.nitz

Senior Member
Oct 19, 2014
98
12
Try this recovery: https://androidfilehost.com/?fid=1395089523397945946
It's just the one I used on my device.

Yes, I already tried that after installing TWRP from your posted link I'm stuck on icon Xiaomi and the device doesn't get into recovery. It must be noted that before that I used Lineageos 13 and already did wipe system & Chache & Dalvic & Data.
Only when I flash TWRP 3.1.1.0 from here (twrp from lollipop - nougat bootloader) I manage to get into the Recovery, the problem then I get eror 7 when I try to flash Lineageos 17.
It must be noted that before that I used Lineageos 13 and already did wipe system & Chache & Dalvic & Data. So now I am without an operating system, only recovery.
 

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Yes, I already tried that after installing TWRP from your posted link I'm stuck on icon Xiaomi and the device doesn't get into recovery. It must be noted that before that I used Lineageos 13 and already did wipe system & Chache & Dalvic & Data.
Only when I flash TWRP 3.1.1.0 from here I manage to get into the Recovery, the problem then I get eror 7 when I try to flash Lineageos 17.
It must be noted that before that I used Lineageos 13 and already did wipe system & Chache & Dalvic & Data. So now I am without an operating system, only recovery.

It seems you are using the old bootloader of Android 5.x, but it doesn't support new ROMs after all. To upgrade to the new bootloader, you must have access to officially unlock your device, then flash the latest MIUI and boot one time (it will make sure you could unlock your bootloader).
Use the unlock tool here (official solution): https://www.miui.com/unlock/index.html
If you have other ways to unlock the new bootloader without the official method, it's also right. It may take you some time to get the official permission (from Xiaomi) to unlock the device, good luck!
 

elna.nitz

Senior Member
Oct 19, 2014
98
12
It seems you are using the old bootloader of Android 5.x, but it doesn't support new ROMs after all. To upgrade to the new bootloader, you must have access to officially unlock your device, then flash the latest MIUI and boot one time (it will make sure you could unlock your bootloader).
Use the unlock tool here (official solution): https://www.miui.com/unlock/index.html
If you have other ways to unlock the new bootloader without the official method, it's also right. It may take you some time to get the official permission (from Xiaomi) to unlock the device, good luck!
Thanks a lot, how do I flash latest MIUI? From TWRP?
Where do I download the latest MIUI file?
 

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Thanks a lot, how do I flash latest MIUI? From TWRP?
Where do I download the latest MIUI file?

To flash the latest MIUI, this official document may help you: https://www.miui.com/shuaji-393.html
If you don't want to flash MIUI, but have the permission to unlock your device (IMPORTANT!), just flash the latest firmware and the new TWRP, then reboot to fastboot and unlock your phone.
If anything went wrong during the second way, your phone will be not able to boot unless flashing MIUI. If you just failed to unlock your device, but flash the new firmware and TWRP successfully before reboot, you will still have chance to boot into the recovery and flash the new rom with "locked bootloader".
 

elna.nitz

Senior Member
Oct 19, 2014
98
12
To flash the latest MIUI, this official document may help you: https://www.miui.com/shuaji-393.html
If you don't want to flash MIUI, but have the permission to unlock your device (IMPORTANT!), just flash the latest firmware and the new TWRP, then reboot to fastboot and unlock your phone.
If anything went wrong during the second way, your phone will be not able to boot unless flashing MIUI. If you just failed to unlock your device, but flash the new firmware and TWRP successfully before reboot, you will still have chance to boot into the recovery and flash the new rom with "locked bootloader".
I can get permission to open the device only after connecting to my MI account through the device when installed on it official miui.
Therefore I seem to have previously had flash latest MIUI then log in to MI account and submit a request to open bootloader. Am I right?
 

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
I can get permission to open the device only after connecting to my MI account through the device when installed on it official miui.
Therefore I seem to have previously had flash latest MIUI then log in to MI account and submit a request to open bootloader. Am I right?

Yes, if you want to unlock your device. A Mi account is needed to do this, on the latest MIUI version (if stable version "10.1.1.0" doesn't work, the develop version of MIUI is needed).
 

elna.nitz

Senior Member
Oct 19, 2014
98
12
To flash the latest MIUI, this official document may help you: https://www.miui.com/shuaji-393.html
If you don't want to flash MIUI, but have the permission to unlock your device (IMPORTANT!), just flash the latest firmware and the new TWRP, then reboot to fastboot and unlock your phone.
If anything went wrong during the second way, your phone will be not able to boot unless flashing MIUI. If you just failed to unlock your device, but flash the new firmware and TWRP successfully before reboot, you will still have chance to boot into the recovery and flash the new rom with "locked bootloader".
Ok
I flashed latest firmware and TWRP 3.3.0, then Unlock bootloader with Mi Unlock.
Then flashed Lineageos 17 successfully.
The problem is that when I try to flash Gapps pico I get eror 70...
I tried to search for the font folder in the system path in TWRP File explorer and I couldn't find it (System Folder is empty) .
I tried reboot to system anyway, and after a long boot with the logo of the Lineageos 17, device initializing itself back to Recovery.
What else can we do?
 

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Ok
I flashed latest firmware and TWRP 3.3.0, then Unlock bootloader with Mi Unlock.
Then flashed Lineageos 17 successfully.
The problem is that when I try to flash Gapps pico I get eror 70...
I tried to search for the font folder in the system path in TWRP File explorer and I couldn't find it (System Folder is empty) .
I tried reboot to system anyway, and after a long boot with the logo of the Lineageos 17, device initializing itself back to Recovery.
What else can we do?

The latest version of lineage-17.0 could boot properly (tested my self). However, you flash the GAPPs and got interrupted halfway, which may cause some strange issues.
To fix this, format "/system" and flash the rom again. After that, mount "/system" manully in TWRP, then you could modify "/system" with the TWRP file manager.
There is another way to solve the GAPPs problem: If you're using magisk, try some modules that could install GAPPs without modifying "/system" (eg. "Weeb GAPPs"). Android 10 takes more free space in "/system" than Android 9 at present, even if without the fonts, it still has possibility that makes the GAPPs installation failed (this way works in lineage-16.0, which has 2.5× free space than 17.0).
 

elna.nitz

Senior Member
Oct 19, 2014
98
12
The latest version of lineage-17.0 could boot properly (tested my self). However, you flash the GAPPs and got interrupted halfway, which may cause some strange issues.
To fix this, format "/system" and flash the rom again. After that, mount "/system" manully in TWRP, then you could modify "/system" with the TWRP file manager.
There is another way to solve the GAPPs problem: If you're using magisk, try some modules that could install GAPPs without modifying "/system" (eg. "Weeb GAPPs"). Android 10 takes more free space in "/system" than Android 9 at present, even if without the fonts, it still has possibility that makes the GAPPs installation failed (this way works in lineage-16.0, which has 2.5× free space than 17.0).
Ok, I deleted the Notosansjfk.ttc from fonts & android viwe system app, And now I am able to flash Gaaps pico and boot to system.
But when I run the system and try to get to the System User Interface Launcher course, you can't use your device. Probably happened because I deleted the font or the Android view system..
Any solutions?
 

WJXXBSH

Senior Member
Dec 22, 2018
165
86
Xiaomi Mi 4C
Xiaomi Mi Mix 2
Ok, I deleted the Notosansjfk.ttc from fonts & android viwe system app, And now I am able to flash Gaaps pico and boot to system.
But when I run the system and try to get to the System User Interface Launcher course, you can't use your device. Probably happened because I deleted the font or the Android view system..
Any solutions?

You deleted the "Android System Webview" without installing a new one? That's not a good news after all, because every APP that contains webview will crash. The CJK font will not cause any serious problems, just make some words a "◻".
As a solution, if you could use Play Store, just install "Android System Webview" from there. Otherwise, you could still install one through ADB.
Download the webview app here (if Play Store not working): https://www.apkmirror.com/apk/googl...em-webview-78-0-3904-108-android-apk-download
 

elna.nitz

Senior Member
Oct 19, 2014
98
12
You deleted the "Android System Webview" without installing a new one? That's not a good news after all, because every APP that contains webview will crash. The CJK font will not cause any serious problems, just make some words a "".
As a solution, if you could use Play Store, just install "Android System Webview" from there. Otherwise, you could still install one through ADB.
Download the webview app here (if Play Store not working): https://www.apkmirror.com/apk/googl...em-webview-78-0-3904-108-android-apk-download
Finally I installed Weeb Gapps magisk Moudle, and The majority are fine.

There are 2 problems:

1. The device feels very lag in the opening of the apps and in the transition between them.

2. After restart takes the device nearly 2 minutes to find a cellular network
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    DESCRIPTION
    Unofficial LineageOS ROMs for Mi-4c (libra) and Mi-4s (aqua), with base-layer enhancements and performance optimizations. Version 15.1/16.0/17.1/18.1 are available for download.

    FEATURE
    The following items may not be available for all versions, please use the latest build!
    • Build with user variant instead of userdebug (to reduce image size and improve performance).
    • CPU/GPU is overclocked with optimized voltage/bus-cci and 300 Hz/Jiffies kernel clock frequency. [16.0 +]
    • EAS (sched cpufreq governor from linux-3.18) CPU scheduler implemented. [16.0 +]
    • Full-weight NotoSansCJK fonts included (to display East Asian characters with more font weights).
    • High screen refresh-rate (75 Hz) support for Mi-4c with "Sharp-rsp61322 LCD" screen. [16.0 +]
    • Implement ZRAM with ZSTD crypto algorithm (KSM is used after 20210116) to improve I/O performance on devices with 2GB RAM. [16.0 +]
    • Linux kernel is built by clang-12 toolchains, with Polly + LTO + -Ofast optimization to get better performance. [17.1 +]
    • Pre-dex2oat with everything filter globally (sacrificing space and first-install time to improve efficiency).
    • Remove or disable unnecessary kernel configs and modules, also includes some other optimizations. [16.0 +]
    • Remove unnecessary apps/binaries/libraries/services from system. [16.0 +]
    • Signature spoofing support (ready for MicroG, including Chinese translations).
    • User-friendly controller for special features in Settings app (like CPU overclock, Edge gesture and Screen refresh rate). [17.1 +]
    • ...

    STATUS
    Go to GitHub Issues for more details and give me feedback.
    • Working
      • Basic hardware
        • Baseband/SMS
        • Bluetooth
        • Camera/Flashlight
        • IR remote
        • Speaker/Microphone
        • Wi-Fi
      • Extras
        • Camera API2 (with patch) [17.1 +]
        • Edge gesture (in Settings > System > Buttons) [16.0 +]
        • Overclock control (in Settings > Battery > Battery saver and performance) [17.1 +]
        • Screen refresh rate (in Settings > Display) [17.1 +]
    • Not working
      • SELinux permissive [16.0 +]
      • VOLTE (won't fix because of no compatible IMS stacks) [16.0 +]

    DOWNLOAD

    SOURCE

    Thanks to all developers and users (Gah0 | Mortezadadgar | Xiaomi classic dev | ...) who contributed to Mi-4c/Mi-4s (including other devices shipped with MSM8992/8994 SOC) or gave me help!
    7
    TIPS
    Here are some tips which may improve your experience or resolve some problems.
    • Basic quality assurance: I only have one smart phone (3+32GB Mi-4c ×1), so the ROMs here should at least satisfy my daily usage.
      • This project will be kept maintained even after I bought my new mobile phone (8+128GB Mi-Mix-2 ×1) in 2021. My Mi-4c is one of the most meaningful items of my own, it's not easy to leave it behind in the drawer and say goodbye. The new battery and rear cover (thanks to yipinghuang1991) will refresh this old device and make it usable again.
    • Even though the signal icon in status bar shows "No signal" at the first minute after boot, the device is still able to receive SMS and phone calls (so the device does have signal, but the system doesn't admit it at all).
    • If the free space in /system is not enough to install GAPPs, try to delete /system/fonts/NotoSansCJK.ttc to get about 100MB free space (If Chinese/Japanese/Korean is not your main language). Removing the prebuilt Webview packages (about 120MB) after installed another one is also a solution.
    • If you found random reboot on your device with overclock enabled (or just updated to lineage-17.1-20201216 and left overclock option unchanged), please disable this feature to see if this issue is resolved. Go to Settings > System > Battery > Battery saver and performance, enable then disable "High performance mode", and reboot your device. If you are using lineage-17.1-20210209 or newer, it's no need to do such steps after a clean install (as both persist.sys.cpu_overclock and persist.vendor.edge_touch_mode are default to false by default).
    • It's highly recommended to disable system logs to reduce resource consumption (for better performance and privacy), unless you're going to collect system logs. Go to Settings > System > Developer options, and set the value of "Logger buffer sizes" to off.
    • It's not recommended to use SELinux enforcing mode even if it's supported in some builds. Also, please consider the negative effect of I/O performance before enabling disk encryption, unless you really want to.

    BUILD
    As all source codes and custom changes in my LineageOS ROMs are open-source, you are permitted to build your own ROM or kernel (not only for LineageOS) with my sources for non-commercial purpose.

    There are many documents about how to build custom Android ROMs in Linux/OSX, so I will not post these basic steps here to reduce redundancy. However, there are still some important things which may not be included in other documents. Here are some basic steps about what you should do (using lineage-18.1 as example), you can also take a reference to other tutorials.
    • Install necessary packages
      • There are a number of "necessary" packages listed in most tutorials, but not all of them are needed. Here are the packages you need to install manually on Ubuntu or Debian.
        • sudo apt install bc bison git gnupg make repo rsync unzip zip
    • Sync Android sources
      • You need to download and update your local repo with upstream sources regularly, in order to get new changes as soon as possible (just like other open-source projects).
        • Init repo to current directory: repo init -u https://github.com/LineageOS/android.git -b lineage-18.1 --depth=1
        • Sync all repos and prune unused branches: repo sync --prune
      • If nothing wrong happened, the LineageOS sources have been downloaded to your computer (about 100GB). Here are some commands which might be useful in the future.
        • Show all local changes of your repos: repo status or repo diff
        • Perform any operations to all repos: repo forall -c "xxx"
    • Setup local manifest
      • To sync your Android sources with upstream repos easily, it's recommended to create a local manifest in ./repo/local_manifests/. The local manifest should be a XML file like the following one, any filename is accepted (file: libra.xml).
        XML:
        <?xml version="1.0" encoding="UTF-8"?>
        <manifest>
          <project name="BYZYB/android_device_xiaomi_libra" path="device/xiaomi/libra" remote="github" revision="lineage-18.1" />
          <project name="BYZYB/android_kernel_xiaomi_libra" path="kernel/xiaomi/libra" remote="github" revision="master" />
          <project name="BYZYB/android_vendor_xiaomi_libra" path="vendor/xiaomi/libra" remote="github" revision="lineage-16.0" />
          <project name="LineageOS/android_hardware_sony_timekeep" path="hardware/sony/timekeep" remote="github" revision="lineage-18.1" />
          <project name="LineageOS/android_hardware_xiaomi" path="hardware/xiaomi" remote="github" revision="lineage-18.1" />
        </manifest>
    • Resolve build errors
      • Due to some hacks in my device configurations which are conflict with Android build rules, there might be some build errors if using all my repos directly. To resolve this issue, you need to modify project build/make/manually on your disk. After that, you should be able to prepare the necessary environment for Android build without errors.
        • Setup build namespace only: . build/envsetup.sh
        • Prepare build environment for Mi-4c with a specified build variant (xxx = eng/userdebug/user): . build/envsetup.sh && lunch lineage_libra-xxx
      • If you want to build the ROM in "user" build variant instead of the default "userdebug", more changes are needed to avoid build errors or potential bootloop. The following commands are some ways to build a full ROM.
        • Build full ROM in "user" variant: brunch lineage_libra-user
        • Build full ROM in "userdebug" variant: brunch lineage_libra-userdebug
        • Build full ROM with a specified number of threads (x ≤ physical CPU cores): lunch lineage_libra-xxx && make -jx
        • If you have lunch before, here is the simplest way: m
      • As git patch files are similar to git diff, you can always do these changes manually without using git am xxx.patch && git reset HEAD^ or other shell commands.
    • Kernel build toolchains
      • The kernel supports to be built with gcc-9+ or clang-10+. As Link-Time-Optimization (LTO) for Clang is enabled by default (config: CONFIG_LTO_CLANG), building the kernel with GCC directly will result in build errors. In conclusion, it's recommended to choose Clang as your toolchains for both faster build speed and better performance.
      • As VDSO compat is enabled (config: CONFIG_COMPAT_VDSO), both arm and arm64 toolchains are needed to build the kernel. Clang could handle different cross compile targets easily (thanks to LLVM), but GCC could not. Also, though the kernel sources are compiled by clang, they will be linked by LD (included in GCC toolchains -> Binutils) with LLVM plugins. In conclusion, if the ROM you are building provides legacy gcc-4.9 toolchains (like LineageOS based projects), it should be safe to go ahead without installing GCC toolchains or Binutils. Otherwise, you need to install both Binutils and Clang packages in your computer to avoid build problems.
      • If you are using Ubuntu or Debian on your computer, please install the following packages (choose one way).
        • Using prebuilt toolchains in Android repo (recommend): sudo apt install libc6-dev libgcc-12-dev
        • Using toolchaings in your distribution: sudo apt install clang llvm-dev
        • For ROMs without legacy gcc-4.9 toolchains: sudo apt install binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf
      • Then you should be able to build the kernel without modifying build configs.
        • Build kernel image only: make bootimage
        • Build recovery image only: make recoveryimage
    • Apply custom changes (optional)
    2
    I want to flash this rom on my Mi4C, but cant get it to flash.
    i'm not sure what i do wrong.

    1. I installed the latest official twrp from twrp.me (version 3.1.1.-1).
    2. Downloaded the .zip file lineage-18.1-20210623-UNOFFICIAL-libra from github.
    3. Did a full wipe.
    4. Tried to flash the .zip file.

    The TWRP error is:

    E3004: This package is for device: 4C,libra; this device is .
    Updater process ended with ERROR: 1
    Error installing zip file '/sdcard/rom/lineage-18.1-20210623-UNOFFICIAL-libra.zip'


    It seems like TWRP doesn't know it is a Mi4C or something.
    Can anyone help me?
    Could you try this version of TWRP recovery (3.1.1 is too old)? Also, you need to unlock your Mi-4c with official method and flash the latest firmware before using this ROM.
    2
    Thanks for the fast reply. So it's not possible to disable the pop up without updating to LineageOS 17? It's not a big issue but I want to be sure.

    Technically, yes. We cannot get rid of the pop-ups unless disabling permission review. You may try to decompile framework-res.apk (or generate a RRO overlay to override default configs), find "config_permissionReviewRequired" in "res/values/config.xml" and set it to "false".
    2
    :good: :victory: Finally, my phone do no longer randomly reboots.
    I reduced the speed to around 144k with a root app called "CpuSpeed". Thanks for the important note!

    If CPU/GPU overclock is the reason that caused random reboot (it's surely possible), it means the CPU (or msm8992 SOC) in some devices has different hardware quality than others (just as the screen: only some of them support 75Hz refresh rate, others will stop working). That's why this problem doesn't happens to all Mi-4c/4s (My device doesn't reboot even when overclocking the big cores to 1.8GHz).