[MODULE] Universal GMS Doze

Search This thread

F3N!X

Member
Jan 19, 2013
44
12
Xiaomi Mi Pad 4
Redmi Note 10 Pro
For anyone who had no success with this project, I rebuilt the google.xml without the battery whitelist line (based on this post on Stackexchange) and put it in a super simple Magisk module. It's not advanced at all like this project is (my module is just a simple text file in "system"), but this is what worked for me. And maybe does for some other people too.

Edit: I got a helpful message regarding this and need to say, this works only if the original config file is on /system. But it it typically the case on custom ROMs and if you flashed something like OpenGapps (which is the case for me and where it worked).

Edit2: I noticed thanks to MatLog in logcat that Google Play Services is not happy and keeps exiting some services due not getting its special exception. I'm not sure if I should keep this file up or if the original GMS Doze project from OP can create the same side effect. But please proceed with caution and test if this works correctly!

@RandomNewbie Sorry for the noob question but how could we adapt your module to the /system_ext location required by GApps packages like FlameGApps?
I've extracted your ZIP file, replaced "system" with "system/system_ext", compressed the files to ZIP again and installed it to my Magisk 24.3: OK. I can now see with Termux that the /system_ext/etc/sysconfig/google.xml content is your version, I mean with blank lines. But it doesn't change anything to this service battery consumption and it doesn't change the "Battery optimisation not available" status of Google Play Services, still no ability to enable optimisation :-(
 
Last edited:

Cosmii

New member
Feb 16, 2022
1
0
Samsung Galaxy A70
I installed the magisk module, found that notifications (from apps like Discord) no longer work, but then the GMS services are still disabled. I tried to re-enable via adb shell pm, but it says that the shell cannot change component state. How do I properly uninstall this and reverse all changes the module made? Thanks.
 

73sydney

Senior Member
@gloeyisk Any chance to adapt your module's scripts to this /system_ext path? Or any way to make the @RandomNewbie solution work for FlameGApps?

You can:

1) Unzip the module
2) Open customize.sh

Add /system_ext/ to the paths in the lines:

# Patch the XML and place the modified one to the original directory
ui_print "- Patching XML files"
gms=$(xml=$(find /system/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.gms"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
ims=$(xml=$(find /system/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.ims"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
pst=$(xml=$(find /system/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.apps.safetyhub"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
trb=$(xml=$(find /system/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.apps.turbo"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)


aka

# Patch the XML and place the modified one to the original directory
ui_print "- Patching XML files"
gms=$(xml=$(find /system/ /system_ext/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.gms"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
ims=$(xml=$(find /system/ /system_ext/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.ims"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
pst=$(xml=$(find /system/ /system_ext/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.apps.safetyhub"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)
trb=$(xml=$(find /system/ /system_ext/ /product/ /vendor/ -iname "*.xml");for i in $xml; do if grep -q 'allow-in-power-save package="com.google.android.apps.turbo"' $ROOT$i 2>/dev/null; then echo "$i";fi; done)

3) zip the files in the root of the modules folder back up, and flash and test


OR

You can try my simpler GMS Doze module (added the /system_ext/ path just now)

It doesnt do as much as gloeyisk's, but it uses the "original" method as described here (this is the OG of doze tweaks)

aka it merely comments out

<allow-in-power-save package="com.google.android.gms" />

to

<!-- <allow-in-power-save package="com.google.android.gms" /> -->

my common/install.sh (i use MMT-Ex module format):

Bash:
gxml=$(find /system/ /system_ext/ /product/ /vendor/ -iname "google.xml" -print | head -n 1 | sed 's|/[^/]*$||')
ui_print "google.xml found at: $gxml"
ui_print "creating directory: $MODPATH$gxml"
mkdir -p "$MODPATH$gxml"
ui_print "copying $gxml/google.xml to $MODPATH$gxml/"
cp -af "$gxml/google.xml" "$MODPATH$gxml/google.xml"
ui_print "modifying $MODPATH$gxml/google.xml"
sed -i 's/<allow-in-power-save package=\"com.google.android.gms\" \/>/<!--  &  -->/g' "$MODPATH$gxml/google.xml"

what it does (similar to above, though different): finds the first google.xml it can in the paths:
/system/
/system_ext/
/product/
/vendor/

copies the google.xml to the modules /system folder

and then uses sed to add a <--- prefix and ---> suffix to the relevant line

thats all it does. for those who have issues with main GMS Doze module, you may like to try this simpler one. I made it (in 30 seconds) in response to a members question on here, and only up till now shared it with him privately. It resolved the issue was personally having, ymmv

attached....

never be afraid to open up a script and look for ways to customize it to your needs, its often easily to figure out how to add/change a path...its hard to hose your device with a magisk module, even if you bootloop it, its fixable....
 

Attachments

  • GMS Doze Simplified (Magisk Module).zip
    15.4 KB · Views: 81
Last edited:

73sydney

Senior Member
I installed the magisk module, found that notifications (from apps like Discord) no longer work, but then the GMS services are still disabled. I tried to re-enable via adb shell pm, but it says that the shell cannot change component state. How do I properly uninstall this and reverse all changes the module made? Thanks.

Most (well written modules) will be completely reversible upon uninstall

This one should....

You could find your google.xml in one of these paths above, for example:

/system/etc/sysconfig/google.xml
/system_ext/sysconfig/google.xml
/product/sysconfig/google.xml
/vendor/sysconfig/google.xml

and check

<!-- <allow-in-power-save package="com.google.android.gms" /> -->

and if need be change to

<allow-in-power-save package="com.google.android.gms" />

and reboot
 
Last edited:
  • Like
Reactions: rodken

F3N!X

Member
Jan 19, 2013
44
12
Xiaomi Mi Pad 4
Redmi Note 10 Pro
@73sydney
1/ test with modified gloeyisk GMS Doze after having added the path /system_ext/ to the lines you've highlighted: from 100% battery to 59% in 5 hours while not using the phone at all, Google Play Services totaling 32% of "battery usage since full charge". And if I go to the Battery Optimization menu I can see that battery optimization is still not available for Google Play Services. Result: no benefits.

2/ test with your GMS Doze Simplified : "battery optimization not available" for Google Play Services. Now fully charging to test again and I will modify this message if the results are different but I'm not so hopeful.

Apart of re-flashing phone from scratch with AospExtended and BiTGApps (or any already optimized GApp) rather than FlameGApps, I see no solution... :(
 
  • Like
Reactions: 73sydney

73sydney

Senior Member
@73sydney
1/ test with modified gloeyisk GMS Doze after having added the path /system_ext/ to the lines you've highlighted: from 100% battery to 59% in 5 hours while not using the phone at all, Google Play Services totaling 32% of "battery usage since full charge". And if I go to the Battery Optimization menu I can see that battery optimization is still not available for Google Play Services. Result: no benefits.

2/ test with your GMS Doze Simplified : "battery optimization not available" for Google Play Services. Now fully charging to test again and I will modify this message if the results are different but I'm not so hopeful.

Apart of re-flashing phone from scratch with AospExtended and BiTGApps (or any already optimized GApp) rather than FlameGApps, I see no solution... :(

occasionally you'll hit a ROM where it just wont work....used to happen on my old device
 

Oxxxide

New member
Apr 13, 2022
2
1
Hello everyone, after installing this module, push notifications from applications stopped coming.
 

73sydney

Senior Member
Hello everyone, after installing this module, push notifications from applications stopped coming.

 

F3N!X

Member
Jan 19, 2013
44
12
Xiaomi Mi Pad 4
Redmi Note 10 Pro
At least I've tried everything I can with your valuable help. I will try again with BiTGApps.
Once again thank you very much @73sydney :)
Just for info, tested BiTGapps on AospExtended but a fake error tells me that it's impossible to install it on ROMs that include GApps, while it's a pure Vanilla ROM. Tested again for one week with AEX + OpenGApps Pico + GMS Doze module and... GMS Doze module is working (I can enable battery optimization on Google Play Services and other Google apps, could have been great) but this f*****g Google Play Services app continues to crazily eat my battery energy... 106% of use now for example. My phone was charged at 50% yesterday night before going to sleep, I've enabled the airplane mode and stopped location services, and at wake up 7 hours later it was shut down out of battery. I'm so tired of this never ending issue, the ROM is great but seems unusable this way 🤔
Dunno yet what I have to do nor what I will do... This module visibly can't resolve this on my phone/ROM/GApps, and I don't know what's the root cause in this combination. But thanks anyway for the efforts on this module.
 

Attachments

  • Screenshot_20220514-132727761.jpg
    Screenshot_20220514-132727761.jpg
    200.3 KB · Views: 78

xontax

Senior Member
Dec 17, 2011
229
42
Not working on latest A12 with security patches
 

Attachments

  • Screenshot_2022-06-07-10-54-53-43_84d3000e3f4017145260f7618db1d683.jpg
    Screenshot_2022-06-07-10-54-53-43_84d3000e3f4017145260f7618db1d683.jpg
    334.3 KB · Views: 52
  • Screenshot_2022-06-07-10-56-24-73_fc704e6b13c4fb26bf5e411f75da84f2.jpg
    Screenshot_2022-06-07-10-56-24-73_fc704e6b13c4fb26bf5e411f75da84f2.jpg
    74.8 KB · Views: 58
Last edited:

trawel

Senior Member
Aug 22, 2012
437
56
OnePlus 8T
Hi,
I'm running custom ROM based off A12.1. Is it possible that notifications still doesn't work though I've done the procedure mentioned in 'Troubleshoot' section?
I'm using the module together with battery guru (with force doze when screen off), might that be the issue?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 167
    Universal GMS Doze

    Overview:
    - Optimized and adjusted Google Play services.
    - Support API 23 or later.
    - Support Magisk Live or Custom Recovery installations.

    Contents:
    - Base extensions
    module: 1.8.4 (0830)
    code: 184

    Credits:
    - @topjohnwu / Magisk - Magisk Module Template
    - @JumboMan / Custom installation script

    Extras:
    - Donation: PayPal - LiberaPay
    - Mirror Links: GitHub Releases - Telegram - Index
    - Source Code: GitHub
    64
    Troubleshooting:

    - Command-line for check optimization (with add-on installed):
    Code:
    > su
    > gmsc

    - Command-line for check optimization (general):
    There's a line written Whitelist (except idle) system apps: and if com.google.android.gms line does not exist it means Google Play services is optimized.
    Code:
    > su
    > dumpsys deviceidle

    - Command-line for fix delayed incoming messages issue:
    Code:
    > su
    > cd /data/data
    > find . -type f -name '*gms*' -delete

    - Command-line for disable Find My Device:
    Code:
    > su
    > pm disable com.google.android.gms/
    com.google.android.gms.mdm.receivers.MdmDeviceAdminReceiver

    Changelog:

    v1.8.4
    - Removed redundant script (GMS: Stay with disabling Find My Device only)


    v1.8.3
    - Android 12 support
    - Additional boot complete check
    - Multi-User support
    - Set ignore for GMS and IMS WRITE_SETTINGS
    - Minor improvements

    v1.8.2
    - Android 11 support
    - Improved installation (Magisk Live and Custom Recovery)
    - Improved patching detections (XML files and conflicting modules)
    - Integrated add-on (run 'gmsc' with superuser rights for check optimization status)
    - Set ignore for GMS and IMS BOOT_COMPLETED
    - Set ignore for GMS and IMS AUTO_START (custom permissions for Oxygen OS)
    - Updated template

    v1.8.1
    - Integrated custom recovery installation
    - Added boot logic for search and patch any conflicting modules (if present)
    - Whitelisted IMS and Turbo (this should fixed location crash issue in MIUI)

    v1.8.0
    - Initial re-release
    - 100 seconds Magisk Boot Service
    35
    So this is it guys, both of my old machines are totally broken and some parts are get burned. I've no idea to revive it since my money were spent for my primary demands. I've built ±5 beta builds available in the support group (if you want to) but there's no special things since I'm still tinkering with every devices that Find My Device doesn't disabled automatically. Talking/sharing in here or in support group would be a nice place to find other workarounds. I'm so sorry for the lack of updates, also I just want to tell that I'll married soon.

    Keep up all of your supports, sorry for the inconveniences.
    Have a nice day!
    30
    New stable build is up!​

    This is like a dilemma, where I've to continue this GMS optimization stuff or not. But I got a few ideas lately where my loyal supporters always ask about GMS optimization and this is the answer. I will continue to try to make this module work well, stable, efficiently and of course optimized GMS.
    Please remember to read installation guides on OP, and don't use similar modules or tweaks because I won't know where the issue came from that might one day happens to you. I would like to say Thank You to all my supporters for my simplicity-oriented-usability project.
    Happy flashing :fingers-crossed:
    27
    GL-DP wishes you Happy Eid Mubarak
    and
    Here's the Stable Update!​

    I've made a lot of changes regarding I'll stop/drop supports or works for optimizing GMS. Now I'm starting to focus to prevent unnecessary GMS running in the background with my own modified services in hope for getting better battery life. Please note that I'm not referred you to use similar modules while reporting any issues you've faced of. So I can check whether the wrong is from my module or in your ends.

    While the ponds is starting to dry, don't forget that the ponds will stay wet when the rain comes.
    Happy flashing! :fingers-crossed: