Loading core/java/android/webkit/WebViewDelegate.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.webkit; import static android.webkit.Flags.updateServiceV2; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; Loading Loading @@ -205,6 +207,9 @@ public final class WebViewDelegate { * Returns whether WebView should run in multiprocess mode. */ public boolean isMultiProcessEnabled() { if (updateServiceV2()) { return true; } try { return WebViewFactory.getUpdateService().isMultiProcessEnabled(); } catch (RemoteException e) { Loading core/java/android/webkit/WebViewZygote.java +13 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.webkit; import static android.webkit.Flags.updateServiceV2; import android.content.pm.PackageInfo; import android.os.Build; import android.os.ChildZygoteProcess; Loading Loading @@ -50,8 +52,8 @@ public class WebViewZygote { private static PackageInfo sPackage; /** * Flag for whether multi-process WebView is enabled. If this is {@code false}, the zygote * will not be started. * Flag for whether multi-process WebView is enabled. If this is {@code false}, the zygote will * not be started. Should be removed entirely after we remove the updateServiceV2 flag. */ @GuardedBy("sLock") private static boolean sMultiprocessEnabled = false; Loading @@ -73,11 +75,19 @@ public class WebViewZygote { public static boolean isMultiprocessEnabled() { synchronized (sLock) { if (updateServiceV2()) { return sPackage != null; } else { return sMultiprocessEnabled && sPackage != null; } } } public static void setMultiprocessEnabled(boolean enabled) { if (updateServiceV2()) { throw new IllegalStateException( "setMultiprocessEnabled shouldn't be called if update_service_v2 flag is set."); } synchronized (sLock) { sMultiprocessEnabled = enabled; Loading services/core/java/com/android/server/webkit/SystemImpl.java +18 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.webkit; import static android.webkit.Flags.updateServiceV2; import android.app.ActivityManager; import android.app.AppGlobals; import android.content.Context; Loading Loading @@ -237,18 +239,30 @@ public class SystemImpl implements SystemInterface { @Override public int getMultiProcessSetting(Context context) { return Settings.Global.getInt(context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, 0); if (updateServiceV2()) { throw new IllegalStateException( "getMultiProcessSetting shouldn't be called if update_service_v2 flag is set."); } return Settings.Global.getInt( context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, 0); } @Override public void setMultiProcessSetting(Context context, int value) { Settings.Global.putInt(context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, value); if (updateServiceV2()) { throw new IllegalStateException( "setMultiProcessSetting shouldn't be called if update_service_v2 flag is set."); } Settings.Global.putInt( context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, value); } @Override public void notifyZygote(boolean enableMultiProcess) { if (updateServiceV2()) { throw new IllegalStateException( "notifyZygote shouldn't be called if update_service_v2 flag is set."); } WebViewZygote.setMultiprocessEnabled(enableMultiProcess); } Loading services/core/java/com/android/server/webkit/WebViewUpdateService.java +26 −8 Original line number Diff line number Diff line Loading @@ -157,8 +157,13 @@ public class WebViewUpdateService extends SystemService { public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, String[] args, ShellCallback callback, ResultReceiver resultReceiver) { (new WebViewUpdateServiceShellCommand(this)).exec( this, in, out, err, args, callback, resultReceiver); if (updateServiceV2()) { (new WebViewUpdateServiceShellCommand2(this)) .exec(this, in, out, err, args, callback, resultReceiver); } else { (new WebViewUpdateServiceShellCommand(this)) .exec(this, in, out, err, args, callback, resultReceiver); } } Loading Loading @@ -275,18 +280,31 @@ public class WebViewUpdateService extends SystemService { @Override // Binder call public boolean isMultiProcessEnabled() { if (updateServiceV2()) { throw new IllegalStateException( "isMultiProcessEnabled shouldn't be called if update_service_v2 flag is" + " set."); } return WebViewUpdateService.this.mImpl.isMultiProcessEnabled(); } @Override // Binder call public void enableMultiProcess(boolean enable) { if (getContext().checkCallingPermission( if (updateServiceV2()) { throw new IllegalStateException( "enableMultiProcess shouldn't be called if update_service_v2 flag is set."); } if (getContext() .checkCallingPermission( android.Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: enableMultiProcess() from pid=" String msg = "Permission Denial: enableMultiProcess() from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; + ", uid=" + Binder.getCallingUid() + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; Slog.w(TAG, msg); throw new SecurityException(msg); } Loading services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java +5 −23 Original line number Diff line number Diff line Loading @@ -85,9 +85,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { private static final int VALIDITY_INCORRECT_SIGNATURE = 3; private static final int VALIDITY_NO_LIBRARY_FLAG = 4; private static final int MULTIPROCESS_SETTING_ON_VALUE = Integer.MAX_VALUE; private static final int MULTIPROCESS_SETTING_OFF_VALUE = Integer.MIN_VALUE; private final SystemInterface mSystemInterface; private final Context mContext; Loading Loading @@ -166,7 +163,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public void prepareWebViewInSystemServer() { mSystemInterface.notifyZygote(isMultiProcessEnabled()); try { synchronized (mLock) { mCurrentWebViewPackage = findPreferredWebViewPackage(); Loading Loading @@ -366,10 +362,8 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { // Once we've notified the system that the provider has changed and started RELRO creation, // try to restart the zygote so that it will be ready when apps use it. if (isMultiProcessEnabled()) { AsyncTask.THREAD_POOL_EXECUTOR.execute(this::startZygoteWhenReady); } } /** * Fetch only the currently valid WebView packages. Loading Loading @@ -632,25 +626,14 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public boolean isMultiProcessEnabled() { int settingValue = mSystemInterface.getMultiProcessSetting(mContext); if (mSystemInterface.isMultiProcessDefaultEnabled()) { // 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. return settingValue >= MULTIPROCESS_SETTING_ON_VALUE; } throw new IllegalStateException( "isMultiProcessEnabled shouldn't be called if update_service_v2 flag is set."); } @Override public void enableMultiProcess(boolean enable) { PackageInfo current = getCurrentWebViewPackage(); mSystemInterface.setMultiProcessSetting(mContext, enable ? MULTIPROCESS_SETTING_ON_VALUE : MULTIPROCESS_SETTING_OFF_VALUE); mSystemInterface.notifyZygote(enable); if (current != null) { mSystemInterface.killPackageDependents(current.packageName); } throw new IllegalStateException( "enableMultiProcess shouldn't be called if update_service_v2 flag is set."); } /** Loading @@ -659,7 +642,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public void dumpState(PrintWriter pw) { pw.println("Current WebView Update Service state"); pw.println(String.format(" Multiprocess enabled: %b", isMultiProcessEnabled())); synchronized (mLock) { if (mCurrentWebViewPackage == null) { pw.println(" Current WebView package is null"); Loading Loading
core/java/android/webkit/WebViewDelegate.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.webkit; import static android.webkit.Flags.updateServiceV2; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; Loading Loading @@ -205,6 +207,9 @@ public final class WebViewDelegate { * Returns whether WebView should run in multiprocess mode. */ public boolean isMultiProcessEnabled() { if (updateServiceV2()) { return true; } try { return WebViewFactory.getUpdateService().isMultiProcessEnabled(); } catch (RemoteException e) { Loading
core/java/android/webkit/WebViewZygote.java +13 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.webkit; import static android.webkit.Flags.updateServiceV2; import android.content.pm.PackageInfo; import android.os.Build; import android.os.ChildZygoteProcess; Loading Loading @@ -50,8 +52,8 @@ public class WebViewZygote { private static PackageInfo sPackage; /** * Flag for whether multi-process WebView is enabled. If this is {@code false}, the zygote * will not be started. * Flag for whether multi-process WebView is enabled. If this is {@code false}, the zygote will * not be started. Should be removed entirely after we remove the updateServiceV2 flag. */ @GuardedBy("sLock") private static boolean sMultiprocessEnabled = false; Loading @@ -73,11 +75,19 @@ public class WebViewZygote { public static boolean isMultiprocessEnabled() { synchronized (sLock) { if (updateServiceV2()) { return sPackage != null; } else { return sMultiprocessEnabled && sPackage != null; } } } public static void setMultiprocessEnabled(boolean enabled) { if (updateServiceV2()) { throw new IllegalStateException( "setMultiprocessEnabled shouldn't be called if update_service_v2 flag is set."); } synchronized (sLock) { sMultiprocessEnabled = enabled; Loading
services/core/java/com/android/server/webkit/SystemImpl.java +18 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.webkit; import static android.webkit.Flags.updateServiceV2; import android.app.ActivityManager; import android.app.AppGlobals; import android.content.Context; Loading Loading @@ -237,18 +239,30 @@ public class SystemImpl implements SystemInterface { @Override public int getMultiProcessSetting(Context context) { return Settings.Global.getInt(context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, 0); if (updateServiceV2()) { throw new IllegalStateException( "getMultiProcessSetting shouldn't be called if update_service_v2 flag is set."); } return Settings.Global.getInt( context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, 0); } @Override public void setMultiProcessSetting(Context context, int value) { Settings.Global.putInt(context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, value); if (updateServiceV2()) { throw new IllegalStateException( "setMultiProcessSetting shouldn't be called if update_service_v2 flag is set."); } Settings.Global.putInt( context.getContentResolver(), Settings.Global.WEBVIEW_MULTIPROCESS, value); } @Override public void notifyZygote(boolean enableMultiProcess) { if (updateServiceV2()) { throw new IllegalStateException( "notifyZygote shouldn't be called if update_service_v2 flag is set."); } WebViewZygote.setMultiprocessEnabled(enableMultiProcess); } Loading
services/core/java/com/android/server/webkit/WebViewUpdateService.java +26 −8 Original line number Diff line number Diff line Loading @@ -157,8 +157,13 @@ public class WebViewUpdateService extends SystemService { public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, String[] args, ShellCallback callback, ResultReceiver resultReceiver) { (new WebViewUpdateServiceShellCommand(this)).exec( this, in, out, err, args, callback, resultReceiver); if (updateServiceV2()) { (new WebViewUpdateServiceShellCommand2(this)) .exec(this, in, out, err, args, callback, resultReceiver); } else { (new WebViewUpdateServiceShellCommand(this)) .exec(this, in, out, err, args, callback, resultReceiver); } } Loading Loading @@ -275,18 +280,31 @@ public class WebViewUpdateService extends SystemService { @Override // Binder call public boolean isMultiProcessEnabled() { if (updateServiceV2()) { throw new IllegalStateException( "isMultiProcessEnabled shouldn't be called if update_service_v2 flag is" + " set."); } return WebViewUpdateService.this.mImpl.isMultiProcessEnabled(); } @Override // Binder call public void enableMultiProcess(boolean enable) { if (getContext().checkCallingPermission( if (updateServiceV2()) { throw new IllegalStateException( "enableMultiProcess shouldn't be called if update_service_v2 flag is set."); } if (getContext() .checkCallingPermission( android.Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) { String msg = "Permission Denial: enableMultiProcess() from pid=" String msg = "Permission Denial: enableMultiProcess() from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; + ", uid=" + Binder.getCallingUid() + " requires " + android.Manifest.permission.WRITE_SECURE_SETTINGS; Slog.w(TAG, msg); throw new SecurityException(msg); } Loading
services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java +5 −23 Original line number Diff line number Diff line Loading @@ -85,9 +85,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { private static final int VALIDITY_INCORRECT_SIGNATURE = 3; private static final int VALIDITY_NO_LIBRARY_FLAG = 4; private static final int MULTIPROCESS_SETTING_ON_VALUE = Integer.MAX_VALUE; private static final int MULTIPROCESS_SETTING_OFF_VALUE = Integer.MIN_VALUE; private final SystemInterface mSystemInterface; private final Context mContext; Loading Loading @@ -166,7 +163,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public void prepareWebViewInSystemServer() { mSystemInterface.notifyZygote(isMultiProcessEnabled()); try { synchronized (mLock) { mCurrentWebViewPackage = findPreferredWebViewPackage(); Loading Loading @@ -366,10 +362,8 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { // Once we've notified the system that the provider has changed and started RELRO creation, // try to restart the zygote so that it will be ready when apps use it. if (isMultiProcessEnabled()) { AsyncTask.THREAD_POOL_EXECUTOR.execute(this::startZygoteWhenReady); } } /** * Fetch only the currently valid WebView packages. Loading Loading @@ -632,25 +626,14 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public boolean isMultiProcessEnabled() { int settingValue = mSystemInterface.getMultiProcessSetting(mContext); if (mSystemInterface.isMultiProcessDefaultEnabled()) { // 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. return settingValue >= MULTIPROCESS_SETTING_ON_VALUE; } throw new IllegalStateException( "isMultiProcessEnabled shouldn't be called if update_service_v2 flag is set."); } @Override public void enableMultiProcess(boolean enable) { PackageInfo current = getCurrentWebViewPackage(); mSystemInterface.setMultiProcessSetting(mContext, enable ? MULTIPROCESS_SETTING_ON_VALUE : MULTIPROCESS_SETTING_OFF_VALUE); mSystemInterface.notifyZygote(enable); if (current != null) { mSystemInterface.killPackageDependents(current.packageName); } throw new IllegalStateException( "enableMultiProcess shouldn't be called if update_service_v2 flag is set."); } /** Loading @@ -659,7 +642,6 @@ class WebViewUpdateServiceImpl2 implements WebViewUpdateServiceInterface { @Override public void dumpState(PrintWriter pw) { pw.println("Current WebView Update Service state"); pw.println(String.format(" Multiprocess enabled: %b", isMultiProcessEnabled())); synchronized (mLock) { if (mCurrentWebViewPackage == null) { pw.println(" Current WebView package is null"); Loading