OSDN Git Service

Register isolated UIDs before reporting process state
authorAdam Lesinski <adamlesinski@google.com>
Wed, 27 Jul 2016 19:25:00 +0000 (12:25 -0700)
committerAdam Lesinski <adamlesinski@google.com>
Wed, 27 Jul 2016 19:46:55 +0000 (12:46 -0700)
Isolated UIDs should be registered with a real app UID
before any process state changes are reported for them.

Bug:25195548
Change-Id: Id0d3a5373ca57d3725315b2d99e5f8e5286022c8

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

index 8e4af12..ae0ccd6 100644 (file)
@@ -3780,9 +3780,6 @@ public final class ActivityManagerService extends ActivityManagerNative
             checkTime(startTime, "startProcess: returned from zygote!");
             Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
 
-            if (app.isolated) {
-                mBatteryStatsService.addIsolatedUid(app.uid, app.info.uid);
-            }
             mBatteryStatsService.noteProcessStart(app.processName, app.info.uid);
             checkTime(startTime, "startProcess: done updating battery stats");
 
@@ -11457,6 +11454,14 @@ public final class ActivityManagerService extends ActivityManagerNative
                 // the uid of the isolated process is specified by the caller.
                 uid = isolatedUid;
             }
+
+            // Register the isolated UID with this application so BatteryStats knows to
+            // attribute resource usage to the application.
+            //
+            // NOTE: This is done here before addProcessNameLocked, which will tell BatteryStats
+            // about the process state of the isolated UID *before* it is registered with the
+            // owning application.
+            mBatteryStatsService.addIsolatedUid(uid, info.uid);
         }
         final ProcessRecord r = new ProcessRecord(stats, info, proc, uid);
         if (!mBooted && !mBooting