All posts by Manoj Nair

Hi, My name is Manoj Nair. I am based in Mumbai, India. I have been working in the IT industry for the last two decades. Before that I was working with the Government of India and was lucky enough to be posted in some of the remote corners of India. I love working with computers and dabble in a little bit of programming. On the wrong side of fifty, I sincerely believe that learning never stops. Recently I started brushing up my programming skills and found that I enjoyed the experience more than ever. I am working with a young, vibrant team at /e/OS, a user data-privacy-respecting android operating system. I jot down points that I come across during my work or tips I find useful while fooling around with my PC and post them here When free, I write short stories all of which you can read here Thanks for stopping by and have a great day !!!

A Noob’s guide to building a Lineage ROM

As the title mentions, this is a guide by a noob which spells out the steps that build a lineage ROM. What the title does not mention is that this article is aimed at noobs as well. Now lets get down to business.

Disclaimer: Please note that by following the steps as mentioned in this article you can seriously damage your smart phone. There is good chance your phone would be bricked i.e. effectively be rendered useless and cause a lot of frustration, irritation and make you pull at your hair. If you hit that point later, Please do not look towards me to save you since I am also new to this and like you learning how to traverse this parallel universe of custom ROM development. That being said do not despair. As the saying goes browse and you shall find – Check out the internet and you would find others who have messed up their smartphones and yet somehow lived to tell the tale. In most cases you would be able to revive your phone. Ideally do not use your daily driver for such experimentation.

After reading all this if still want to go ahead then read on.
Objective:
Build a custom lineage ROM for your smart phone. I own a Xiaomi MiA1 and used the same as my target phone. You may have a different model but technically the build steps should be the same for all android phone models.

Requirements:
A linux based or a Mac computer.
Windows computers do not directly support the tools required for this type of development. As such they are not being covered in this article.
The recommended operating system is Ubuntu.

Other requirements:

  1. A basic understanding of Linux based OS specifically Ubuntu.
  2. Ability to type and use the command line. Write or copy paste commands in the Ubuntu konsole.
  3. A basic understanding of programming concepts, read and update XML files, understand error messages.
  4. Fast internet access.
  5. Steady electricity supply.
  6. Lots and lots of patience.

You will understand why the last three requirement are mentioned as you read on

Hardware recommendations – ideally your system should exceed these conditions

  1. 64 bit environment
  2. 100 GB of free hard disk space
  3. 16 GB RAM / swap space.

My hardware configuration:

  1. Intel i5 processor
  2. 16 GB RAM
  3. 1 TB hard disk.
    Please note even with this configuration it takes me about 3 hours to build the code!
    Operating system:
    I used the Ubuntu 18.04 build which is the latest at the time of writing. I will be covering only the Ubuntu OS as part of this article as I do not have a Mac and as such it is out of scope for me!

Steps to build the Custom ROM from scratch
Step 1: Setup Ubuntu
Assuming you have set up the Ubuntu OS if not click this link for a detailed explanation of the installation of Ubuntu.
Step 2: Installation of Java Development Kit
In a console window type or copy past the below commands.
Wait for one line of command to execute before typing or pasting the next

sudo apt-get update
sudo apt-get install openjdk-8-jdk

Please note the sudo command will ask you to enter your password.

Step 3: Installing required packages ( this is a single line not multiple lines)

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip

Step 4: Configure your smart phone access

These tools will provide you access to the device once you have complete the

build and are ready to flash the Rom.

Step 5: Creating your work directories

Step 6: Installing Repo

The Android source tree is located in a Git repository and is hosted by Google. The Git repository includes metadata for the Android source. Repo is a tool that makes it easier to work with Git .

mkdir -p ~/bin

sudo apt-get install android-tools-adb

sudo apt-get install fastboot

mkdir -p ~//lineage

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

Next type below command to make repo executable.

chmod a+x ~/bin/repo

Step 7: Initialize your lineage source

Now change directory and move into the newly created lineage folder.
You can do this either by Opening nautilus and right clicking inside the lineage folder and selected ‘Open Terminal here’ or by typing the below command

cd ~//lineage

Important: Ensure you are in the lineage folder before executing the next set of commands

Step 8: Configure your Git user

You can set these on the GitHub website. Once you have set your GitHub web site

Type paste these commands. Replace the text within “ ” with your credentials.

git config –global user.name “Your Name”

git config –global user.email “you@example.com”

Step 9: Initialize the repo

repo init -u https://github.com/LineageOS/android.git -b lineage-15.1

A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.

Step 8: Download the source code

