From e39801390563f3f6a67e06d1338d3f099a93f564 Mon Sep 17 00:00:00 2001 From: Jackal Guo Date: Thu, 9 Dec 2021 13:04:24 +0800 Subject: [PATCH] Mitigate the races during installation. During the installation of update, the application would be killed twice. The first one is done by PackageFreezer. It kills and freezes the application while starting installing. The second one happens just after the package is unfrozen. Since the application won't be able to be started when it's frozen. The second kill is a little overkill to me. It's possible that someone starts the application before the second kill comes. Skip the second kill to mitigate the possible race. Bug: 165012101 Test: atest PackageManagerTest Change-Id: I5085547ba3f20c370474228deb13bbc24064ae21 --- .../java/com/android/server/am/ActivityManagerService.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index a33aa600febdf..fbaf2f04f7fc7 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -13372,12 +13372,7 @@ public class ActivityManagerService extends IActivityManager.Stub !intent.getBooleanExtra(Intent.EXTRA_DONT_KILL_APP, false); final boolean fullUninstall = removed && !replacing; if (removed) { - if (killProcess) { - forceStopPackageLocked(ssp, UserHandle.getAppId( - intent.getIntExtra(Intent.EXTRA_UID, -1)), - false, true, true, false, fullUninstall, userId, - removed ? "pkg removed" : "pkg changed"); - } else { + if (!killProcess) { // Kill any app zygotes always, since they can't fork new // processes with references to the old code forceStopAppZygoteLocked(ssp, UserHandle.getAppId(