Clear the Clutter on Xiaomi


Tired of the irritating bloatware on the Xiaomi phones? Not just irritating, it is scary when those apps demand irrational permissions. Like why should the notes application need permission to make phone calls? And why should the File manager want access to internet? Why does the so called security app pop up again and again, asking permission to do anything and everything? Is it really securing my phone? Or sealing my data? And what exactly is that msa, hanging out in memory?

It is true that Xiaomi is a reputed company that may not indulge in lowly practices. But.. You never know. I do not feel comfortable when I know there are Chinese apps on my phone, messing around with the phone. If they are not, then why do they need such permissions?

*** Please read the Disclaimer below. ***

Disable the Bloatware


I started with the simple techniques, to individually disable each of these apps, lock away all their permissions and installed alternatives - that are a lot more trustworthy.

  • Mi Notes replaced by Google Keep, or Evernote.
  • Mi Pay replaced by any of the several UPI apps.
  • SMS Messenger replaced by Microsoft SMS Organizer, or Facebook Messenger
  • Mi Contacts replaced by Google Contacts
  • Mi Browser replaced by Google Chrome, Firefox
  • Mi Video, Mi Music replaced by VLC
  • Mi Security replacedby McAfee

I went through the Permissions allocated in the Android Settings, and ensured I had disabled all the permissions for the Mi Apps.

I thought I was safe. But, soon I found that those apps had regained their permissions, and started popping up again. I got a notification that I had 1 GB of garbage in my internal memory and that could be cleaned if I gave it additional permissions. I got messages that my mobile was not secure, and it could be secured by allowing more permissions. The Notes app popped up again and again - out of nowhere - asking for permissions to make calls and view SMS.

Root the Device


I thought I had enough of it. So decided I would root the device and erase these apps one by one.

I looked around for ways to root the device. A lot of videos and blogs out there. But each one warned me the if I do, it will void my warranty. So what? I don't want Mi anyway. I don't need their warranty!

So I decided it is time I take the jump. The steps for rooting an android device:

  • Unlock the boot loader
  • Install the new Recovery ROM
  • Install a rooting App like Magisk

Simple! Well it is not so simple. Let's look at it in detail. First of all, make sure your phone is fully charged, so that it does not give up half way. That could be very bad.

Unlock the Boot Loader


Unlocking the boot loader is not as simple a task. You need to use an MI application for that! Well.. does that defeat the purpose? I thought let me try anyway. So I started with the process. This requires some steps on the phone and some steps on the PC.

Phone:


First step is to enable the developer options. That is a trivial task. Go to Settings -> About Phone -> Tap the version 7 times. And you are done! You have enabled the developer options.

Now, come back to the Settings menu. In Additional Settings, you will see a new entry. Developer options. In there.. enable all that you are allowed to enable. Specifically, enable the USB Debugging, Install via USB and OEM Unlocking. Make sure you have these enabled, else you might get into trouble.

Finally, enter the MI Unlock Status in the same menu. You will be prompted to log into the MI Account. If you have not done before.. create an MI Account and login. You have a long message there, essentially warning you that you are about to commit a grave sin. Ignore that and click on Accept and "Add account and device"

It insists that you connect via mobile data, login with Mi account, etc. Follow those steps - you have no choice. Finally, you will get an approval.

Finally, enter the Fasboot Mode. Switch off your phone. Then press the Volume Down button. With this pressed, press the power button. Hold it till the phone vibrates. It will start the "Fastboot mode".

On the PC:


On the PC, you need to install the MI Unlock App. It is a simple zip file, does not require any installation. Extract it a folder and open the "miflash_unlock.exe". Accept the warning, Login with your phone number and an OTP that it generates.

Now, connect the phone with the USB and click Unlock. If all is well, your phone should be unlocked in 5 minutes.

Recovery ROM


The next step is to flash the Recovery ROM.

On the PC:


Visit TWRP - Xiaomi page for your specific device. Be very sure to pick the recovery ROM for your specific device. Messing here can be costly.

Click on your phone name, then scroll down to Download. You have two links for Europe and America. Chose the one geographically closer to you. Then you will see the list of IMG files. Download the latest of them.

Also, install the Android Platform Tools. If you are an Android freak, you might already have it installed with your Android Developer SDK. Extract the Zip file and find the two binaries inside it.. adb and fastboot. These are important in the process. Copy the Recovery Rom IMG file into the platform tools folder - so that you can run everything easily from the command prompt.

To start with, just make sure we are setup well, on the command prompt type "fastboot devices". It should give an output like this.

C:\dev\android\platform-tools>fastboot devices
27a5e496        fastboot

If this does not work, stop now, and check up. A problem with USB port/driver? Or with the settings in Developer Options in your mobile? Or a problem with the platform tools package? Check it out and fix it. Should not be major. If all is well, you can proceed to the next step.

On the command prompt, type the below command to push the Recovery Rom into the phone.

C:\dev\android\platform-tools>fastboot flash recovery twrp-3.4.0-1-ugg.img
Sending 'recovery' (26166 KB)                      OKAY [  2.306s]
Writing 'recovery'                                 OKAY [  0.212s]
Finished. Total time: 2.606s

Note that twrp-3.4.0-1-ugg.img - was the Recovery ROM image for my phone. It would be different for your phone. Also, as mentioned above, it is easiest to have everything in the platform-tools folder. If you have not done that, you should give the full path to the img file. This takes only a couple of seconds.

Phone:


There you are. Now, power off the phone. Press the Volume Up as well as the Volume Down buttons. With these pressed, press the Power button. Keep them pressed till the phone vibrates. Now, your phone has booted in the Recovery Mode.

Install Magisk


Now, we are ready to install the rooting app. There are several rooting apps out there, but Magisk is the best choice. Simple as well as powerful. If you are curious, you can try out others as well.

On the PC:


Download the latest version of Magisk. Note, the same page also has a Magisk Manager APK file. We want the Magisk. It is a zip file.

With the Mobile connected to the USB, you should be able to access the Internal Storage. Put the Zip file into the Internal Storage (Base folder).

Phone:


In the previous step, you had booted the phone in recovery mode. This is the way it looks. You might have a few initial confirmation dialog. Accept that. And you should be here. Tap on the Install.

You will see the base folder of your Internal Storage. Locate the Magisk*.zip that you dropped in there. And tap that. You will be taken to the Zip install confirmation page.

Swipe to confirm flash. And there it goes.

Confirm successful install and then click Reboot System. Let the phone boot normally. There, in the installed apps, you will see the Magisk Manager. And your device is rooted. I have another blog on configuring and using the Magisk Manager. For now, it should be enough to have it in place.

Remove System Apps


Well, after all this excitement, one might forget. We started with removing the system apps that pestered us. So, lets get going.

Now that we have root access, we have to be careful with what we do. The apps that we run on our mobile and everything! So we have to be careful that we install only the well tested and trusted apps to do the job.

One app that I trust is the System App Remover. This helps you quickly identify and remove the unwanted apps.

Install and run the app. It will ask for root access, grant it. You will see the Mi Apps there in the list. And you can remove them.

Unfortunately, very few can be removed this way. Don't bash me up for this anti-climax. After all, it is a Xiaomi. Some of those apps - marked important, are really important. and if you mess around with them, your phone will not boot again.

Custom ROM


Hmm... After all this frustrating struggle, I had only one way out. Clear out everything, and install a good, fresh Open Source Custom ROM.

Many of my friends had scared me. It is very risky. You could lose your phone. There is no way to recover if you make a mistake...

But, after going through the process, I feel that was an unnecessary hoax around it. Yes, you can damage the phone - just as you can also damage it by banging it hard on the floor. But why would you do it? The steps are pretty simple and straightforward. So, don't worry. Just carry on - at your own risk ;)

Installing Custom Rom is quite similar to rooting the phone. Follow the first two steps above - Unlock it and install the Recovery Rom. Then, instead of installing Magisk, we format the phone and install the Custom Rom. Simple! Let's do it.

Lineage OS


There is a vast variety of open source Custom ROM's available on Github. But we have to be careful. Not all are made with good intention. Some of these Custom ROM's have more malware than the one we are trying to remove. So be careful in choosing here. LineageOS and Pixel Experience are two of the most popular ones. They are wonderfully stable, tested and trusted by several techies who have been enjoying the ride.

These ROM's are prepared for individual devices in the market. Most of the popular phones have a build available here. Lineage OS has a much wider range than the other. So I prefer that. Pixel Experience - as the name suggests has a wonderful look and feel.

It is important that you choose the ROM that is created for your particular model - so that the device drivers and other specifics match properly. Else, you can get into trouble. Lineage OS has most of them. Yet, some are missing. In that case, you can search around for other trusted sources. But, warning you again, look for, and the ROM only for your specific model.

To download the Lineage OS, visit the Lineage OS Wiki Page. This has a list of all the popular devices out there in the market. The list keeps growing as they work on more and more devices. So don't feel disheartened if your device is missing. Just check again after a few days.

It is possible that your device is present in there, but named differently. There are only a few of those, but you can identify that easily by a little Google Search.

Once you have identified the model, click on that link and you will be able to see some more technical specifications. Ensure that the specifications there match those on your phone. There is a link to "Get the builds". Click on that and you will see the list of builds for the given Custom Rom. Well, people have been working hard on this - giving you regular updates to the ROM. Pick the latest one and download it.

It is a simple zip file. If you are curious, you can try to open it and see what is in there. But for the mobile, you have to push in the zip as it is.

GAPS


You also need the Google Apps package. This is not absolutely essential. But, good to have and makes things a lot easier to start when you have installed the new ROM. So you should pick it up. Again, open the Wiki Page to get the appropriate version for you. Choose the version of Lineage OS that you would install, and in there, pick the specific platform. Usually it comes pre-selected. But, it is better to verify. Most of the Xiaomi phones are based on Arm64. But, again, you should verify it for your phone. The version number is of course the android version that you are about to install. That too should come pre-selected

The third choice is the variant of the GApps package. Ranging from Pico to Aroma, it adds more and more of Google into your phone. I would suggest anything from Macro to Super - depending upon how much of Google you like on the phone, and the amount of memory your phone permits. You can always install the missing Apps later on. But you should at least get the Google Play Service installed!

Magisk


And, if you want to root the phone, you also need the Magisk - discussed above. Just download the keep the Magisk Zip file ready.

Format


Before we install the new ROM, we should cleanup the old. Best to format and clear the cache, and get rid of everything else out there.

This is your last chance to stop and resign. Once you format your mobile, there is no return. So male up your mind and just do it!

On the Recovery screen, tap Wipe. Then click Format Data. This will format the Internal Storage.

But that is not enough. Once the Format is complete, You should also click on the Advanced Wipe, to take care of any ugly stuff hiding in the cache or RAM. So clear that as well. Once the slate is clean, we can go ahead with the rest.

Installation


There you are, ready to begin. As I said, the first two steps are identical to what we did for Rooting. I will start here with the third - installing everything on the mobile.

On the PC:


With the mobile connected on the USB, in Recovery mode, push the two (or three - if you want to root the phone) zip files into the phone.

C:\dev\android\platform-tools>adb push lineage-16.0-20200902-nightly-santoni-signed.zip /sdcard
lineage-16.0-20200902-nightly-santoni-signed.zip: 1 file pushed, 0 skipped. 31.4 MB/s (570637664 bytes in 17.347s)

C:\dev\android\platform-tools>adb push open_gapps-arm64-7.1-super-20200905.zip /sdcard
open_gapps-arm64-7.1-super-20200905.zip: 1 file pushed, 0 skipped. 44.1 MB/s (1176400542 bytes in 25.347s)

If you want to root the device, you can also push the Magisk at this time.

C:\dev\android\platform-tools>adb push Magisk-v20.3.zip /sdcard
Magisk-v20.3.zip: 1 file pushed, 0 skipped. 19.1 MB/s (5,533,696 bytes in 0.347s)

Don't worry about the /sdcard. This is just a folder in your internal storage. You do not need an External SD Card

If it possible that you get an error that you are out of memory. In that case, control your appetite and use a lesser version of the GApps. You can always install the required Apps later.

Phone:


And finally, you go back to the phone, and click on Install.

There, select the Lineage OS ROM that we pushed in the above step. On selecting tap the "Add more Zips", to add the next one. This way, add the GApps and then Magisk (if you are rooting). Make sure you follow the sequence.

Finally, Swipe to confirm Flash. Then, just wait and watch. Two common problems that people stumble on.

The install script can throw up saying that the ROM is not meant for this device. This is meant to protect you. So, check the details again and download the correct Custom ROM. But, if you are absolutely certain that you are right in what you are doing, there is a way to resolve this. On your PC, unzip the LineageOS zip fil. In there, pick the META-INF\com\google\android\updater-script. The first line in the script is an assert statement that throws this error. You can remove that line, and rebuild the zip file. On the phone, Clear Zip Queue, and start over again.

Another possible problem is that of a missing folder - /cache/resources. This is a trivial and simple problem. On the Team Win Recovery Project screen, click on Advanced and then Terminal. There, you can see a Linux Shell. Just create the directory /cache/resources. That should solve the problem.

In case you see any other problem, a simple search on xda-developers can give you a quick solution. Many people install the LineageOS everyday. So many others have faced the problem that you face today. Quite likely that you get a good solution out there.

Reboot


Once this process is complete, you can reboot your phone by tapping the Reboot button.. Congratulations! you have a perfect version of Lineage OS installed on your mobile.

Complete!


And finally, I got a mobile free from bloatware. Clean, safe and secure. The battery life of my phone doubled. And I love the Googly UI. I have a vast range of apps to choose from, and I can erase all that I do not need. That gives me a wonderful mobile phone. Xiaomi restricted me to Android 7. Now, I have Android 9 installed on my phone. Why didn't I do this before?

The entire process took me a couple of hours. And it was worth the effort!

Disclaimer


Rooting the mobile, or installing a Custom ROM is not as difficult as they make it sound. It is simple. You can browse through these steps to get an idea of the level of difficulty.

But certainly, this is not meant for the Dummies. Do not venture into it unless you know what you are doing. And if you do, at your own risk, I wish you all the best!

If you feel you have goofed up, and want to revert back, you can pick up the official ROM for your mobile from the Xiaomi Firmware Site.