This is the step where you will realize the importance of having a fast internet connection. The source code size is about 30 – 35 GB. I have a 10 mbps line and at times the download speed shoots up to 20- 25 mbps!!!  Yet it takes me anything from 4 – 10 hours to download the code!
My suggestion is check the time when your local ISP download speeds are at its best. For me it is during the night. I set the download up at night and go to sleep!

The command to type paste to get the source code is :

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

Optional Step 8 a: Take a backup of your source code

I copy the entire folder and keep a copy on an external device. This is just in case there is any need for me to format my hard disk. I do not copy the .Repo and .Cache folders on to my backup. To check hidden folders press Ctrl + H.

Step 9: Get the source code for your specific device.

This is an important part to understand. The code which you downloaded is generic in nature. For your particular device you would need to get files which are specific to your device.
The source for all these files is github. You are targeting three sets of folders – Device, Kernel and vendor. The git clone commands given below are for the tissot or Xiaomi Mia1 phone. Similarly other phones have their locations on GitHub from where you can get files specific to them.

git clone https://github.com/TheScarastic/andr…msm8953-common -b lineage-15.1 device/xiaomi/msm8953

git clone https://github.com/TheScarastic/andr…_xiaomi_tissot -b lineage-15.1 device/xiaomi/tissot

git clone https://github.com/TheScarastic/prop…_vendor_xiaomi -b lineage-15.1 vendor/xiaomi

git clone https://github.com/Tissot-Developmen…_xiaomi_tissot -b 8.1 kernel/xiaomi/msm8953

The format of the command will remain the same for all phones only check the url and the folder names.

Step 10: Modify Caching to speed up the build process.

Type paste one command at a time and wait for it to execute before posting the next.

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

Step 11: Configure JACK

JACK is the java compiler and can cause crashes – believe me! A simple fix is this command which you type next
export _JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

Step 12: Cleaning up the build folder

make clean

Step 13: Initializing the build

source build/envsetup.sh

Step 14: Starting the build

croot
brunch tissot

Screenshot_Settings_20180705

Now sit back and wait for a few hours. Check the screen, occasionally for what is happening. There will a ton or warnings showing up.Do not worry about the warnings. Read the message displayed on the screen for clues as to what is happening.
The entire build took about 3 hours on my machine with nothing else running. This duration can increase and decrease based on the configuration of your build machine. It can also depend on the files downloaded during the Repo sync process.

Finally you will get the .iso file in a folder labeled out. Check the screen shot above. It shows the build settings screen. Have been using it as on my main driver and so far so good.

Handling Error messages:

There is a very good chance that the build will stop many times. When this happens read the error message and then try googling it. I can guarantee that there would be number of other people across the world who have faced similar issues while building their custom ROM’s. See what solutions have been suggested and try them out. It took me almost a week to get my first build right!
Then in the same day I got 2 builds in a row that were successful! It has a lot with having all the right files in the build environment + a good hardware configuration + lots of luck!

At times the error message which stopped the build could report that a particular file is not found in a particular folder. Do a search in the base lineage folder and see if the file is there in any other folder. Simply copy it to the folder where the build is expecting it. After that run the build commands again and restart the build.

Remember to use your default login. I used su – superuser and ran into trouble while doing a repo with the normal login. So I do not use su for the build and do the entire build and repo sync with my login.  Since i installed the system Ubuntu is satisfied with my credentials.

As I mentioned at the start this is my first shot at building a custom ROM. While there is not exactly much customization being done here as the source code is available on Lineage.com and the files specific to the device were shared by various developers on GitHub. All that I have done is that I downloaded the code and recompiled it on my machine. Having said that there is a sense of pride that you feel when you see your name in the settings tab!!!!

Hope this was a easy to understand guide to help noobs around the world do their own custom ROM development. This article is as I mentioned a guide, you should refer the links given below and get a complete understanding of the process of building ROM’s before you start on your own. So good luck with your custom ROM building!!!

Some important links which you should visit to understand how the experts do it.

Build ROM from source for Tissot 
The Android Source Code
How to build your own custom Android ROM

To download the build click the links below:
Please note that you are downloading and installing the build at your own risk. I will not be responsible for your phone bricking up and also will not be able to support you in case of any issues.

On a personal note I have been using the same build on my daily driver for the last couple of days with no issues. I have GApps installed and am able to use some 46 apps with no issues including Twitter, Whatsapp, Quora, XDA, WordPress among others. The phone camera and fingerprint features are working normally.

What Data Privacy is and why is it important

The purpose of this article is to explain what Data Privacy is and why is it important in layman’s terms. Of late most of us have seen a spurt of emails with the subject line mentioning updates to Data privacy policy. In my case the first one came from Xiaomi – since I own a phone of theirs, then another mail came from Google and now I see even my website hosting provider has issued one!

