NetGuard gets reset to Optimized (battery) after reboot on xiaomi poco x3 ... Feedback for Xiaomi page

This issue has been tracked since 2021-12-08.

Please note that since fairly recently, 1-2 weeks ago (max. 2, I'd say) after each device reboot (at least on xiaomi poco x3 pro, up to date) the Battery Optimization setting(not the Battery saver one) for NetGuard will be reset from "Don't Optimize" to "Optimize". This has the effect of allowing the NetGuard GUI (and its permanent notification) to live and work full time but all firewall features will silently not work (you can check Logging in Netguard to see no new entries) after a while whdn thd OS actuzlly decides to apply the Optimization hammer onto NetGuard.

Other apps get changed from "Optimized" to "Don't Optimize" too like Analitics, Cast.

Here's a before and after reboot:
IMG_20211208_152908

IMG_20211208_152706

The other 3 required settings so that NetGuard stays alive(and isn't syopped by the OS) aren't touched. (they're: the lockpad, the autostart on, the battery saver to unrestricted, and the 4th being the above one)

So again the UI of NetGuard works, it even thinks NetGuard is on and firewall is working, but some part of it must've been stopped by the OS so that the effect is that you have no firewall and every app has full internet access. So for example an app that I never gave any access to, like the YouTube app, will fully work(have full network access) and NetGuard won't even notice. (in its Logs window either)

Possible workaround: set two bogus IPs(ie. local IPs for non-existent machines) for DNS for the wireless network (so that Android thinks you've no internet access, in a notification that it pops up when you turn on wireless), and then (optionally?) set two good IPs inside NetGuard's DNS options. So this way, if an app doesn't try DoH or access its own dns IPs, it will fail to access internet, when NetGuard isn't working. Better than nothing.

Also possibly try "Block connections without VPN" but NetGuard doesn't like this option so it will nag you about it. (seems to work thus far, but NetGuard seems to expect Android won't send any host requests to the VPN after a while? didn't yet happen for me, so I'm keeping the option)

Btw, the xiaomi page could mention this "Battery Optimization" feature, as it's different than the "Battery saver" one, and very much needed.

hawtdayum wrote this answer on 2021-12-08

Also note the the NetGuard app doesn't live on external storage like mentioned in #179

hawtdayum wrote this answer on 2022-02-08

as an exercise I've tried renaming every occurence of "netguard" and "faurcode" (of any case) and rebuilt NetGuard with that new name, installed and used it on phone, rebooted and it still got set to Optimized by something! I've no idea how it can get identified still, or are all unknown apps set to Optimized after reboot but somehow Spren and Toast Source are already in their exceptions list... ? because those remain on Unoptimized.

hawtdayum wrote this answer on 2022-03-25

"Battery optimization" is gone from the UI in MIUI 13 (which is updated from android 11 in the previously mentioned MIUI, to android 12 in MIUI13) but it can be opened by the playstore app with id "com.ceyhan.sets".

Screenshot_2022-03-25-18-52-03-858_com ceyhan sets jpg
Screenshot_2022-03-25-18-52-13-381_com android settings jpg

More Details About Repo
Owner Name urbandroid-team
Repo Name dont-kill-my-app
Full Name urbandroid-team/dont-kill-my-app
Language JavaScript
Created Date 2018-12-19
Updated Date 2022-12-08
Star Count 904
Watcher Count 82
Fork Count 681
Issue Count 212

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date