Thursday, March 3, 2016

6.0 marshmallow - How to make Google Play services and other default white-listed system apps Doze?


Assume that I'm a user who doesn't like some system apps being automatically white-listed under Battery optimization settings and immune from battery optimization or is fed up with Play services consuming more than its fair share of battery. I'm looking for a solution which would revoke this privilege enjoyed by those apps and add them into the line where the rest of the ordinary comrade apps are waiting for the user to mark them with Don't optimize.


(Click image to enlarge)


IMG:



I've already seen this answer and as noted in a comment it doesn't work for apps white-listed by system.


As of now, these are the apps white-listed by Android 6.0.1 in my rooted Nexus 6:


IMG


I'm most interested in removing com.google.android.gms.



Answer



Requisites



  • A rooted Android


Optional:




  • A full ROM backup made through a custom recovery. It is for your own convenience. If something suggested in the next section causes boot issues or system/app crashes, you would have something good to fallback to earlier state.


  • 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. The answers here may help: Is there a way to see which apps are using GCM?


    I preferred my own answer for simplicity.






FOR AVOIDING THE HASSLE


If you are targeting only Google Play Services and wants to avoid the hassle of editing system files, you can use Enable Doze for GMS or SysConfig Patcher Magisk Module. You would be needing Magisk framework and Magisk Manager.





As I noted here, Google Play services is white-listed by Google through the file google.xml located under /system/etc/sysconfig/. Among other things, the file notes:




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

Comment out the highlighted line using at the end. The line should now look like:






(Click an image to enlarge it)


IMG: IMG:


Reboot the device and behold Google Play services now not available under Not optimized tab but available for optimization.


(Click an image to enlarge it)


IMG: IMG:


I observed that the list of apps decreased too:


IMG


Note: I used ES File Explorer to browse to the directory /system/etc/sysconfig and used QuickEdit to edit google.xml. It is not mandatory to use these tools. You can use whatsoever you find convenient.


Now, for the rest of the names in the list, refer to corresponding files noted below:




  • com.android.providers.downloads : /system/etc/permissions/platform.xml

  • com.android.vending: /system/etc/sysconfig/google.xml -- I noticed that dealing with Google Play services automatically removed Play Store from the list

  • com.google.android.apps.tycho : /system/etc/sysconfig/google_build.xml

  • com.android.omadm.service : /system/etc/sysconfig/whitelist_com.android.omadm.service.xml.


Comment out the appropriate line, reboot and your tweak should work.


Note: I've extrapolated my findings with Google Play services here.


SystemConfig.java is used to read configuration from the directory /system/etc/permissions and /system/etc/sysconfig. So, if you have a white-listed system app not manually added and not covered in this answer, then focus your search into those two directories at first.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...