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

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:

<!-- GmsCore must always have network access for GCM and other things. -->
<allow-in-power-save package="com.google.android.gms" />

Comment out the highlighted line using <!-- at the start and --> at the end. The line should now look like:

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

(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.