From fa5ab2d27bbf7520b31b4a188d91294b7d71e4f8 Mon Sep 17 00:00:00 2001 From: Paul Hobbs Date: Tue, 29 Jun 2021 19:54:32 +0000 Subject: [PATCH] Revert "Apply overlay changes with config change" Revert submission 15058002 Reason for revert: Causes crash in com.android.cts.splitapp, breaks android.appsecurity.cts.SplitTests#testFeatureWithoutRestart_full. Bug: 192242649 Reverted Changes: Icf81845da:Apply overlay changes with config change Iea54abf38:Version LoadedApk cache using base code path I986563142:Revert "Deprecate Context#createApplicationContext... Change-Id: Ifb30daa85d9de4587bc39e074341ebdefaf26f84 --- core/java/android/app/ActivityThread.java | 1 - core/java/android/app/ResourcesManager.java | 43 +++---------------- .../com/android/server/am/ProcessList.java | 5 ++- .../server/wm/ActivityTaskManagerService.java | 12 +++--- 4 files changed, 14 insertions(+), 47 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 4182ac3e572dd..f71e9fd033dae 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1182,7 +1182,6 @@ public final class ActivityThread extends ClientTransactionHandler } public void scheduleApplicationInfoChanged(ApplicationInfo ai) { - mResourcesManager.updatePendingAppInfoUpdates(ai); mH.removeMessages(H.APPLICATION_INFO_CHANGED, ai); sendMessage(H.APPLICATION_INFO_CHANGED, ai); } diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index 4984577ac1533..f28c760d54d95 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -98,12 +98,6 @@ public class ResourcesManager { */ private int mResDisplayId = DEFAULT_DISPLAY; - /** - * ApplicationInfo changes that need to be applied to Resources when the next configuration - * change occurs. - */ - private ArrayList mPendingAppInfoUpdates; - /** * A mapping of ResourceImpls and their configurations. These are heavy weight objects * which should be reused as much as possible. @@ -1038,7 +1032,7 @@ public class ResourcesManager { * @param classLoader The classloader to use for the Resources object. * If null, {@link ClassLoader#getSystemClassLoader()} is used. * @return A Resources object that gets updated when - * {@link #applyConfigurationToResources(Configuration, CompatibilityInfo)} + * {@link #applyConfigurationToResourcesLocked(Configuration, CompatibilityInfo)} * is called. */ @Nullable @@ -1165,8 +1159,8 @@ public class ResourcesManager { /** * Updates an Activity's Resources object with overrideConfig. The Resources object * that was previously returned by {@link #getResources(IBinder, String, String[], String[], - * String[], String[], Integer, Configuration, CompatibilityInfo, ClassLoader, List)} is still - * valid and will have the updated configuration. + * String[], Integer, Configuration, CompatibilityInfo, ClassLoader, List)} is still valid and + * will have the updated configuration. * * @param activityToken The Activity token. * @param overrideConfig The configuration override to update. @@ -1317,22 +1311,6 @@ public class ResourcesManager { return newKey; } - public void updatePendingAppInfoUpdates(@NonNull ApplicationInfo appInfo) { - synchronized (mLock) { - if (mPendingAppInfoUpdates == null) { - mPendingAppInfoUpdates = new ArrayList<>(); - } - // Clear previous app info changes for the package to prevent multiple ResourcesImpl - // recreations when only the last recreation will be used. - for (int i = mPendingAppInfoUpdates.size() - 1; i >= 0; i--) { - if (appInfo.sourceDir.equals(mPendingAppInfoUpdates.get(i).sourceDir)) { - mPendingAppInfoUpdates.remove(i); - } - } - mPendingAppInfoUpdates.add(appInfo); - } - } - public final boolean applyConfigurationToResources(@NonNull Configuration config, @Nullable CompatibilityInfo compat) { return applyConfigurationToResources(config, compat, null /* adjustments */); @@ -1346,18 +1324,7 @@ public class ResourcesManager { Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "ResourcesManager#applyConfigurationToResources"); - final boolean assetsUpdated = mPendingAppInfoUpdates != null - && config.assetsSeq > mResConfiguration.assetsSeq; - if (assetsUpdated) { - for (int i = 0, n = mPendingAppInfoUpdates.size(); i < n; i++) { - final ApplicationInfo appInfo = mPendingAppInfoUpdates.get(i); - applyNewResourceDirs(appInfo, new String[]{appInfo.sourceDir}); - } - mPendingAppInfoUpdates = null; - } - - if (!assetsUpdated && !mResConfiguration.isOtherSeqNewer(config) - && compat == null) { + if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) { if (DEBUG || DEBUG_CONFIGURATION) { Slog.v(TAG, "Skipping new config: curSeq=" + mResConfiguration.seq + ", newSeq=" + config.seq); @@ -1400,7 +1367,7 @@ public class ResourcesManager { } } - return assetsUpdated || changes != 0; + return changes != 0; } finally { Trace.traceEnd(Trace.TRACE_TAG_RESOURCES); } diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 1b67679b56d6d..8ebc987a59f46 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -4698,10 +4698,10 @@ public final class ProcessList { final ApplicationInfo ai = AppGlobals.getPackageManager() .getApplicationInfo(packageName, STOCK_PM_FLAGS, app.userId); if (ai != null) { + app.getThread().scheduleApplicationInfoChanged(ai); if (ai.packageName.equals(app.info.packageName)) { app.info = ai; } - app.getThread().scheduleApplicationInfoChanged(ai); targetProcesses.add(app.getWindowProcessController()); } } catch (RemoteException e) { @@ -4712,7 +4712,8 @@ public final class ProcessList { }); } - mService.mActivityTaskManager.updateAssetConfiguration(targetProcesses, updateFrameworkRes); + mService.mActivityTaskManager.updateAssetConfiguration( + updateFrameworkRes ? null : targetProcesses); } @GuardedBy("mService") diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 8078c78dfdc8c..5e75cebc322df 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -4146,21 +4146,21 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { /** * Update the asset configuration and increase the assets sequence number. - * @param processes the processes that needs to update the asset configuration + * @param processes the processes that needs to update the asset configuration, if none + * updates the global configuration for all processes. */ - public void updateAssetConfiguration(List processes, - boolean updateFrameworkRes) { + public void updateAssetConfiguration(List processes) { synchronized (mGlobalLock) { final int assetSeq = increaseAssetConfigurationSeq(); - if (updateFrameworkRes) { + // Update the global configuration if the no target processes + if (processes == null) { Configuration newConfig = new Configuration(); newConfig.assetsSeq = assetSeq; updateConfiguration(newConfig); + return; } - // Always update the override of every process so the asset sequence of the process is - // always greater than or equal to the global configuration. for (int i = processes.size() - 1; i >= 0; i--) { final WindowProcessController wpc = processes.get(i); wpc.updateAssetConfiguration(assetSeq);