From f8be8e51e1fa66674a2c0a593c2f629607e9235d Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 21 Apr 2020 11:57:10 -0700 Subject: [PATCH] Calculate oldPaths for out of date LoadedApks This was originally omitted because the only known case this branch was hit was after a package update, which would inherently change the code paths for the package. Thus, spending the time to calculate these oldPaths was worthless because they would never be applicable. Seemingly this case where the paths are not changed has been found, causing duplicate paths to be added to the same ClassLoader. This warrants further investigation to determine why, but for now, this should be safe to commit to fix the issue. Bug: 149410951 Test: manual used steps at b/149410951#comment57, verified that paths were not added multiple times; device functions as normal otherwise Change-Id: I632994dd19cae2b0101d7386826c8f8c7251051a --- core/java/android/app/ActivityThread.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 21b56d3e337f0..25b92c9a5cb02 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2238,7 +2238,9 @@ public final class ActivityThread extends ClientTransactionHandler { LoadedApk packageInfo = ref != null ? ref.get() : null; if (ai != null && packageInfo != null) { if (!isLoadedApkResourceDirsUpToDate(packageInfo, ai)) { - packageInfo.updateApplicationInfo(ai, null); + List oldPaths = new ArrayList<>(); + LoadedApk.makePaths(this, ai, oldPaths); + packageInfo.updateApplicationInfo(ai, oldPaths); } if (packageInfo.isSecurityViolation() @@ -2326,7 +2328,9 @@ public final class ActivityThread extends ClientTransactionHandler { if (packageInfo != null) { if (!isLoadedApkResourceDirsUpToDate(packageInfo, aInfo)) { - packageInfo.updateApplicationInfo(aInfo, null); + List oldPaths = new ArrayList<>(); + LoadedApk.makePaths(this, aInfo, oldPaths); + packageInfo.updateApplicationInfo(aInfo, oldPaths); } return packageInfo;