[6.0.x][FIX] Google Play Services battery drain / Optimization - Galaxy S 4 General

I was having heavy battery drain from Google Play Services so I searched around and found nothing that would solve my problem. But then I saw the light in the end of the tunnel and it wasn't a train.
The problem was that the Google Play Services couldn't be optimized, generating massive wake locks. So all I had to do is allow it to be optimized editing a single file.
What you'll need: a root file manager (I use Root Browser)
Go to /system/etc/sysconfig, find the file google.xml and edit it
Find the following lines:
Code:
<!-- GmsCore must always have network access for GCM and other things. -->
<allow-in-power-save package="com.google.android.gms" />
Comment the second line so both will look like this:
Code:
<!-- GmsCore must always have network access for GCM and other things. -->
<!-- <allow-in-power-save package="com.google.android.gms" /> -->
Reboot your phone and see if Google Play Services can be optimized now (or is already optimized) in Settings>Battery>3 dot menu>Battery Optimization.
You can confirm after some use that under the Google Play Services battery details the Keep Awake and the Computed Power Use will be much less than before.
It worked on my I9505 running latest JDCTeam's AOSP 6.0.1 with OpenGapps AROMA package.
Didn't had any crashes, delayed WhatsApp messages or any other issue 'til now (almost 2 days).

Thanks for pointing us this tweak.
My 2 cents : after reading some articles, I would underline also this method could lead to drawback on apps based upon GCM. Better to know it before
Optimizing Play services may cause unforeseen consequences (including Android Device Manager or device tracking apps not functioning appropriately). You are advised to calculate the number of installed apps which depends upon Google Cloud Messaging and would be affected by this move.
Click to expand...
Click to collapse
More reading here

Manfrowar said:
I was having heavy battery drain from Google Play Services so I searched around and found nothing that would solve my problem. But then I saw the light in the end of the tunnel and it wasn't a train.
The problem was that the Google Play Services couldn't be optimized, generating massive wake locks. So all I had to do is allow it to be optimized editing a single file.
What you'll need: a root file manager (I use Root Browser)
Go to /system/etc/sysconfig, find the file google.xml and edit it
Find the following lines:
Comment the second line so both will look like this:
Reboot your phone and see if Google Play Services can be optimized now (or is already optimized) in Settings>Battery>3 dot menu>Battery Optimization.
You can confirm after some use that under the Google Play Services battery details the Keep Awake and the Computed Power Use will be much less than before.
It worked on my I9505 running latest JDCTeam's AOSP 6.0.1 with OpenGapps AROMA package.
Didn't had any crashes, delayed WhatsApp messages or any other issue 'til now (almost 2 days).
Click to expand...
Click to collapse
Can you confirm if this works on Nougat? I tried this teak on RR 7.1.1 to no avail. I even deleted the GMS line but after a reboot, GMS is still whitelisted on doze. Thanks.

Google Play Services Optimization
Google Play Services Optimization /system/etc/sysconfig /google.xml and edit it
<!-- GmsCore must always have network access for GCM and other things. -->
<!-- <allow-in-power-save package="com.google.android.gms" /> -->
<allow-in-data-usage-save<!-- package="com.google.android.gms" />
Reboot phone and see if G.P.Services can be optimized now (or is already optimized) Settings>Battery>3 dot menu>Battery Optimization.

Related

Best Battery saver tweak: Google services

Go to google services (through battery icon or through applications)
Section: data use
Scroll down
Configure Background access to only over Wi-Fi
and the battery will last a long long time like never before.
You can eventually update to the latest Google service here:
http://www.apkmirror.com/apk/google-...play-services/
Choose the version that suits your device
I can't find google services on TouchWiz

Any way to disable "you must have Google play services to run (name of app that doesn

Any way to disable "you must have Google play services to run (name of app that doesn
Title cut off, rest should say "doesn't require Google play services to run"
I only use the play store basically, and have no issues with manually enabling before checking for app updates or to download new apps (on my newer device, my older device doesn't even require them for the play store at all)
But things like ccleaner, my emoji keyboard, a few other apps I can't think, of annoyingly claim to need these services to run... While I'm actively running them and using them just fine without.
On a device without the option "disable notifications for this app"either within the app itself, or within my older 4.0.4 device that runs just fine despite it being older... How can I get rid of these annoyances?
Play services are a huge battery and ram hog which I keep disabled unless needed. So any "just install play services" comments isn't exactly what I'm looking for...
I've looked around in disable service (the app) for these apps, unable to find anything looking relevant.
Any help would be appreciated
Play Services are often used for authentication reasons. Meaning the apps look if you have a genuine version. For freemium apps they check for any in app purchases you might have done.
Other common cases are for push notifications or location services etc. These are often only minor or optional features of apps. That's why they usually work nonetheless without having Play Services active.
The only easy option is to use an alternative app store like the Amazon App Store or F-Droid. All the apps over there are pretty much guaranteed to work without Play Services.
There are also some projects out there that aim for a system without Play Services. A quick search should yield quite some results.
If you are rooted and capable of using XPosed, then there is a module in the repo somewhere that does exactly what you are looking for - hiding the pop up.
Can't remember the name right now and don't know if it is still maintained, but searching the modules should provide it to you.
However, Google Play Service shouldn't be so much of a power drainer any more. Beginning with Android 6 / M the battery optimizations are quite enormous, even though the Play Services are excluded from the system wide optimization (because they take care of these optimizations). To further improve the footprint, you could disable the location services and wireless scanning services.

Google Play Services reboots phone every midnight to push system update I don't want.

Ok, I've got a Blu Life One X3 with BLU_L0150WW_V7.0.04.13_GENERIC ROM, Android Nougat 7.0.04.13, rooted with TWRP as bootloader and Magisk as root. AFWall+ is the iptables firewall, and the systemless Xposed Framework is installed as a module in Magisk.
All syncing is turned off and disabled, most of the Google pre-installed apps have been removed from the phone. Only the following remain:
Google Services Framework
Google Play Store
Google Play Services
Google Partner Setup
Google Account Manager
Contacts
Google Phone (merely because I can't find contacts and dialer that properly hook into Android... I will eventually)
Removed:
Google Chrome (internet activity tracking)
Google Tag Manager (tag & pixel tracking)
Google Play Music (lifestyle demography)
Google Play Movies & TV (lifestyle demography)
Google Maps (location tracking)
Google - Quick Search Box (search tracking)
Google YouTube (lifestyle demography)
Google TalkBack / Android Accessibility Suite
Google Drive (lifestyle demography)
Google Duo (audiovisual demography)
Google Contacts Sync (association demography)
Google Backup Transport
Google Market Feedback Agent
Google Calculator
Google Calendar (lifestyle demography)
Google Gmail (lifestyle and association demography)
Google Text-To-Speech
Google Japanese Input
Google SMS - Messages (SMS tracking)
Google Photos (lifestyle demography)
Google Carrier Services
OK Google voice assistant (audio monitoring)
Work Profile Setup
GBoard Google Keyboard (keylogger tracking)
ASIDE:
----------
Yes, GBoard logs keystrokes... Google's own privacy statement about the keyboard reads: "Gboard will remember words you type to help you with spelling or to predict searches you might be interested in."
Maybe you trust that "spelling or to predict searches" is all Google is using their keylogger keyboard for, but I don't.
----------
I've been browsing through the phone's file system, doing a lot of research, and editing .xml files to disable all the jobs that Google starts when the phone boots, and to retract permissions that Google has taken the liberty of using... this reduces CPU utilization and increases battery life. The phone works beautifully, doing what I want it to do (and nothing more), and going for days before requiring a charge.
I've seen no adverse effects from this, save for the issue at hand... that of Google Play Services trying to push a new ROM (BLU_L0150WW_V7.0.04.14_GENERIC), despite me having disabled OTA updates and Google Play Store automatic updates. Google Play Services reboots my phone at midnight each night in attempting to install the update, against my will and without my express consent.
When Google becomes the data-filching malware you cannot turn off, it's time to put Google on a short leash.
Google Play Services downloads via WiFi a .zip file named update_s.zip to /cache, then reboots the phone at midnight. It expects to reboot to fastboot, but that no longer works because I've got TWRP as bootloader, so it boots to the main TWRP screen and just sits there until I reboot it. If the update_s.zip file is allowed to remain in /cache until the next night, Google Play Services won't re-download it, it'll simply reboot the phone in attempting to install it.
I've removed Scheduled Power On/Off (package:/system/vendor/app/SchedulePowerOnOff/SchedulePowerOnOff.apk=com.mediatek.schpwronoff), so it cannot be the cause of the reboots, it's definitely Google Play Services. I've watched system activity via adb logcat and can clearly see that the culprit is Google Play Services.
Even if the update could successfully execute, I wouldn't install it... why is Google pushing a phone manufacturer's ROM, and why are they doing so against my will and in contradiction to the disabled OTA and Google Play Store automatic updates? Why didn't Blu push the update? I suspect they're pushing the ROM to get their permissions back... I'm no longer a cash cow for them, and they desperately want to make money off my info.
I see no way of disabling this behavior, and I've certainly not authorized Google to push system updates to my phone, nor to reboot my phone... they must be brought to heel and forced (via litigation, if necessary) to respect personal property rights. This is illegal under California Penal Code 502(c), Comprehensive Computer Data Access and Fraud Act.
This is tantamount to a mechanic creeping into someone's garage at midnight each night and letting the air out of someone's car tires because that someone doesn't use that mechanic's services. This is tantamount to a refrigerator manufacturer sneaking into someone's home at midnight each night and unplugging the refrigerator because it's made by another manufacturer.
How do I disable this behavior?
So far, the only thing in the file system that I can find that pertains to this is:
/service_contexts
#Other Services
GoogleOtaBinder ubject_rta_agent_service:s0
Anyone know what this is? I can pull the file to the computer in TWRP Recovery Mode, comment out that line and push it back to the phone to see if that ends the behavior. Before I do so, though, I'm going to wait until tomorrow... tonight, I've deleted the /cache/update_s.zip file, and I'm keeping internet connections down (and, for good measure, the firewall in lockdown mode), to see how Google Play Services reacts.
I'm betting it'll do this when that line is commented out:
Code:
private boolean setInstallInfo(String strPkgPath, String strTarVer) {
Xlog.i(TAG, "onSetRebootRecoveryFlag");
try {
IBinder binder = ServiceManager.getService("GoogleOtaBinder");
SystemUpdateBinder agent = SystemUpdateBinder.Stub.asInterface(binder);
if (agent == null) {
Xlog.e(TAG, "agent is null");
return false;
The phone did not reboot last night with update_s.zip deleted from /cache and all internet connections down.
This means Google Play Services is performing unannounced, unsolicited and unwanted remote operations upon a computer system, while disregarding the 'Settings' > 'Developer Options' > 'Automatic System Updates' being disabled, a blatant violation of CA Penal Code 502(c). Anyone up for a class-action lawsuit?
Google Play Services / GoogleOtaBinder doesn't query the 'Automatic System Updates' setting prior to performing its above-described operations, and I have a hard time believing this was just an oversight on the part of Google... it would seem far more likely (given that they're a multi-billion dollar company which hires highly competent programmers, given that they have a financial incentive to regain deleted apps or retracted permissions which a knowledgeable user might delete / retract, given the unannounced nature of the operations they're attempting, given the midnight time at which they're attempting to perform those operations) that the bypassing of the 'Automatic System Updates' setting is quite intentional as means of Google surreptitiously regaining apps deleted or permissions retracted so they can continue to gather personal data via the phone.
Tonight I'm disabling the registration of the service context for GoogleOtaBinder... let's see what kind of fits Google Play Services throws. :silly:
{EDIT}
Hrmph... /service_contexts is written to during boot to register Google's service contexts... I'm going to have to dig a bit deeper to permanently disable GoogleOtaBinder.
Until then, I'm renaming /system/etc/security/otacerts.zip so GoogleOtaBinder cannot communicate with the OTA update server.
There remains the nagging questions:
- Why does Google's OTA system updater disregard user settings which disable automatic system updates?
- Why does Google reboot the phone unannounced?
- Why does Google reboot the phone unannounced, at midnight, when the phone is least likely to be monitored?
- Why does Google dynamically write GoogleOtaBinder into /service_contexts at boot, rather than hard-coding it in so it can easily be commented out, thereby disabling Google OTA updates?
- Why doesn't Google provide a user-interface-accessible means of turning off Google OTA updates?
Well, that did the trick. Renaming /system/etc/security/otacerts.zip so GoogleOtaBinder cannot communicate with the OTA update server does away with Google Play Services' attempts at forcing a system update.
Now to dig into the files and figure out where they're writing to /service_contexts from during boot. I'm going to pull every bit of the Google-weed out by the roots that I can.

Installation of google play services for a specific user profile

I wonder if I can create two (or more) user profiles on my android device, one of which I will use only open source stuff and everything else on the other.
As far as I know, it is possible to create several user profiles in Android that are isolated from each other.
I would probably install LineageOS for this as it doesn't have google play services pre-installed on it and it seems very "clean" in terms of these things (I have never used this system).
There is something like OpenGApps that allows you to install google play services but as far as I know it requires installation from twrp. So I suspect google play services will then be installed for all user profiles on the device.
So is there any possibility to install google services for one user only?
I also know that there is such a thing as microg (and Aurora stora). When I heard that there was such a thing as "LineageOS for microG" I thought it would be a very good option (on one android profile I just wouldn't use microg). But later I also found out that it is supposedly against the google policy and that they can ban my account for it, which I would prefer to avoid.
So I wanted to ask if the only option to do this is to install LineageOS, check what applications are installed by default, install OpenGApps to it and then disable all google related applications on one of the user profiles?
Does such disabling the application also ensure that Google will not be able to "work" on my device in any way? Does OpenGApps install any system level google stuff that will run in the background anyway?
And are OpenGApps not something that I should not install when I don't want to get a google ban?
You are confusing (Open)GApps - Google themselves call them Google Mobile Services (GMS) - and Google Play Services what are two completely different things.
Google Play Services is one of the most important parts of Android. It helps connect everything together and hold it all there. The Google Play Services are the interface to the Google Mobile Services as well as to the hardware functions of the Android device. Many of your apps use Google Play Services everyday.
GMS is a bunch of apps what includes
Google Play Store,
Google Now,
Google Play Music,
Google Maps,
Google+,
Gmail,
Google Photos,
Youtube
and the Android Device Manager.
Knowing the difference it should be clear that GMS can get installed on a per-user basis whereas Google Play Services not.
jwoegerbauer said:
You are confusing (Open)GApps - Google themselves call them Google Mobile Services (GMS) - and Google Play Services what are two completely different things.
Google Play Services is one of the most important parts of Android. It helps connect everything together and hold it all there. The Google Play Services are the interface to the Google Mobile Services as well as to the hardware functions of the Android device. Many of your apps use Google Play Services everyday.
GMS is a bunch of apps what includes
Google Play Store,
Google Now,
Google Play Music,
Google Maps,
Google+,
Gmail,
Google Photos,
Youtube
and the Android Device Manager.
Knowing the difference it should be clear that GMS can get installed on a per-user basis whereas Google Play Services not.
Click to expand...
Click to collapse
Thanks for the clarification, although I still don't really know what you meant. I thought that google play services is the name for all those components that are needed to run, for example, the google play store. If the google play store needs also other components (?), then when I wrote google play services, I meant all the components that are needed to run the play store.
In any case, I mean in practice whether I am able to install both the play store and the components needed for it only for one user in Android, but from what I understand it is not possible in your opinion.
The questions at the end of my post probably still remain the same. I can only clarify that I meant more general cases in these questions:
Does installing the play store (along with the necessary components) install any system-level Google stuff that will run in the background anyway even if I disable these apps?
And isn't installing the play store (along with the necessary components) by hand something that I shouldn't be doing when I want to avoid a Google ban?
Again:
Google Play Store simply is an ordinary user app as any other user app, too, nothing else. It itself installs , except some Android OS libraries, nothing. Only thing is it requires Google Play Services ( which are running in background ) to properly run. As already said: Google Play Services can only get installed once because it extends Android OS. And Android OS always is the same for all created users.
Don't understand what you mean with "Google ban".
Dani3I said:
I would probably install LineageOS for this as it doesn't have google play services pre-installed on it and it seems very "clean" in terms of these things (I have never used this system).
There is something like OpenGApps that allows you to install google play services but as far as I know it requires installation from twrp. So I suspect google play services will then be installed for all user profiles on the device.
So is there any possibility to install google services for one user only?
Click to expand...
Click to collapse
You can install those apps but you have to flash it via recovery. Also, you need to do that prior to booting into the os for the first time, which I think is related to encryption.
If you already booted into your os, you need to boot into recovery and perform a factory data reset, then flash those gapps (as far as I know dirty flashing those gapps will introduce instability to those gapps. That's why you need a factory data reset).
Keep in mind that factory reseting will delete all your person data.
After you flashed it, those gapps will be available for every user
Dani3I said:
I also know that there is such a thing as microg (and Aurora stora). When I heard that there was such a thing as "LineageOS for microG" I thought it would be a very good option (on one android profile I just wouldn't use microg). But later I also found out that it is supposedly against the google policy and that they can ban my account for it, which I would prefer to avoid.
Click to expand...
Click to collapse
Aurora Store provides an anonymous google account. It's data isn't linked to you which means they cannot ban your account.
Dani3I said:
So I wanted to ask if the only option to do this is to install LineageOS, check what applications are installed by default, install OpenGApps to it and then disable all google related applications on one of the user profiles?
Click to expand...
Click to collapse
LOS comes without any google apps preinstalled. So first flash LOS, then OpenGApps (follow their official guide. They describe it there).
And yes, after that you have to disable every google app you don't want to use for every new user profile.
Dani3I said:
Does such disabling the application also ensure that Google will not be able to "work" on my device in any way? Does OpenGApps install any system level google stuff that will run in the background anyway?
Click to expand...
Click to collapse
If you disable it for the current user, it won't run in any way, yes.
OpenGApps itself shouldn't install anything on system level. But those apps will be installed on system level since you flash them to the system (using your recovery). However, if you disable them they won't run in the background.
Dani3I said:
And are OpenGApps not something that I should not install when I don't want to get a google ban?
Click to expand...
Click to collapse
I don't know.
jwoegerbauer said:
You are confusing (Open)GApps - Google themselves call them Google Mobile Services (GMS) - and Google Play Services what are two completely different things.
Google Play Services is one of the most important parts of Android. It helps connect everything together and hold it all there. The Google Play Services are the interface to the Google Mobile Services as well as to the hardware functions of the Android device. Many of your apps use Google Play Services everyday.
GMS is a bunch of apps what includes
Google Play Store,
Google Now,
Google Play Music,
Google Maps,
Google+,
Gmail,
Google Photos,
Youtube
and the Android Device Manager.
Knowing the difference it should be clear that GMS can get installed on a per-user basis whereas Google Play Services not.
Click to expand...
Click to collapse
Yep that's absolutely correct

google play services debug

is there any way to find out (debug) which app is causing google play services to drain battery in background ?
apart from trial and error of course ?
my guesses in my case are telegram (with a few bot notifications including pictures) / spotify running in background
tried clearing up cache, readd google account, disabled sync, everything same drain (2-3%/h)
nobody got a smart way to see which app causes google play services to missbehave?
As long as a service / app is running - where it doesn't matter whether in background or in foreground - battery gets drained.
common sense this. but how do i know which app is causing this drain to gms ?
My guess is you're confusing things:
GMS stands for Google Mobile Services and is essentially a bundle of applications and APIs ( application programming interfaces ) installed at the system level. This essentially means that they are deeply integrated with the operating system.
The list of apps tied together with GMS you surely can find on Internet.
Google Play Services is a proprietary background service and API package produced by Google for Android devices. It was introduced in 2012, it is allowing applications to communicate with the services through common means.
To check whether an app makes use of Google Play Services or not you would do a LOGCAT.

Categories

Resources