[SCRIPT] [GUIDE] Google Play Services Battery Drain Fix/Workaround

Search This thread

Alcolawl

Senior Member
Jul 21, 2012
1,400
2,273
United States
Google Pixel 4
Anyone's Google Play Services update recently? If you're suddenly experiencing dreadful battery life due to Google Play Services (see pic below) then this fix might be right for you.

Background:
Recently, an update to Google Play Services (ver. 7.0.97) was released and reports flooded the internet with complaints of battery life issues. People had battery graphs similar to this:
batterydrian.png


I also experienced this issue. After checking my frequency tables in my kernel tweaker, I noticed that my phone was NEVER going into Deep Sleep, and, instead, was sitting at 300mhz even when the screen was off. After some Googling and reading some comments on GitHub, it seemed apparent that the problem was one Service in particular "SystemUpdateService".

The Problem: Without going into much detail SystemUpdateService is basically Google's OTA update service, and when it detects that your phone need and update while running a Custom ROM, it fails and re-runs this check over and over again. It's this wakelock that drains your battery.

The Solution: Enabling the service. You read that correctly. For whatever reason, enabling the service actually prevents the wakelock from occurring. I, along with a few testers, have been using our phones for hours now after having run the script and the wakelock and battery drain is completely gone.

Method #1: init.d Script
For those of you with custom ROMs that support init.d scripts, simply unzip and place this script in the /etc/init.d folder (as root) and set permissions to 755. The service becomes disabled again as soon as the phone reboots. We place this script in the init.d folder so the script runs automatically every time the phone boots. If your Custom ROM does NOT support init.d scripts skip over to Method #2 or 3.

DOWNLOAD SCRIPT HERE: View attachment fixUpdateService.zip

Permissions Screenshot:
Screenshot_2015_03_19_22_45_10.png


The source code to this script (Edited slightly, Credit to Oreganoian on Reddit):
Code:
echo "Disabling SystemUpdateService Battery Drain"
su -c pm enable com.google.android.gms/.update.SystemUpdateActivity 
su -c pm enable com.google.android.gms/.update.SystemUpdateService
su -c pm enable com.google.android.gms/.update.SystemUpdateService$ActiveReceiver 
su -c pm enable com.google.android.gms/.update.SystemUpdateService$Receiver 
su -c pm enable com.google.android.gms/.update.SystemUpdateService$SecretCodeReceiver 
su -c pm enable com.google.android.gsf/.update.SystemUpdateActivity 
su -c pm enable com.google.android.gsf/.update.SystemUpdatePanoActivity 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService$Receiver 
su -c pm enable com.google.android.gsf/.update.SystemUpdateService$SecretCodeReceiver
echo "Script Execution Successful"

Method #2: Manually Running the Script
This method works best if you like working in the terminal or file explorer. Or if you would rather just do things yourself. Place the script above in the /etc/init.d directory and set permissions to 755. This time, however, you must run the script yourself EVERY TIME THE PHONE BOOTS. You can do this by using your file explorer, if it supports executing scripts (see output below) or running the script via Terminal.

Terminal: Run this command as root (type "su" and hit enter):
Code:
./etc/init.d/fixUpdateService.sh
Screenshot_2015_03_19_22_45_55.png


File Explorer: I personally use FX (File Explorer), which is a wonderful app by the way, so the output in the screenshot below may be styled different but generally should appear the same:
Screenshot_2015_03_19_22_42_50.png


Method #3: Enabling SystemUpdateService via App

Now, if you're a no frills kinda person, or just don't feel comfortable rummaging around in your filesystem or terminal, there is an app you can download called Disable Service which lets you do the same thing, just with a nice GUI. YOU MUST DO THIS EVERY TIME YOU REBOOT YOUR PHONE.

Steps:
  1. Once installed, launch the app.
  2. Then click the "System" tab on the top right.
  3. Scroll down and select "Google Play services"
  4. Scroll down to "SystemUpdateService" and CHECK the box.
  5. Done!

