[MAGISK 16][Battery Saver][6.0+] ENABLE DOZE on Google Play Services

Search This thread

otonieru

Senior Member
May 7, 2011
3,440
2,207
Djakarta
Hi guys,

I actually made this module for my personal own use, but who knows, someone here might find it useful as well.

PIE & Magisk v19 Compatible Update
https://drive.google.com/file/d/1-Nw6xHIhOPz06j4FqD-geAnMCz2NzPKX/view?usp=drivesdk

UPDATE NOTES :
OOS Nougat & Oreo User might not be able to find system app on Battery Optimisation list, you can work around this by using 3rd party app like Greenify or Naptime to open Doze Whitelist, you will see Google Play Services already listed as "Optimised App". Or go to App Info from setting, choose "Battery" and scroll down to "Battery Optimisation" - if the module work, it should written "Optimising Battery Use"

OREO User, PLEASE USE OREO version. v6 Update is already in the Magisk Repo.

BACKGROUND :
I always find that Google Play Services is way too aggresive in doing its activities in the background. And its no secret that this main services from google is oftenly one of the main culprit for the sub par battery performance on most stock or even custom ROM across devices.

THE IDEA & THE BARRIER :
Starting in Android 6.0, Google has introduced one of my favorite features in battery saving : DOZE (quick read about this Here), it help us to make apps go into a "shallow" hibernation state. Where it use less energy but retain it's functionality.

Thing is, this feature is NOT applicable for Google Play Services. Thus, it cant help you to save the battery from being eaten by Google Play Services. And this is not for no reason of course (read SIDE EFFECT/NOTE section bellow for further explanation)

THE SOLUTION :
Quick study (if you are interested, one of the discussion can be found Here) reveal that Google put simple configuration is /system/etc/sysconfig/google.xml that WHITELISTING Google Play Services from the DOZE Mechanism.

So to make DOZE able to work on it, we simply need to remove the whitelisting.

This is WHAT THIS MODULE DO - SYSTEMLESSLY (obviously)

By installing this module, you can move Google Play Services from the "App Not Optimised" list to "App Optimised" which mean DOZE mechanism will work its magic on Google Play Services, thus should saving you more juices/batt throughout the day.

THE SIDE EFFECT/NOTE :
Saving energy never come without side effect. Same goes with this method.

By enabling Doze on Google Play Services, it will theoritically delay/pause some it's services. Most noticeable might be the GCM (cloud messaging) services.

App that use this services might experience delay in notification when Doze already kick in.

Although, in my experience (i use this mod on all of my three devices) my notif for LINE, WhatsApp and Telegram (my main comm app) is never been delayed. ( I put all these apps in my whitelist btw)

The one i noticed had slight delay is GMail. But i check my mail regularly throughout the day, so i need no real time notif for that.

As for all other main services like Accounts, Alarm, Location and elses, i never have any issue with them when i got this module active. GPS work fine, Alarm ringing, Account Syncing normally.


HOW TO INSTALL :
SO if after reading all the PROs and the probable CONs above , you still interested in trying this mod,

Simply dowmload it from the attachment, and install it through your MAGISK MANAGER. And reboot.

After reboot, go to "Setting" - "Battery" - tap the tri-dot menu on the top right and choose "Battery Optimisation"

Choose "All Apps" and switch ON the toggle for Google Play Services (in most ROM, it will be automatically switched to ON once this mod is installed)

ENJOY THEN ! :highfive:

Addendum :

WHAT IS THE DIFFERENCE between (+) and standard module ?
• Plus (+) version modified by @VR25 has an extra feature, which removing Google Play Services from Background Data Access Whitelisting. Thus enabling data saver or restricting background data will impact Google Play Services as well. This might save you extra juice, but BEWARE for interrupted background data activities.

Choose the one suit you most.

COMPATIBILITY :
This Mod should compatible with any Marshmallow and Nougat ROM (Official & Custom) that has Google Play Services Installed on it,

Tested on :
OOS, LOS, CM13, MIUI, EMUI, and TouchWiz

If you found that this module causing issue for your set up, simply uninstall it from magisk manager, or use the TWRP Uninstaller.

Screenshot of expected level of Google Play Services Battery Usage :

Screenshot_20170623_020158.png
Screenshot_20170623_020705.png
 

Attachments

  • EnableDozeGMS-TWRP-by-otonieru.zip
    394.2 KB · Views: 29,275
  • EnableDozeGMS-TWRP-Uninstaller.zip
    146.2 KB · Views: 9,720
  • EnableDozeforGMS-Rev5-by_otonieru.zip
    8.8 KB · Views: 8,669
  • EnableDozeforGMS-Magisk13xONLY-by_otonieru.zip
    8.5 KB · Views: 5,672
  • EnableDozeGMS+Magisk-by-VR25-Rev5.zip
    8.9 KB · Views: 14,554
  • OREO_EnableDozeGMS+_TWRP_by_otonieru.zip
    148.8 KB · Views: 13,113
Last edited:

otonieru

Senior Member
May 7, 2011
3,440
2,207
Djakarta
Htc 10 on viper rom. This breaks fingerprint sensor/home button for me

Thats weird,

My S8, OP3 and P9 all has fingerprint scanner, and work normal.

Can you try,

Before placing finger on the scanner, turn on your screen first by pressing lock button,

If it managed to scan, then it means it doesn't actually break FP, it just the phone go to deeper sleep (since GMS is now hibernated as well) and refuse to wake up simply by placing finger.

But if it atill refuse to scan even with screen on. Send me a logcat
 

JohnFawkes

Senior Member
Jul 9, 2015
764
1,323
john-fawkes.com
Thats weird,

My S8, OP3 and P9 all has fingerprint scanner, and work normal.

Can you try,

Before placing finger on the scanner, turn on your screen first by pressing lock button,

If it managed to scan, then it means it doesn't actually break FP, it just the phone go to deeper sleep (since GMS is now hibernated as well) and refuse to wake up simply by placing finger.

But if it atill refuse to scan even with screen on. Send me a logcat

I don't have any FPs set up but waking screen and using it as a home button does not work and I get no vibration either even though it's set to 90 in exkm
edit give me a few minutes to reinstall and I'll get a logcat for you
 

JohnFawkes

Senior Member
Jul 9, 2015
764
1,323
john-fawkes.com
so after flashing this time I lost root and no cell serviceafter reboot. Looked at your module.prop and from my understanding with v12 modules are supposed to use versioncode 3 not 1. So I changed it 3 and zipped it back up. Booted into twrp used magiskmount to delete this module and flashed the one with 3 as versioncode and after booting up I have root and cell service and my home button is working like it should.
 

otonieru

Senior Member
May 7, 2011
3,440
2,207
Djakarta
so after flashing this time I lost root and no cell serviceafter reboot. Looked at your module.prop and from my understanding with v12 modules are supposed to use versioncode 3 not 1. So I changed it 3 and zipped it back up. Booted into twrp used magiskmount to delete this module and flashed the one with 3 as versioncode and after booting up I have root and cell service and my home button is working like it should.

Crap, so that's where the issue belong,

although am using v1 myself on v12 Magisk, since it's supposed to have backward compatibility. And so far there's no issue.

I think ROM combination might have something to do as well,

but as for now i'll update the installer zip.

Thx for the debug!
 

JohnFawkes

Senior Member
Jul 9, 2015
764
1,323
john-fawkes.com
Crap, so that's where the issue belong,

although am using v1 myself on v12 Magisk, since it's supposed to have backward compatibility. And so far there's no issue.

I think ROM combination might have something to do as well,

but as for now i'll update the installer zip.

Thx for the debug!

No problem! Happy to help. If you need a tester for anything just let me know :)
 

asusgarb

Senior Member
Jul 4, 2010
1,779
345
Hi. I tried installing it. Installation worked and module appeared in the list, but on reboot it disappear. I'm on Galaxy Note 3 with custom kernel and custom magisk. I've asked if it could be that magisk's problem, but maybe could be this module fault?
My rom is Unofficial LineageOS 7.1.2.

P.S. I also tried flashing it with TWRP without success. I'll try this module in my tablet to check too (Lineage 7.1.2 too).

Inviato dal mio SM-P605 utilizzando Tapatalk
 
Last edited:

otonieru

Senior Member
May 7, 2011
3,440
2,207
Djakarta
Hi. I tried installing it. Installation worked and module appeared in the list, but on reboot it disappear. I'm on Galaxy Note 3 with custom kernel and custom magisk. I've asked if it could be that magisk's problem, but maybe could be this module fault?

Inviato dal mio SM-P605 utilizzando Tapatalk

Well, all i can say is that i only test it on official Magisk :(

But, try use the new module attached, and whether it solve your issue
 

asusgarb

Senior Member
Jul 4, 2010
1,779
345
Well, all i can say is that i only test it on official Magisk :(

But, try use the new module attached, and whether it solve your issue
Just for information, with modified magisk didn't work, but it works in both devices with official magisk 12.

And now let's test its impact on battery life![emoji1]

Inviato dal mio SM-N9005 utilizzando Tapatalk
 
  • Like
Reactions: otonieru

DroneDoom

Senior Member
Nov 8, 2013
571
165
Works like a charm.
BTW, there is also Download Manager which cannot be optimized. Can you add it to your module?
You do realize if you're downloading a big file and download manager is optomize your download will stop soon after you turn off the screen when doze starts. Download manager doesn't produce any wakelocks or alarms.
 
  • Like
Reactions: ACardAttack

Shished

Senior Member
Nov 8, 2016
438
94
You do realize if you're downloading a big file and download manager is optomize your download will stop soon after you turn off the screen when doze starts. Download manager doesn't produce any wakelocks or alarms.

Hidden downloads such as play store or play services are also downloaded with this app.
 

DroneDoom

Senior Member
Nov 8, 2013
571
165
Hidden downloads such as play store or play services are also downloaded with this app.
What is your point?

---------- Post added at 04:21 PM ---------- Previous post was at 04:17 PM ----------

Hidden downloads such as play store or play services are also downloaded with this app.
Download manager is independent from those services. If everything is optomize, nothing should be invoking download manager in the first place during doze. Thus download manager shouldn't be bothered with the battery optomize option.
 
  • Like
Reactions: otonieru

otonieru

Senior Member
May 7, 2011
3,440
2,207
Djakarta
What is your point?

---------- Post added at 04:21 PM ---------- Previous post was at 04:17 PM ----------


Download manager is independent from those services. If everything is optomize, nothing should be invoking download manager in the first place during doze. Thus download manager shouldn't be bothered with the battery optomize option.

This is true @Shished

I even put ADM to whitelist. I dont want any of my downloads interrupted when the screen is off or when am sleeping :rolleyes:

Thus, it shouldnt be bothered. :eek:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 268
    Hi guys,

    I actually made this module for my personal own use, but who knows, someone here might find it useful as well.

    PIE & Magisk v19 Compatible Update
    https://drive.google.com/file/d/1-Nw6xHIhOPz06j4FqD-geAnMCz2NzPKX/view?usp=drivesdk

    UPDATE NOTES :
    OOS Nougat & Oreo User might not be able to find system app on Battery Optimisation list, you can work around this by using 3rd party app like Greenify or Naptime to open Doze Whitelist, you will see Google Play Services already listed as "Optimised App". Or go to App Info from setting, choose "Battery" and scroll down to "Battery Optimisation" - if the module work, it should written "Optimising Battery Use"

    OREO User, PLEASE USE OREO version. v6 Update is already in the Magisk Repo.

    BACKGROUND :
    I always find that Google Play Services is way too aggresive in doing its activities in the background. And its no secret that this main services from google is oftenly one of the main culprit for the sub par battery performance on most stock or even custom ROM across devices.

    THE IDEA & THE BARRIER :
    Starting in Android 6.0, Google has introduced one of my favorite features in battery saving : DOZE (quick read about this Here), it help us to make apps go into a "shallow" hibernation state. Where it use less energy but retain it's functionality.

    Thing is, this feature is NOT applicable for Google Play Services. Thus, it cant help you to save the battery from being eaten by Google Play Services. And this is not for no reason of course (read SIDE EFFECT/NOTE section bellow for further explanation)

    THE SOLUTION :
    Quick study (if you are interested, one of the discussion can be found Here) reveal that Google put simple configuration is /system/etc/sysconfig/google.xml that WHITELISTING Google Play Services from the DOZE Mechanism.

    So to make DOZE able to work on it, we simply need to remove the whitelisting.

    This is WHAT THIS MODULE DO - SYSTEMLESSLY (obviously)

    By installing this module, you can move Google Play Services from the "App Not Optimised" list to "App Optimised" which mean DOZE mechanism will work its magic on Google Play Services, thus should saving you more juices/batt throughout the day.

    THE SIDE EFFECT/NOTE :
    Saving energy never come without side effect. Same goes with this method.

    By enabling Doze on Google Play Services, it will theoritically delay/pause some it's services. Most noticeable might be the GCM (cloud messaging) services.

    App that use this services might experience delay in notification when Doze already kick in.

    Although, in my experience (i use this mod on all of my three devices) my notif for LINE, WhatsApp and Telegram (my main comm app) is never been delayed. ( I put all these apps in my whitelist btw)

    The one i noticed had slight delay is GMail. But i check my mail regularly throughout the day, so i need no real time notif for that.

    As for all other main services like Accounts, Alarm, Location and elses, i never have any issue with them when i got this module active. GPS work fine, Alarm ringing, Account Syncing normally.


    HOW TO INSTALL :
    SO if after reading all the PROs and the probable CONs above , you still interested in trying this mod,

    Simply dowmload it from the attachment, and install it through your MAGISK MANAGER. And reboot.

    After reboot, go to "Setting" - "Battery" - tap the tri-dot menu on the top right and choose "Battery Optimisation"

    Choose "All Apps" and switch ON the toggle for Google Play Services (in most ROM, it will be automatically switched to ON once this mod is installed)

    ENJOY THEN ! :highfive:

    Addendum :

    WHAT IS THE DIFFERENCE between (+) and standard module ?
    • Plus (+) version modified by @VR25 has an extra feature, which removing Google Play Services from Background Data Access Whitelisting. Thus enabling data saver or restricting background data will impact Google Play Services as well. This might save you extra juice, but BEWARE for interrupted background data activities.

    Choose the one suit you most.

    COMPATIBILITY :
    This Mod should compatible with any Marshmallow and Nougat ROM (Official & Custom) that has Google Play Services Installed on it,

    Tested on :
    OOS, LOS, CM13, MIUI, EMUI, and TouchWiz

    If you found that this module causing issue for your set up, simply uninstall it from magisk manager, or use the TWRP Uninstaller.

    Screenshot of expected level of Google Play Services Battery Usage :

    Screenshot_20170623_020158.png
    Screenshot_20170623_020705.png
    16
    Here's a new goodie:

    Sysconfig Patcher

    Systemlessly patches "/system/etc/sysconfig/*" for data and battery savings & auto-re-patches after ROM/GApps updates.

    This one does the same as "DozeGMS" or similar module/tweak, but... in addition to "google.xml," it also patches ALL the remaining XML files in /system/etc/sysconfig, systemlessly! Therefore it's not limited to GApps. The other system apps listed there are also removed from the power & data whitelists.

    This way, no app will ever have unrestricted access to data & power intensive resources without the user's explicit consent.

    Note: this may not be for everyone. While some mention things such as downloads stopping on screen off & whatnot, I've never came across such an issue. Test for yourself, take your own conclusions & be responsible for any nuclear disaster(s) and/or cat harm potentially triggered by the use/misuse of this module.
    14
    Nope not the same, someone seems to have tried to copy him and made a module that doesn't even work
    @otonieru might wanna publish your module to the Magisk repo since someone else put an inferior module copying yours there

    Thx @demonoidmaster for the head up,
    @simonsmh is a fellow member here at xda as well,

    I dont think he actually copy my module,

    I believe he create another module using regex logic, so that he wont need to replace the whole google.xml

    He used to put comment(s) in this thread as well about that,

    My reason why i didnt move to using regex is because it has bigger risk of module not working,

    Most of ROM which using Gapps will still use google standards in placing the config in the respective .xml thus my module will work in like 8 out of 10 situations,

    Am not sure about the success rate of using regex method, (used to try it, but decide to revert)

    After all, we are just two dev(s) trying to achieve same goal, only using different path

    I think Simon surely already test his module prior to released as well (on his OP3 i guess?)

    But unfortunately it wont work on OP5 ?

    Thank you for advising me to put the module up to repo,

    I'll try to do that, (not soon enough maybe) i dont have much time on my pc lately. Most of my recent xda activities were done in a brief time through phone.

    Also for everyone who still use Magisk v12, the compatible v3 module is avail page back,

    I advising you to either keep the file yourself after download, or upgrading to v13.3 altogether,

    i'll only maintain the latest module which using latest template, else it can confusing in main post

    Thank you & salam from indonesia
    12
    Here you go:

    Original Oreo google.xml
    https://www.dropbox.com/s/k7q3g0rx9uyumza/google.xml?dl=0

    and I made the below Magisk module for myself but figured others might enjoy it :)

    EnableGMSDoze for Oreo
    https://www.dropbox.com/s/562drx7q1uenf57/EnableGMSDoze_Oreo_Magiskv15.zip?dl=0
    12
    But with the next version (13.3), all Magisk modules will not continue to work..

    @otonieru could you keep up to date your module please ?

    This has already been addressed: https://forum.xda-developers.com/showpost.php?p=72981906&postcount=227

    As of now the module still works fine.

    Module has been updated to latest template. tested on 13.2 and it work as it should as well

    v4 is available on main post.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone