OSDN Git Service

Don't touch usage stats before system ready
authorSvetoslav Ganov <svetoslavganov@google.com>
Wed, 28 Sep 2016 01:12:22 +0000 (18:12 -0700)
committerSvetoslav Ganov <svetoslavganov@google.com>
Thu, 29 Sep 2016 04:05:43 +0000 (04:05 +0000)
When a content provider is accessed we update its foreground
state and usage stats if the calling app is in the foreground.
However we install system providers before the
PHASE_SYSTEM_SERVICES_READY phase which means we cannot touch
the the usage stats service as it calls into the content
service triggering the sync manager creation before system
ready violating the contract of the latter causing cascading
issues.

bug:31562236

Change-Id: Ied446cf3de8949e0850bab8f2b92155eac793591

services/core/java/com/android/server/am/ActivityManagerService.java

index b623bc7..85d2981 100644 (file)
@@ -20669,8 +20669,11 @@ public final class ActivityManagerService extends ActivityManagerNative
             final long now = SystemClock.elapsedRealtime();
             Long lastReported = userState.mProviderLastReportedFg.get(authority);
             if (lastReported == null || lastReported < now - 60 * 1000L) {
-                mUsageStatsService.reportContentProviderUsage(
-                        authority, providerPkgName, app.userId);
+                if (mSystemReady) {
+                    // Cannot touch the user stats if not system ready
+                    mUsageStatsService.reportContentProviderUsage(
+                            authority, providerPkgName, app.userId);
+                }
                 userState.mProviderLastReportedFg.put(authority, now);
             }
         }