Add shell command for turning on/off WebView multiprocess.
Now that we are removing the WebView Multiprocess Developer Setting we
instead add a couple of shell commands for debugging purposes:
adb shell cmd webviewupdate enable-multiprocess
adb shell cmd webviewupdate disable-multiprocess
We also ensure that multiprocess for WebView is enabled after this
change - even if the user disabled it earlier.
Bug: 36513859
Test: Run WebViewUpdateServiceTest tests.
Test: Ensure disabling/enabling multiprocess through the new adb
commands causes WebViewZygote to be used accordingly, and kills apps
using WebView.
Test: Disable multiprocess on a previous OC-build, then flash a build
with this change in it, and ensure multiprocess is turned on
(multiprocess is currently on by default for all devices).
Change-Id: I923198781777e33848b671ec44f50bbc65b43e24
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
index 114c362..b1acbec 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl.java
@@ -26,6 +26,7 @@
import android.webkit.WebViewProviderResponse;
import java.io.PrintWriter;
+import java.lang.Integer;
import java.util.List;
/**
@@ -72,6 +73,9 @@
private WebViewUpdater mWebViewUpdater;
final private Context mContext;
+ private final static int MULTIPROCESS_SETTING_ON_VALUE = Integer.MAX_VALUE;
+ private final static int MULTIPROCESS_SETTING_OFF_VALUE = Integer.MIN_VALUE;
+
public WebViewUpdateServiceImpl(Context context, SystemInterface systemInterface) {
mContext = context;
mSystemInterface = systemInterface;
@@ -234,31 +238,20 @@
}
boolean isMultiProcessEnabled() {
- PackageInfo current = getCurrentWebViewPackage();
- if (current == null) return false;
- int currentVersion = current.versionCode;
int settingValue = mSystemInterface.getMultiProcessSetting(mContext);
if (mSystemInterface.isMultiProcessDefaultEnabled()) {
- // Multiprocess should be enabled unless the user has turned it off manually for this
- // version or newer, as we want to re-enable it when it's updated to get fresh
- // bug reports.
- return settingValue > -currentVersion;
+ // Multiprocess should be enabled unless the user has turned it off manually.
+ return settingValue > MULTIPROCESS_SETTING_OFF_VALUE;
} else {
- // Multiprocess should not be enabled, unless the user has turned it on manually for
- // any version.
- return settingValue > 0;
+ // Multiprocess should not be enabled, unless the user has turned it on manually.
+ return settingValue >= MULTIPROCESS_SETTING_ON_VALUE;
}
}
void enableMultiProcess(boolean enable) {
- // The value we store for the setting is the version code of the current package, if it's
- // enabled, or the negation of the version code of the current package, if it's disabled.
- // Users who have a setting from before this scheme was implemented will have it set to 0 or
- // 1 instead.
PackageInfo current = getCurrentWebViewPackage();
- int currentVersion = current != null ? current.versionCode : 1;
mSystemInterface.setMultiProcessSetting(mContext,
- enable ? currentVersion : -currentVersion);
+ enable ? MULTIPROCESS_SETTING_ON_VALUE : MULTIPROCESS_SETTING_OFF_VALUE);
mSystemInterface.notifyZygote(enable);
if (current != null) {
mSystemInterface.killPackageDependents(current.packageName);