If you watch the news, you must have seen the videos of Mark Zuckerberg the founder of Facebook appearing before a committee of the US Senate last month. The events that led to this senate hearing occurred a couple of year’s back. It was a U.K based political consulting firm, Cambridge Analytica that triggered this sudden avalanche of interest in Data Privacy. Cambridge Analytica, combined data mining, data brokerage and data analytics to extract information from Facebook users.

The method adopted by Cambridge Analytica was rather simple. Through an application called ‘thisisyourdigitallife’ it asked Facebook users if it could collect their data. About 270,000 users volunteered and gave permission to the application to collect and share their data. Now with this approval and in violation of Facebook’s policies Cambridge Analytica gained access to the friend networks of these 270,000 users. Cambridge Analytica using this application illegally gained data on about 50 million users who were in the friend’s network of these 270,000. Remember that a majority of these 50 million, had not explicitly allowed Cambridge Analytica permission to access their personal data.
The data collected basically related to the user behaviour and browsing patterns. It analysed political leaning of the user and accordingly targeted segments of Facebook users with what it called ‘Strategic Communications’. While many mainstream political scientists question CA’s claims about the effectiveness of its methods of targeting voters the matter was considered serious enough by most governments of the world to suspend its operations in their territories.

By its own admission Cambridge Analytica declared that they were involved in 44 US political races in 2014. In 2015, CA admitted it performed data analysis services for Ted Cruz’s presidential campaign in the US. In 2016, CA claimed to have worked for Donald Trump’s presidential campaign as well as the ‘Leave.EU-campaign’ for the United Kingdom’s referendum on European Union membership. CA’s role in those campaigns has been controversial and is the subject of ongoing criminal investigations in both countries. As the bad press and negative publicity from all these disclosures reverberated across the world, on 1 May 2018, Cambridge Analytica and its parent company filed for insolvency and closed operations.

Now does that mean that all is well and the world is a better place to live in… well actually no. There are still some huge monsters out there and they are not hiding under the bed but still using your data and making money out of it. The worst part of it is that we are willingly providing our approval to these ‘monsters’ to collect and use our personal data.

Most of us own smart phones. Every time we install an application on our phones it innocently asks us permission to access the camera, microphone, contact list, folders etc, etc. We have become so used to these requests that we hardly read them and approve the request. That is when the problem starts.
Google, Amazon, Microsoft and Apple are the giants in the tech world. Today we have reached a stage where we are totally dependent on their application, products and tools. If you do not believe me try this simple test. Try removing or not using google products on your android phone for a day. This would mean not using Gmail, You Tube, Google Maps among other applications which you downloaded from Google Play. It would be next to impossible given our dependence on Google and other such companies for most of our mundane internet work. Be it sending or receiving emails, browsing websites, purchasing or selling products online we are puppets in the hands of these massive tech giants.

Now consider this scenario. Assume you want to buy a shoe. You do not have the time to go to the local shoe store, or maybe the design or make you are looking for is not available locally. The first thing you would do is open up your browser and search for the brand of your choice. We would search through Google or check out the options available on Amazon or other similar online retailers. Once you have searched you may or may not decide to purchase the shoe online. Suppose in our scenario you do not go ahead with the online purchase but decide to purchase it locally. As far as you are concerned the matter of the shoe is closed, right? Well the internet and these massive companies do not think so. After this, for a few weeks if you are observant you will notice that as you log on to any web site, you would see advertisements for shoes showing up on the sides of the pages you are browsing. This goes on for a few days. Ever wondered why that happens?

This happens because the information that you had browsed the web, searching for shoes is captured by your browser and passed on by the Googles and Amazon’s of the world. They in turn pass it on to the various web sites which sell these products. IN this way these advertisements customized for your requirements start appearing on to your web browser. If you happen to notice the ad and go ahead and click on it that takes you to the shop where you can buy the shoes. In case you make a purchase then a commission from the sale goes to all these intermediaries who essentially tricked you into buying their product. In essence the internet search engines and business portal make billions out of millions of users like you and me. Now how does that feel? Do you feel cheated or you are ok with being spied upon?

In the above scenario it was a simple shoe now imagine if you happened to browse a porn site or purchased some lingerie online. As a human being you have every right to do that. The problem is that information is also passed on to all the relevant companies who can target you in future. Imagine the case where the same PC or Laptop is shared between multiple people in the same house. How would you like it if your children or grandparent suddenly find their web site plastered by ads for such products? Another slightly dangerous aspect of this breach of data privacy is that organizations where you apply for jobs may want to check you background through your internet searches. The fact that you have in the past browsed such sites will make you un-fit to get jobs.

Then there is another side to this whole story. A lot of website propound extremist ideologies and display information about how to make explosives or propound violence. This browsing information has in the past been used by police organizations to track and arrest operatives from perpetrating acts of violence and mayhem. By tracking onsite browsing data, intelligence organizations have been able to find such criminals before they could put their plans into action. There are specific group who search the web for people who visit child- pornography sites or have such information. Such investigative work has resulted in the arrest across the world. While this is a positive aspect of such data collection it should be remembered that there is a fine line between protection and harassment and too often government agencies tend to overstep their limits and monitor citizens above and beyond what is permissible. Examples are the extreme cases of censorship applied by the Chinese government.
All this bring us to the question as to what is it that we as citizens do to protect ourselves from such blatant violation of our privacy. One way is read carefully the pop-up that come up when you install applications on your cell phones. If you feel that it is too intrusive do not accept it. Find alternative applications and products that respect your privacy and do not intrude into your private life. We will be publishing details of such applications and tools on this web site. Keep reading and stay safe!

How To-Set up Fastboot on your device

Tip: Disable any security keys, patterns or passwords you have set on your device before trying out any installations. Having a password or lock can cause issues in some installations.You can always set them up later.

Through the PC:

  • Connect your device to an adb enabled PC
    An adb enabled PC is a PC where adb has been installed and is working.
  • Type the below command in a console to check your device is detected by the adb installation

    adb devices
  • This should display a screen like this

this screenshot is from a PC with ubuntu

  • If your console shows an alpha numeric value along with ‘Device’ that would mean you device has been detected
  • If the screen shows unauthorized then it would mean you need to tweak developer options on your PC…check the steps here
  • If the device has been detected then type the below command to reboot to fastboot mode

    adb reboot bootloader
  • This would reboot the device into the bootloader or fastboot mode . On xiaomi devices the device screen would look like this

Through the device keys

Another way to go to the bootloader screen directly from your device is to use the device keys.

The difference between this and the previous method is that this one does not require and adb enabled PC.

This method also requires you to be nimble and may not always work perfectly. Requires a couple of tries to get it right.

Here all you do is browse and find out the correct combination for your device

For example check out this set of key combinations for Google and a few Samsung devices

or search for each device and then check for the device specific boot model.
For e.g. here you can find the Recovery and Download modes for the Xiaomi Mi A1 tissot

How To – Install adb and fastboot

This post only covers the installation of adb or fastboot on windows , mac or linux systems. To set up adb or fastboot scroll to the end to find links or click here

Tip: Disable any security keys, patterns or passwords you have set on your device before trying out any installations. Having a password or lock can cause issues in some installations.You can always set them up later.

On Windows PCs

  • Download the Windows zip from Google.
  • Extract it to a folder on your system – for example, %USERPROFILE%\adb-fastboot
  • On Windows 7/8:
    • From the desktop, right-click My Computer and select Properties
    • In the System Properties window, click on the Advanced tab
    • In the Advanced section, click the Environment Variables button
    • In the Environment Variables window, highlight the Path variable in the Systems Variable section and click the Edit button
    • Append ;%USERPROFILE%\adb-fastboot\platform-tools to the end of the existing Path definition (the semi-colon separates each path entry)
  • On Windows 10:
    • Open the Start menu, and type “advanced system settings”
    • Select “View advanced system settings”
    • Click on the Advanced tab
    • Open the “Environment Variables” window
    • Select the Path variable under “System Variables” and click the “Edit” button
    • Click the “Edit Text” button
    • Append ;%USERPROFILE%\adb-fastboot\platform-tools to the end of the existing Path definition (the semi-colon separates each path entry)
  • Install the universal adb driver, and reboot.

On macOS

  1. Download the macOS zip from Google.
  2. Extract it to a folder on your system – for example, ~/adb-fastboot.
  3. Add the following to ~/.bash_profile:if [ -d "$HOME/adb-fastboot/platform-tools" ] ; then export PATH="$HOME/adb-fastboot/platform-tools:$PATH" fi
  4. Log out and back in.

On Linux

  1. Download the Linux zip from Google.
  2. Extract it to a folder on your system – for example, ~/adb-fastboot.
  3. Add the following to ~/.profile:if [ -d "$HOME/adb-fastboot/platform-tools" ] ; then export PATH="$HOME/adb-fastboot/platform-tools:$PATH" fi
  4. Log out and back in.
  5. You may also need to set up udev rules: see this repository for more info.


    Click here to learn how to set up adb or fastboot

OEM unlocking and enabling developer options

