[Xiaomi Mi A1 Guides, News, & Discussion] arunassain:
What is ?

Android is the open-source operating system used for smartphones. Full Freedom for people using it

What is Source Code?

Android is an open-source software stack created for a wide array of devices with different form factors. The primary purposes of are to create an open software platform available for carriers, OEMs, and to make their innovative ideas a reality and to introduce a successful, real-world product that improves the mobile experience for users.The result is a full, production-quality consumer product with source code open for customization and porting.

So basically Allows to customize the things you like and make new things without any Restrictions. Cool isn’t it?

What is ROM ?

The ROM is the operating system. This is the User interface (Sense UI in HTC phones) and the file system for maintaining contacts etc. It is composed of a Linux kernel and various add-ons to achieve specific functionality.

What does a Rom Contain ?

Basically a Rom Contains following main things :

· Kernel

· Bootloader

· Recovery

· Radio

· Framework

· Apps

· core

· -runtime,Etc

Some Basics About Above Terms

Kernel :

A kernel is critical component of the and all operating systems. It can be seen as a sort of bridge between the applications and the actual hardware of a device. devices use the Linux kernel, but it's not the exact same kernel other Linux-based operating systems use. There's a lot of specific code built in, and Google's kernel maintainers have their work cut out for them. OEMs have to contribute as well, because they need to develop hardware drivers for the parts they're using for the kernel version they're using. This is why it takes a while for independent and hackers to port new versions to older devices and get everything working. Drivers written to work with the Gingerbread kernel on a phone won't necessarily work with the Ice Cream Sandwich kernel. And that's important, because one of the kernel's main functions is to control the hardware. It's a whole lot of source code, with more options while building it than you can imagine, but in the end it's just the intermediary between the hardware and the software. So basically if any instruction is given to mobile it first gives the command to kernel for the particular task execution.

Bootloader :

The bootloader is code that is executed before any Operating System starts to run. Bootloaders basically package the instructions to boot operating system kernel and most of them also have their own debugging or modification environment. Think of the bootloader as a security checkpoint for all those partitions. Because if you’re able to swap out what’s on those partitions, you’re able to break things if you don’t know what you’re doing. So basically it commands the kernel of your device to Boot the Device properly without any issues. So careful with bootloader since it can mess things very badly.

Recovery :

Recovery is defined in simple terms as a source of backup. Whenever your phone firmware is corrupted, the recovery does the job in helping you to restore or repair your faulty or buggy firmware into working condition. It is also used for flashing the Rom’s , kernel and many more things.

Radio

The lowest part of software layer is the radio: this is the very first thing that runs, just before the bootloader. It control all wireless communication like GSM Antenna, GPS etc.

What you’ll need

A relatively recent 64-bit computer (Linux, OS X, or Windows)(Virtual Machine will work as well) with a reasonable amount of RAM and about 100 GB of free storage (more if you enable ccache or build for multiple devices). The less RAM you have, the longer the build will take (aim for 8 GB or more). Using SSDs results in considerably faster build times than traditional hard drives.

A decent internet connection & reliable electricity :)

Some familiarity with basic operation and terminology. It would help if you’ve installed custom roms on other devices and are familiar with recovery. It may also be useful to know some basic command line concepts such as cd for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /, etc.

Install the SDK

If you haven’t previously installed adb and fastboot, you can download them from Google. Extract it running:

unzip platform-tools-latest-linux.zip -d ~

Now you have to add adb and fastboot to your PATH. Open ~/.profile and add the following:

# add SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi

Then, run source ~/.profile to update yur environment.

Install the build packages

Several packages are needed to build LineageOS. You can install these using your distribution’s package manager.

To build LineageOS, you’ll need:

bc bison build-essential curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev

For Ubuntu versions older than 16.04 (xenial), substitute:

libwxgtk3.0-dev → libwxgtk2.8-dev

Java

Different versions of LineageOS require different JDK (Java Development Kit) versions.

LineageOS 14.1: OpenJDK 1.8 (install openjdk-8-jdk)

LineageOS 11.0-13.0: OpenJDK 1.7 (install openjdk-7-jdk)*

https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher

Create the directories

You’ll need to set up some directories in your build environment.

To create them:

mkdir -p ~/bin
mkdir -p ~//lineage

Install the repo command

Enter the following to download the repo binary and make it executable (runnable):

curl [url]https://storage.googleapis.com/git-repo-downloads/repo[/url] > ~/bin/repo
chmod a+x ~/bin/repo

Put the ~/bin directory in your path of execution

In recent versions of Ubuntu, ~/bin should already be in your PATH. You can check this by opening ~/.profile with a text editor and verifying the following code exists (add it if it is missing):

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

Then, run source ~/.profile to update your environment.

Initialize the LineageOS source repository

cd ~//lineage
repo init -u [url]https://github.com/LineageOS/.git[/url] -b lineage-15.1

Download the source code

repo sync -c -f --force-sync --no-clone-bundle --no-tags --optimized-fetch --prune

Prepare the device-specific code

git clone [url]https://github.com/TheScarastic/android_device_xiaomi_msm8953-common[/url] -b lineage-15.1 device/xiaomi/msm8953
git clone [url]https://github.com/TheScarastic/android_device_xiaomi_tissot[/url] -b lineage-15.1 device/xiaomi/tissot
git clone [url]https://github.com/TheScarastic/proprietary_vendor_xiaomi[/url] -b lineage-15.1 vendor/xiaomi
git clone [url]https://github.com/Tissot-Development/android_kernel_xiaomi_tissot[/url] -b 8.1 kernel/xiaomi/msm8953

Turn on caching to speed up build

export CCACHE_DIR=./.ccache
ccache -C
export USE_CCACHE=1
export CCACHE_COMPRESS=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G

Configure jack

Jack is the new Java compiler used when building LineageOS 14.1. It is known to run out of memory - a simple fix is to run this command:

export _JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

Make Clean Build

make clean

Initialize the build command

source build/envsetup.sh

Start Build

croot
brunch tissot

For More info:

https://source..com/source/requirements

https://wiki.lineageos.org/devices/cheeseburger/build