Recheck the condition before really killing

Since the kill is asynchronously scheduled in the Handler, logically,
before scheduling, the process may be operated by the user to the
foreground or raising to an important ADJ and then be killed abnormally.

Bug: 235565625
Change-Id: Ied40d3ad22caa4d6c89055fdf85affb905d44d23
This commit is contained in:
desuo wang
2022-06-13 10:22:36 +08:00
parent 030c47cbfb
commit a2461a3faa

View File

@@ -14349,6 +14349,10 @@ public class ActivityManagerService extends IActivityManager.Stub
app.processName, app.toShortString(), cpuLimit, app)) {
mHandler.post(() -> {
synchronized (ActivityManagerService.this) {
if (app.getThread() == null
|| app.mState.getSetProcState() < ActivityManager.PROCESS_STATE_HOME) {
return;
}
app.killLocked("excessive cpu " + cpuTimeUsed + " during "
+ uptimeSince + " dur=" + checkDur + " limit=" + cpuLimit,
ApplicationExitInfo.REASON_EXCESSIVE_RESOURCE_USAGE,
@@ -14374,6 +14378,10 @@ public class ActivityManagerService extends IActivityManager.Stub
app.processName, r.toString(), cpuLimit, app)) {
mHandler.post(() -> {
synchronized (ActivityManagerService.this) {
if (app.getThread() == null
|| app.mState.getSetProcState() < ActivityManager.PROCESS_STATE_HOME) {
return;
}
mPhantomProcessList.killPhantomProcessGroupLocked(app, r,
ApplicationExitInfo.REASON_EXCESSIVE_RESOURCE_USAGE,
ApplicationExitInfo.SUBREASON_EXCESSIVE_CPU,