What is com.google.android.gms.persistent and why is it always using the CPU?
<p>Even when nothing else is happening this system process seems to use a steady 1-2% of the CPU.  Over the course of a day this drains a significant amount of battery even when the device wasn't used for anything. I haven't been able to correlate it to any other apps because even when they have only used a few seconds of CPU time each over the course of several hours this process is using minutes.</p>

<p>It still seems to run even if I:</p>

<ul>
<li>turn off WiFi</li>
<li>turn off BlueTooth</li>
<li>turn off location services</li>
<li>turn off everything except the most bare minimum of syncing (e.g. GMail)</li>
</ul>

<p>I wrote a little test app that monitors <code>/proc/&lt;pid&gt;/stat</code> every 10ms and writes to logcat any time <code>com.google.android.gms.persistent</code>, hoping that it would write something to logcat itself which would pinpoint what app or other service is using "persistent" for its services.  I don't see much, but here are a few things I did see:</p>

<pre><code>InputReader: Reconfiguring input devices.  changes=0x00000010
WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@f73f0b8}
LocationFilter: Forcing stable location. Original location:Location[...
ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 246]
</code></pre>

<p>Each line above was at a different time, immediately preceding (within 10ms of) a log message detecting CPU usage by <code>com.google.android.gms.persistent</code> but without any clear indication whether or not it is related.   Unfortunately, none of the above reports more than 10ms of CPU time taken, and so - even if accurate in denoting what is using "persistent" represents only a small portion of the actual CPU time being used.</p>

<p>Other attempts to research what uses this process have suggested various things (such as wearables) which I don't have and have never had connected to my device.</p>

<p>What is using this process?  I am looking either for this information directly, or for additional ways I can deduce this information similar to my attempts via logcat.</p>

<p>Update: I have been looking for the source (e.g. com.google.android.gms.persistent.java or something like that) on <a href="https://android.googlesource.com" rel="noreferrer">https://android.googlesource.com</a> without any luck. Is this not part of the public source code?  What is really strange is that there doesn't even appear to be any documentation, e.g. here: <a href="https://android.googlesource.com/platform/frameworks/base/+/33fca8e/docs/html/reference/com/google/android/gms" rel="noreferrer">https://android.googlesource.com/platform/frameworks/base/+/33fca8e/docs/html/reference/com/google/android/gms</a></p>

<p>Update 2: I disabled all syncing under Settings -> Accounts.  This seems to reduce CPU usage a bit more, and battery drop seems to have dropped to a crawl - except periodically com.google.android.gms.persistent still seems to take a burst of CPU.  </p>

<p>My working theory now is that it has an Alarm that is firing at approximately 60 second intervals regardless of whether it is needed or not, and that code is checking for syncing work, and if nothing needs to be synced it gives up the time slice right away and lets the CPU go right to sleep.  However, I halfway can't believe that such a horrible design would be used, as anything that wakes up the CPU every minute is sure to drain the battery a lot faster even if it just goes back to sleep, and why would polling be used instead of something interrupt driven for syncing anyway?</p>

<p>As far as I can tell (due to not being able to find it) the source code for com.google.android.gms.persistent is not open source or available online anywhere.  If I am wrong, I would accept as an answer to my question, any answer which would point to the source code as I could browse it and determine for myself why the CPU usage.</p>