Fix delayed notifications on a Xiaomi phone
On a Xiaomi phone running HyperOS, notifications from some applications arrive several minutes late, sometimes only when the screen is unlocked. The system keeps a whitelist of applications allowed to receive notifications without delay. That list is prefilled with applications distributed in China, and messaging apps installed from another country are not in it.
This is also the case for Google Play services (com.google.android.gms), which relay the push notifications of most messaging apps. When they are installed afterwards, they are not added to that whitelist: installing them does not change it.
Requirements
Section titled “Requirements”- A Xiaomi phone running HyperOS.
- A Linux workstation and a USB cable.
- Root rights on the workstation to install one package.
1. Enable developer options on the phone
Section titled “1. Enable developer options on the phone”The screenshots in this note come from a phone whose interface is in English, running Xiaomi HyperOS 3.0.307.0. If your phone uses another language, the labels quoted here are the ones to translate.
Swipe down from the top of the screen to open the control centre, then tap the settings shortcut: the round button marked with a hexagonal nut, at the right end of the third row of shortcuts.

In Settings, tap My device, the second row of the first block.

On the page showing Xiaomi HyperOS and its version number, tap the OS version row seven times in a row. A message confirms the activation, or states that developer mode is already active, as on the screenshot below.

Expected result: a message confirms that developer mode is enabled.
2. Enable USB debugging
Section titled “2. Enable USB debugging”Go back to Settings and scroll down to the last row, Additional settings.

On that page, the Developer options row sits under the accounts block.

Turn on the USB debugging switch, on the first row.

On the phone used for this note, the USB debugging (Security settings) switch is turned on as well. If the write command in step 6 fails, try turning it on.
Then connect the phone to the workstation. The phone displays an authorisation request for the workstation key: accept it, ticking the option that makes it permanent if you plan to do this again later.
Expected result: the phone displays the notification stating that USB debugging is active.
3. Install adb on the workstation
Section titled “3. Install adb on the workstation”On a Debian or Ubuntu based distribution, a single package is enough:
apt install adbExpected result: the adb version command answers.
4. Check that the phone is recognised
Section titled “4. Check that the phone is recognised”adb devicesList of devices attachedxxxxxxxx deviceThe serial number is masked here.
If the second column reads unauthorized, the authorisation was not accepted on the phone. If it reads offline, unplug and plug the cable back in.
Expected result: the phone is listed with the device status.
5. Read the current whitelist
Section titled “5. Read the current whitelist”adb shell settings get system MILLET_NO_RESTRICT_APPcom.whatsapp, org.thoughtcrime.securesms, [...], org.telegram.messengerSelect that line in your terminal and paste it into a text editor, so that you can add the missing application to it.
6. Add the missing application to the list
Section titled “6. Add the missing application to the list”The following command replaces the whole list: you therefore have to write the original list again, then add just the missing application (com.google.android.gms) at the end of it.
adb shell settings put system MILLET_NO_RESTRICT_APP "com.whatsapp, org.thoughtcrime.securesms, [...], org.telegram.messenger, com.google.android.gms"7. Check
Section titled “7. Check”Read the list again:
adb shell settings get system MILLET_NO_RESTRICT_APPcom.whatsapp, org.thoughtcrime.securesms, [...], org.telegram.messenger, com.google.android.gmsExpected result: the notification arrives without waiting for the screen to be unlocked.
