[MAGISK][ROOT] Disable messages and chats notifications in DND when you allow phone calls


famusc

Members
Jul 4, 2013
73
30
Hi guys,
With my Mi 10 Ultra on MIUI 13 I noticed that when I allowed phone calls from starred contacts in DND I got messages notifications too, and there was no way to disable messages and chat notifications. In fact the only one option is for phone calls. And this behavior has been reported for 13 ultra too, in the first MIUI builds at least.
I examined the configuration and noted that there were 2 flags in notification-policy.xml file in zen tag, that are "messages" and "convos", both set to true that made messages and chats notifications to bypass DND, and MIUI interface has no option to explicitly set these flags.
So I wrote a magisk module which changes these flags to false and so now I got no more notification for messages from starred contacts in DND. The module is made of just a single script executed at boot that patches notification-policy.xml. You can delete the module after the first successful execution, since the new values stick. I keep it installed, just to make sure that flags stay on false in case they get back to true somehow.

Please notice that this module changes "messages" and "convos" value to false, indipendently from other flags value. So messages and chats won't bother you anymore in DND, indipendently if you allow calls from anyone or from starred contacts only.
To restore the flags value to true, you can use the Enable module. Please notice that you can have installed only one module (disable or enable), and not both at the same time.

I adapted the module to the current notification policy syntax as of June 2023.

Please notice that the module is super safe as it patches notification-policy only if it finds expected flags at expected offset, so you can use it safely: at most it won't do anything.

UPDATE 2023/08/18:
Code:
Uploaded enable volume whiche restores true value.
Added check during module install that the other module is not installed: you can have only enable or disable module at the same time.

* Anyway the module is provided as it is, with no support. If you make changes, please give credit *

Tested on MIUI 13/14 stable MI 10 Ultra and MIUI 14 stable Xiaomi 13 Ultra.
 

Attachments

  • MIUI13_14_202306-Disable_DND_messages_notification-1.3.zip
    4.1 KB · Views: 105
  • MIUI13_14_202306-Enable_DND_messages_notification-1.3.zip
    4.1 KB · Views: 86
Last edited:
You did a great job. Really...
I was thinking I was the only one in the world considering this a bug.... I really would like to know how people can sleep if they need to keep the phone active....
Anyway, I guess xiaomi fixed the bug, at least in the last MIUI 14.0.16.0 China on Xiaomi 13 Ultra....