There you have it! Hope this helps!
 
Last edited:

Alcolawl

Senior Member
Jul 21, 2012
1,400
2,273
United States
Google Pixel 4
Great!
Method 1 doesn't work on hammerheadcaf 20150318 but Method 3 is working like a charm and the battery drain issue seems to be gone!
And CyanogenMod is going to deal with this issue before long:
http://review.cyanogenmod.org/#/c/91579/
http://review.cyanogenmod.org/#/c/91021/

Interesting, I'll try to see if I can edit the script to get it to work right. Make sure you enable the service with that app every time you reboot your phone.
Also, I've been reading those CyanogenMod discussions. Very interesting. Hopefully they tackle the issue soon and the solution makes its way into other ROMs

Hello...
This only occurs in custom roms or it happens also in Stock Rom?
Thank you...

As far as I know, this bug only affects custom ROMs.
 

bhaismachine

Senior Member
Feb 14, 2011
294
133
Dallas
Method 1 didn't work but method 2 and 3 worked. I believe the permissions for the script
should be 755 instead of 744.

Update : changing permissions didn't help either.
 
Last edited:
  • Like
Reactions: Alcolawl

smader12

Senior Member
Oct 29, 2009
92
23
Detroit
Hello...
This only occurs in custom roms or it happens also in Stock Rom?
Thank you...
I'm experiencing the battery drain with stock HTC sense on my M8 and GP services 7.0.97. The battery usage is very high for GP services (e.g. 38% for screen off!) and the "awake" bar shows the phone awake even during periods of low usage--too many awake intervals.
 

manjake

Senior Member
Jul 12, 2011
116
33
CM fixed this a couple days ago with 2 commits. Hopefully all the ROM teams will incorporate it into their builds.
CM11s may not get another update though. I can confirm that the shell script doesn't work at startup on CM11S.

Edit: sorry didnt realise this was posted in the Nexus 5 section
 

H-Cim

Senior Member
Sep 13, 2010
178
56
Pretty important to add that for that 3rd Method to work you also have to enable that same SystemUpdateService in Google Services Framework. (In addition to enabling it in Google Play Services).

At least, that's what I've read on other posts/Google+ pages. I'm trying it now so do this at your own risk =)
 

humba80

Senior Member
Aug 29, 2013
85
27
Xiaomi Poco F3
Thanks for the script. Works for me, but only manually. I can't get it to work in the init.d at startup. It's in the folder, permissions 755. I'm not that into scripts - anyone who got it working mind for some tips?
 

Wh1t3Rose

Senior Member
Thanks for the script. Works for me, but only manually. I can't get it to work in the init.d at startup. It's in the folder, permissions 755. I'm not that into scripts - anyone who got it working mind for some tips?
Your ROM may not support init.d. Mine doesn't and so I'm using tasker to run the script at boot.
 
  • Like
Reactions: humba80

gpvecchi

Senior Member

Top Liked Posts

  • There are no posts matching your filters.
  • 68
    Anyone's Google Play Services update recently? If you're suddenly experiencing dreadful battery life due to Google Play Services (see pic below) then this fix might be right for you.

    Background:
    Recently, an update to Google Play Services (ver. 7.0.97) was released and reports flooded the internet with complaints of battery life issues. People had battery graphs similar to this:
    batterydrian.png


    I also experienced this issue. After checking my frequency tables in my kernel tweaker, I noticed that my phone was NEVER going into Deep Sleep, and, instead, was sitting at 300mhz even when the screen was off. After some Googling and reading some comments on GitHub, it seemed apparent that the problem was one Service in particular "SystemUpdateService".

    The Problem: Without going into much detail SystemUpdateService is basically Google's OTA update service, and when it detects that your phone need and update while running a Custom ROM, it fails and re-runs this check over and over again. It's this wakelock that drains your battery.

    The Solution: Enabling the service. You read that correctly. For whatever reason, enabling the service actually prevents the wakelock from occurring. I, along with a few testers, have been using our phones for hours now after having run the script and the wakelock and battery drain is completely gone.

    Method #1: init.d Script
    For those of you with custom ROMs that support init.d scripts, simply unzip and place this script in the /etc/init.d folder (as root) and set permissions to 755. The service becomes disabled again as soon as the phone reboots. We place this script in the init.d folder so the script runs automatically every time the phone boots. If your Custom ROM does NOT support init.d scripts skip over to Method #2 or 3.

    DOWNLOAD SCRIPT HERE: View attachment fixUpdateService.zip

    Permissions Screenshot:
    Screenshot_2015_03_19_22_45_10.png


    The source code to this script (Edited slightly, Credit to Oreganoian on Reddit):
    Code:
    echo "Disabling SystemUpdateService Battery Drain"
    su -c pm enable com.google.android.gms/.update.SystemUpdateActivity 
    su -c pm enable com.google.android.gms/.update.SystemUpdateService
    su -c pm enable com.google.android.gms/.update.SystemUpdateService$ActiveReceiver 
    su -c pm enable com.google.android.gms/.update.SystemUpdateService$Receiver 
    su -c pm enable com.google.android.gms/.update.SystemUpdateService$SecretCodeReceiver 
    su -c pm enable com.google.android.gsf/.update.SystemUpdateActivity 
    su -c pm enable com.google.android.gsf/.update.SystemUpdatePanoActivity 
    su -c pm enable com.google.android.gsf/.update.SystemUpdateService 
    su -c pm enable com.google.android.gsf/.update.SystemUpdateService$Receiver 
    su -c pm enable com.google.android.gsf/.update.SystemUpdateService$SecretCodeReceiver
    echo "Script Execution Successful"

    Method #2: Manually Running the Script
    This method works best if you like working in the terminal or file explorer. Or if you would rather just do things yourself. Place the script above in the /etc/init.d directory and set permissions to 755. This time, however, you must run the script yourself EVERY TIME THE PHONE BOOTS. You can do this by using your file explorer, if it supports executing scripts (see output below) or running the script via Terminal.

    Terminal: Run this command as root (type "su" and hit enter):
    Code:
    ./etc/init.d/fixUpdateService.sh
    Screenshot_2015_03_19_22_45_55.png


    File Explorer: I personally use FX (File Explorer), which is a wonderful app by the way, so the output in the screenshot below may be styled different but generally should appear the same:
    Screenshot_2015_03_19_22_42_50.png


    Method #3: Enabling SystemUpdateService via App

    Now, if you're a no frills kinda person, or just don't feel comfortable rummaging around in your filesystem or terminal, there is an app you can download called Disable Service which lets you do the same thing, just with a nice GUI. YOU MUST DO THIS EVERY TIME YOU REBOOT YOUR PHONE.

    Steps:
    1. Once installed, launch the app.
    2. Then click the "System" tab on the top right.
    3. Scroll down and select "Google Play services"
    4. Scroll down to "SystemUpdateService" and CHECK the box.
    5. Done!

    There you have it! Hope this helps!
    3
    Very strange...
    On my CM11 (20150105) the script wasn't working even when manually running it. I had to put everything after su -c in single quotes.
    Even then, when placed in /etc/init.d/ it was not fixing the problem after restart.
    Looks like the script is starting, but something is overriding the service settings later.
    So, here's what I did...
    Put the following script in /etc/init.d/99fixUpdateService:
    Code:
    #!/system/bin/sh
    /system/bin/sh /sdcard/fixUpdateService.sh &

    run this as root:
    Code:
    chown root:shell /etc/init.d/99fixUpdateService
    chmod 777 /etc/init.d/99fixUpdateService

    Put this in /sdcard/fixUpdateService.sh
    Code:
    #!/system/bin/sh
    sleep 60
    echo "Disabling SystemUpdateService Battery Drain"
    su -c 'pm enable com.google.android.gms/.update.SystemUpdateActivity'
    su -c 'pm enable com.google.android.gms/.update.SystemUpdateService'
    su -c 'pm enable com.google.android.gms/.update.SystemUpdateService$ActiveReceiver'
    su -c 'pm enable com.google.android.gms/.update.SystemUpdateService$Receiver'
    su -c 'pm enable com.google.android.gms/.update.SystemUpdateService$SecretCodeReceiver'
    su -c 'pm enable com.google.android.gsf/.update.SystemUpdateActivity'
    su -c 'pm enable com.google.android.gsf/.update.SystemUpdatePanoActivity'
    su -c 'pm enable com.google.android.gsf/.update.SystemUpdateService'
    su -c 'pm enable com.google.android.gsf/.update.SystemUpdateService$Receiver'
    su -c 'pm enable com.google.android.gsf/.update.SystemUpdateService$SecretCodeReceiver'
    echo "Script Execution Successful"

    What it does: the /etc/init.d/99fixUpdateService calls /sdcard/fixUpdateService.sh and immediately exits, while in the background /sdcard/fixUpdateService.sh waits 60 seconds and then enables the service.
    Seems to be working for my & my gf's N5.
    2
    Great!
    Method 1 doesn't work on hammerheadcaf 20150318 but Method 3 is working like a charm and the battery drain issue seems to be gone!
    And CyanogenMod is going to deal with this issue before long:
    http://review.cyanogenmod.org/#/c/91579/
    http://review.cyanogenmod.org/#/c/91021/

    Interesting, I'll try to see if I can edit the script to get it to work right. Make sure you enable the service with that app every time you reboot your phone.
    Also, I've been reading those CyanogenMod discussions. Very interesting. Hopefully they tackle the issue soon and the solution makes its way into other ROMs

    Hello...
    This only occurs in custom roms or it happens also in Stock Rom?
    Thank you...

    As far as I know, this bug only affects custom ROMs.
    2
    Okay I fixed the problem with a method that's not mentioned. I'll go through the steps of failing and how I succeeded.

    Apps used: X-plore (not compulsory), Root Explorer (compulsory), Terminal Emulator (duh), Disable Service (More useful to check if SystemUpdateService service for Google Play services is enabled or not, it's disabled by default if you have this problem.), ROM Toolbox Lite (How i fixed the problem)

    1) Pasted the (.sh) file into init.d, didn't work. (Method 1), check if init.d works for your system [http://forum.xda-developers.com/showthread.php?t=1933849]
    2) Made an init.d following this thread [http://forum.xda-developers.com/showthread.php?t=2326585] (Noob friendly!), didn't work. Let's call this script 99 (Hey at least you learned)
    3) Tried to use (su, chmod 777 filename) command in T.Emulator to change permissions for the 99 script, but it kept giving me 'Read-only system file (Pic attached below)
    4) Bought Root Explorer, checked the permissions for 99 script and changed it to 755, rebooted and didn't work. Changed to 777, rebooted and didn't work
    5) Downloaded Disable Service, and enabled SystemUpdateService in Google Play services manually for now.
    6) Checked and ran the script using (su, /etc/init.d/fixUpdateService.sh) and it ran, showing that the script has no problem
    7) Checked ROM Toolbox Lite and saw a section called Scripter. Hmm wonder what it does? Clicked in and it basically allows you to run script files, and even set them at boot! So I added the 99 script file in and set it to run at boot. Fixed.

    Screenshot_2015-07-20-23-44-02.png

    Screenshot_2015-07-20-23-44-37.png

    Screenshot_2015-07-20-23-50-29.png

    Screenshot_2015-07-20-23-50-44.png
    2
    I fix script to run on boot :)
    I can upload if you want ;)