Mark persistent apps as such when the ProcessRecord is created
...rather than only during the OS's "time to start the persistent apps" boot phase. This closes a window of opportunity during which a persistent app container may be live without having been properly noted as such, because it wound up being launched prior to the [rather late] boot phase at which the persistent apps are directly enumerated and bookkeeping for them established. Bug 20855725 Change-Id: I41822b412de4540dbdeab300b38089303678f76c
This commit is contained in:
@@ -376,6 +376,10 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
// Delay in notifying task stack change listeners (in millis)
|
// Delay in notifying task stack change listeners (in millis)
|
||||||
static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 1000;
|
static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 1000;
|
||||||
|
|
||||||
|
// Necessary ApplicationInfo flags to mark an app as persistent
|
||||||
|
private static final int PERSISTENT_MASK =
|
||||||
|
ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT;
|
||||||
|
|
||||||
/** All system services */
|
/** All system services */
|
||||||
SystemServiceManager mSystemServiceManager;
|
SystemServiceManager mSystemServiceManager;
|
||||||
|
|
||||||
@@ -9871,10 +9875,10 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
String proc = customProcess != null ? customProcess : info.processName;
|
String proc = customProcess != null ? customProcess : info.processName;
|
||||||
BatteryStatsImpl.Uid.Proc ps = null;
|
BatteryStatsImpl.Uid.Proc ps = null;
|
||||||
BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
|
BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
|
||||||
|
final int userId = UserHandle.getUserId(info.uid);
|
||||||
int uid = info.uid;
|
int uid = info.uid;
|
||||||
if (isolated) {
|
if (isolated) {
|
||||||
if (isolatedUid == 0) {
|
if (isolatedUid == 0) {
|
||||||
int userId = UserHandle.getUserId(uid);
|
|
||||||
int stepsLeft = Process.LAST_ISOLATED_UID - Process.FIRST_ISOLATED_UID + 1;
|
int stepsLeft = Process.LAST_ISOLATED_UID - Process.FIRST_ISOLATED_UID + 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (mNextIsolatedProcessUid < Process.FIRST_ISOLATED_UID
|
if (mNextIsolatedProcessUid < Process.FIRST_ISOLATED_UID
|
||||||
@@ -9898,7 +9902,13 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
uid = isolatedUid;
|
uid = isolatedUid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ProcessRecord(stats, info, proc, uid);
|
final ProcessRecord r = new ProcessRecord(stats, info, proc, uid);
|
||||||
|
if (!mBooted && !mBooting
|
||||||
|
&& userId == UserHandle.USER_OWNER
|
||||||
|
&& (info.flags & PERSISTENT_MASK) == PERSISTENT_MASK) {
|
||||||
|
r.persistent = true;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ProcessRecord addAppLocked(ApplicationInfo info, boolean isolated,
|
final ProcessRecord addAppLocked(ApplicationInfo info, boolean isolated,
|
||||||
@@ -9930,8 +9940,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
+ info.packageName + ": " + e);
|
+ info.packageName + ": " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((info.flags&(ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT))
|
if ((info.flags & PERSISTENT_MASK) == PERSISTENT_MASK) {
|
||||||
== (ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) {
|
|
||||||
app.persistent = true;
|
app.persistent = true;
|
||||||
app.maxAdj = ProcessList.PERSISTENT_PROC_ADJ;
|
app.maxAdj = ProcessList.PERSISTENT_PROC_ADJ;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user