Deep comparison between emui and MIUI background processing

Time:2021-5-3

Android’s background mechanism is not only an advantage of Android, but also a feature with serious fragmentation. As a developer of three apps that rely on Android’s background services, I write this article to compare the background processing logic of emui and MIUI, the two most common Android systems

  • EMUI 10.0.0, Android 10
  • MIUI 12.0.6, Android 10

The premise of comparing the background mechanism is that both systems use the default settings, regardless of special circumstances such as power saving mode and minimalist mode, which is in line with the use of most users.

summary

There are three common ways for Android apps to stay in the background:

  • Register system services, such as accessibility services
  • Using Android timing service
  • The front desk service of resident notice bar, namely foregroup service

I have developed corresponding apps for these three background modes, and I will give examples to compare them. In addition, there are some strange and unofficial ways to stay in the background, such as playing a silent music, opening a single pixel floating window and so on. After all, they do not belong to the right way. This article will not compare them.

Before comparing, it’s necessary to explain that for Android systems of various manufacturers, such as emui and MIUI, it’s not enough to register services in this formal way, or it’s easy to be frozen or killed by the system. The reason is that all applications can register services in a formal way, and there are too many backstage applications, plus some applications are not controlled, Mobile phones are bound to get stuck and consume electricity, so it’s easy for manufacturers to understand. By default, they will kill everything. They will make a white list that can only be manually configured. Only when users join the white list will they be allowed to provide back-end services. In this way, most ordinary users won’t have to make any settings to avoid the suffering of malware.

It should be noted that the white list configuration of different systems is slightly different

  • MIUI settings, application settings, application management, select application, set power saving strategy and self start
  • Emui settings application startup management select application settings allow background activities and self startup

Let’s start to test the three background modes.

Barrier free service

I developed itMicro motion gesture, is a typical barrier free service application. Android system supports application registration as barrier free service. Barrier free service not only provides a way to stay in the background, but also provides many functions that ordinary applications can’t do, such as simulating system interaction, simulating gestures and so on. So many Android App have done some functions by barrier free service, for example, even the tiktok App provides a barrier free service.

Let’s take the micro gesture as an example. After the installation is completed and the accessibility service is turned on, I test the following four situations:

  • Default: no settings are made after the default installation
  • Lock: lock the application card in the multitask interface
  • White list: add the application to the background white list in the system
  • Lock + whitelist: set both above

In each case, I conduct four kinds of operation tests. These four kinds of operations are often done by users, and then judge whether the background of micro motion gesture works normally. The four operations are as follows:

  • Lock screen: lock the screen and wait for one minute before unlocking
  • Draw card: directly cross out the application in the multi task page
  • One click cleaning: click one click cleaning on the multi task page
  • Run out of memory: squeeze out the remaining memory by starting multiple large software or games

The test results are as follows:

EMUI MIUI Emui (lock) MIUI (lock) Emui (white list) MIUI (white list) Emui (lock + white list) MIUI (lock + white list)
Lock screen normal frozen normal normal normal normal normal normal
One click cleaning Killed Killed normal normal normal Killed normal normal
Draw a card Killed Killed Killed Killed normal Killed normal Killed
Run out of memory normal normal normal normal normal normal normal normal

Let’s take a closer look at the results here. It is obvious that the background control of MIUI is more stringent than that of emui

  • MIUI thinks that user operation takes precedence over user whitelist, so even if you join the whitelist, you can still kill the application by drawing a card.
  • Emui thinks that the user’s white list has priority. As long as the user joins the white list, even if the user draws a card, the background can keep it normally, and only the foreground interface is closed.

I won’t comment on which of the two methods is better. But obviously, if the MIUI method wants to keep the background, users need to lock and carefully avoid drawing cards after setting the white list. One thing to remind you is that if you set self startup permission for applications in the system at the same time, some background applications will restart immediately after being killed, that is, the killing effect becomes restart.

Time service

The timing service here is a general term, which refers to the realization of a timing running background with the help of a certain “timing” API of Android. Android itself is in a mess here. It provides many incompatible APIs such as AlarmManager, jobschedule, and workmanager to support the timing tasks in the background. I call it timing service here. I developed itFragmentary memoryThis is a typical timing service, which is an application of memorizing words. It needs to check whether the card needs to be reviewed regularly, and then it will pop up automatically from the background.

The results are as follows

EMUI MIUI Emui (lock) MIUI (lock) Emui (white list) MIUI (white list) Emui (lock + white list) MIUI (lock + white list)
Lock screen normal frozen normal normal normal normal normal normal
One click cleaning Killed Killed normal normal Killed Killed normal normal
Draw a card Killed Killed Killed Killed Killed Killed Killed Killed
Run out of memory Killed Killed Killed normal normal Killed normal normal

From this result, the timing service has a lower priority than barrier free service. In some scenarios where barrier free service can still work normally (such as drawing cards and running out of memory), the timing service is killed. However, this time MIUI and emui are relatively consistent.

It is worth mentioning that some of the timing mechanisms provided by Android allow applications to wake up regularly after being killed. However, in this way, malware can obviously use this to achieve immortality. Therefore, systems like emui and MIUI impose additional restrictions on this timing, which will not be detailed here.

Front desk service

Android foreground service is a term: foreground service, which refers to the background service that users can perceive, so a resident notification will be given in the notification column. This is the background mechanism used by many applications, which I developedBattery guardThis mechanism is used. Through this mechanism, the application can obtain the power change information in the background, so as to charge the user or remove the charger alarm.

The same test method is still used, and the test results are as follows:

EMUI MIUI Emui (lock) MIUI (lock) Emui (white list) MIUI (white list) Emui (lock + white list) MIUI (lock + white list)
Lock screen normal normal normal normal normal normal normal normal
One click cleaning Killed Killed normal normal normal Killed normal normal
Draw a card Killed Killed Killed Killed normal Killed normal Killed
Run out of memory Killed normal Killed normal normal normal normal normal

From the test results of running out of memory, the priority level of foreground service seems to be between barrier free service and timing service, and there is still a big difference between emui and MIUI.

summary

From the above test, there are subtle differences among barrier free service, scheduled service and front desk service. Moreover, there are many differences between MIUI and emui. From the two versions I tested, MIUI is more stringent. In some cases, if emui does not kill, MIUI will. For developers, this is a painful thing, but for users, it is more difficult to understand these subtle differences. Fortunately, after adding whitelist and lock, you can basically keep the background, so this kind of application that needs the background can only guide the user to make these settings.

This test only compares MIUI and emui. I believe there will be more differences among Google native, Samsung and other manufacturers. The fragmentation of Android can be seen.

Recommended Today

The use of springboot Ajax

Ajax overview What is Ajax? data Ajax application scenarios? project Commodity system. Evaluation system. Map system. ….. Ajax can only send and retrieve the necessary data to the server, and use JavaScript to process the response from the server on the client side. data But Ajax technology also has disadvantages, the biggest disadvantage is that […]