Commit 22fb742e authored by pkotwicz's avatar pkotwicz Committed by Commit bot

Correctly enable WebAPK updates when "installation from unknown sources" is disabled

Installation / updating via Google Play does not require "Installation from
Unknown Sources" to be enabled to work. This CL enables updating WebAPKs if the
update is done via Google Play regardless of whether "Installation from Unknown
Sources" is enabled.

BUG=662149

Review-Url: https://codereview.chromium.org/2555333002
Cr-Commit-Position: refs/heads/master@{#439050}
parent ecd7aefb
......@@ -47,6 +47,17 @@ public class ChromeWebApkHost {
return isEnabledInPrefs();
}
// Returns whether updating the WebAPK is enabled.
public static boolean areUpdatesEnabled() {
if (!isEnabled()) return false;
// Updating a WebAPK without going through Google Play requires "installation from unknown
// sources" to be enabled. It is confusing for a user to see a dialog asking them to enable
// "installation from unknown sources" when they are in the middle of using the WebAPK (as
// opposed to after requesting to add a WebAPK to the homescreen).
return installingFromUnknownSourcesAllowed() || canUseGooglePlayToInstallWebApk();
}
/** Return whether installing WebAPKs using Google Play is enabled. */
public static boolean canUseGooglePlayToInstallWebApk() {
if (!isEnabled()) return false;
......
......@@ -210,13 +210,7 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer {
return true;
}
// Updating WebAPKs requires "installation from unknown sources" to be enabled. It is
// confusing for a user to see a dialog asking them to enable "installation from unknown
// sources" when they are in the middle of using the WebAPK (as opposed to after requesting
// to add a WebAPK to the homescreen).
if (!installingFromUnknownSourcesAllowed()) {
return false;
}
if (!ChromeWebApkHost.areUpdatesEnabled()) return false;
if (isShellApkVersionOutOfDate(info)) return true;
......
......@@ -319,6 +319,7 @@ public class WebApkUpdateManagerTest {
public void setUp() {
ContextUtils.initApplicationContextForTests(RuntimeEnvironment.application);
CommandLine.init(null);
ChromeWebApkHost.initForTesting(true);
registerWebApk(defaultManifestData(), WebApkVersion.CURRENT_SHELL_APK_VERSION);
Settings.Secure.putInt(RuntimeEnvironment.application.getContentResolver(),
......
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