Commit 801cc00b authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

Fix module install

Previously, we created a SplitInstallManager _before_ calling
SplitCompat.install(-), which breaks the module install flow on Android
pre-Q.

Bug: b/133669491
Change-Id: I0b317732ed364a592047eeb7387c74dd1ea1b258
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1646903
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarChristopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668416}
parent 05c5bcb7
...@@ -40,6 +40,7 @@ public class ModuleInstaller { ...@@ -40,6 +40,7 @@ public class ModuleInstaller {
/** Needs to be called before trying to access a module. */ /** Needs to be called before trying to access a module. */
public static void init() { public static void init() {
if (sSplitCompatted) return;
// SplitCompat.install may copy modules into Chrome's internal folder or clean them up. // SplitCompat.install may copy modules into Chrome's internal folder or clean them up.
try (StrictModeContext unused = StrictModeContext.allowDiskWrites()) { try (StrictModeContext unused = StrictModeContext.allowDiskWrites()) {
SplitCompat.install(ContextUtils.getApplicationContext()); SplitCompat.install(ContextUtils.getApplicationContext());
......
...@@ -91,6 +91,8 @@ import java.util.Set; ...@@ -91,6 +91,8 @@ import java.util.Set;
/** Records via UMA all modules that have been requested and are currently installed. */ /** Records via UMA all modules that have been requested and are currently installed. */
public static void recordModuleAvailability() { public static void recordModuleAvailability() {
// MUST call init before creating a SplitInstallManager.
ModuleInstaller.init();
SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
Set<String> requestedModules = new HashSet<>(); Set<String> requestedModules = new HashSet<>();
requestedModules.addAll( requestedModules.addAll(
...@@ -124,6 +126,8 @@ import java.util.Set; ...@@ -124,6 +126,8 @@ import java.util.Set;
public PlayCoreModuleInstallerBackend(OnFinishedListener listener) { public PlayCoreModuleInstallerBackend(OnFinishedListener listener) {
super(listener); super(listener);
// MUST call init before creating a SplitInstallManager.
ModuleInstaller.init();
mManager = SplitInstallManagerFactory.create(ContextUtils.getApplicationContext()); mManager = SplitInstallManagerFactory.create(ContextUtils.getApplicationContext());
mManager.registerListener(this); mManager.registerListener(this);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment