From 3286a5f61caf1b86ef4c27a8266128a619f88f82 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 20 Nov 2019 09:57:34 -0800 Subject: [PATCH] Fix "Allow the system AssetManager to be reinitialized for testing" The logic was incorrect and prevented the test from reinitializing the system assets. Bug: 136085555 Test: tradefed.sh Change-Id: If95417d29a8a1110560b670900a53ff3db2604a2 --- core/java/android/content/res/AssetManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 2d9ca67a236d2..168eae65ddf24 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -206,7 +206,7 @@ public final class AssetManager implements AutoCloseable { @VisibleForTesting public static void createSystemAssetsInZygoteLocked(boolean reinitialize, String frameworkPath) { - if (sSystem != null || reinitialize) { + if (sSystem != null && !reinitialize) { return; } @@ -225,7 +225,9 @@ public final class AssetManager implements AutoCloseable { sSystemApkAssetsSet = new ArraySet<>(apkAssets); sSystemApkAssets = apkAssets.toArray(new ApkAssets[apkAssets.size()]); - sSystem = new AssetManager(true /*sentinel*/); + if (sSystem == null) { + sSystem = new AssetManager(true /*sentinel*/); + } sSystem.setApkAssets(sSystemApkAssets, false /*invalidateCaches*/); } catch (IOException e) { throw new IllegalStateException("Failed to create system AssetManager", e);