Every wondered what Enabling OEM unlocking Developer options means? This is a simple step by step guide which will help you with enabling OEM unlocking Developer options for android phones.

In case you are wondering why you even need to do all this in the first place let us answer that as simply as is possible. You need to enable OEM unlocking and activate developer options in your android smart phone if and only if you want to install a custom ROM on your phone.
If you do not have any such plans then it is better you move to the short stories section on this website and read the stories there.

For those who dare to mess around with their smart phones read on….

Stage One: Downloading Google Platform tools

Download the latest version of the Google platform tools from the links given below. The link is the official link on the Android site. It has links for different operating systems.
https://developer.android.com/studio/releases/platform-tools
These tools are required to access the Fastboot features of your phone.

Follow the steps as described on the site to install on your PC. This is important as you would need the tools to be fully functional when running on your PC. To understand this step completely please read this post first.

If you have Google Platform tools on your PC and understand what they do then read on.

Stage Two : Enabling OEM unlocking and Developer options

Settings App

 

 

 

 

Step 1: On the smart phone go to Settings. It would be the gear shaped icon in the screen on the left.

 

Step 2: On Settings page scroll to the end of the screen to find the System link. Check image shot to the right. The system link is right at the bottom . System Link on the Settings App

 

 

 

 

 

System Screen DetailsStep 3: Open System >> Click on About Phone. Again the link is at the end of the screen. Somehow you will feel that they want us to miss these settings!

 

 

 

 

 

Step 4: Scroll to the end of the screen >> Build numberAbout Phone Screen

 

 

 

 

 

Step 5: Tap 7 times on Build number… yes, you read that right. Tap seven times on build number. By the third or fourth tap you will start getting a pop up which will mention in reverse the number of taps required out of seven!
Once you complete the mandatory seven taps  you would have enabled Developer options on the phone. If you have enabled a pattern lock it will show up to confirm it is you who want to enable Developer Options

About Phone with Developer OptionsStep 6: Go back to the System screen and now you should see a new option >>Developer options.
In the screenshot to the left see the option just above system update and below Backup.

 

 

 

 

 

Step 7: In Developer options screen select OEM unlocking. By default it would be grayed out. By selected it the option turns green!Developer Options with OEM unlocking enabled

 

 

 

 

 

 

Step 8: In Developer options screen select USB DebuggingDeveloper Options with USB Debugging enabled

That is it, you can now come back.

You have enabled USB debugging and OEM unlocking on your android smart phone.

Let the games begin 🙂

 

 

 

 

 

Read Articles on

Why install a custom ROM on a Xiaomi MiA1

OEM unlocking and enabling developer options

Unlocking the bootloader of Xiaomi phones

What are Google Platform Tools?

What are Google Platform Tools?

What are the Google Platform Tools? Well to put it simply they are a set of tools which are essential if you plan to mess around with your android smart phone. These set of tools interface with the android platform through tools like adb, fastboot and systrace. These are tools you would definitely need if you plan to install custom ROM’s on your android smart phones.

You can download the latest version of the Google platform tools from the link given below. The link is the official link on the Android site. It has links for different operating systems.

These tools are required to access the phone especially when you have messed up the Custom ROM installation. In case your phone is ‘dead’ or not responding. Please note these tools are common for all android phones.

Follow the steps as described on the site to install on your PC. This is important as you would need the tools to be fully functional when running on your PC.

Download the Google Platform Tools for various operating systems:

Windows

Mac

Linux

Extract the downloaded platform tools package to any folder you like (e.g. your home directory or the standard applications directory). Now you need to add this directory to the PATH of your operating system, enabling you to call the tools from any folder. Depending on your Operating system this can be achieved differently:

Windows

  • Download and install the Universal adb driver.
  • Press [WIN] + [PAUSE] to open the “System” window
  • On the left, click the “Advanced system settings” button
  • Open the “Advanced” tab
  • At the bottom of this tab, click the “Environment Variables” button
  • Edit the “PATH” variable and append a semicolon followed by the path you extracted your tools to (e.g. ;C:UsersAndyadb-fastbootplatform-tools)
  • Reboot your PC

MacOS/Linux

  • Depending on your distribution the “.bash_profile” or the “.profile” file in your home folder and add following lines substituing the path with the path where you extraced your tools
 if [ -d "$HOME/adb-fastboot/platform-tools" ] ; then
    export PATH=$HOME/adb-fastboot/platform-tools:$PATH"
 fi
  • Log out and back in

Read Articles on

Why install a custom ROM on a Xiaomi MiA1

OEM unlocking and enabling developer options

Unlocking the bootloader of Xiaomi phones

What are Google Platform Tools?