Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87c4adf2 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Richard Coles
Browse files

Proper IPC wrapper for WebViewUpdateService.

Introduce a proper IPC client wrapper class for WebViewUpdateService
that can be used instead of directly consuming the AIDL interface.

The existing android.webkit.WebViewUpdateService wrapper has a bad API
and will be deprecated in future; in the meantime it will forward calls
to the new wrapper.

Bug: 319292658
Test: with flag enabled, atest CtsWebkitTestCases
Change-Id: I682a75a43eeebec26aa2d08b620b2f69bcfe0667
parent b39512ee
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ package android.content {
    method @NonNull public android.os.UserHandle getUser();
    field public static final String PAC_PROXY_SERVICE = "pac_proxy";
    field public static final String TEST_NETWORK_SERVICE = "test_network";
    field @FlaggedApi("android.webkit.update_service_ipc_wrapper") public static final String WEBVIEW_UPDATE_SERVICE = "webviewupdate";
  }

  public class Intent implements java.lang.Cloneable android.os.Parcelable {
@@ -650,3 +651,34 @@ package android.view.accessibility {

}

package android.webkit {

  @FlaggedApi("android.webkit.update_service_ipc_wrapper") public class WebViewBootstrapFrameworkInitializer {
    method public static void registerServiceWrappers();
  }

  @FlaggedApi("android.webkit.update_service_ipc_wrapper") public final class WebViewProviderResponse implements android.os.Parcelable {
    ctor public WebViewProviderResponse(@Nullable android.content.pm.PackageInfo, int);
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.webkit.WebViewProviderResponse> CREATOR;
    field public static final int STATUS_FAILED_LISTING_WEBVIEW_PACKAGES = 4; // 0x4
    field public static final int STATUS_FAILED_WAITING_FOR_RELRO = 3; // 0x3
    field public static final int STATUS_SUCCESS = 0; // 0x0
    field @Nullable public final android.content.pm.PackageInfo packageInfo;
    field public final int status;
  }

  @FlaggedApi("android.webkit.update_service_ipc_wrapper") public final class WebViewUpdateManager {
    method @Nullable @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public String changeProviderAndSetting(@NonNull String);
    method @NonNull public android.webkit.WebViewProviderInfo[] getAllWebViewPackages();
    method @Nullable public android.content.pm.PackageInfo getCurrentWebViewPackage();
    method @Nullable public String getCurrentWebViewPackageName();
    method @FlaggedApi("android.webkit.update_service_v2") @NonNull public android.webkit.WebViewProviderInfo getDefaultWebViewPackage();
    method @Nullable public static android.webkit.WebViewUpdateManager getInstance();
    method @NonNull public android.webkit.WebViewProviderInfo[] getValidWebViewPackages();
    method @NonNull public android.webkit.WebViewProviderResponse waitForAndGetProvider();
  }

}
+6 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ import android.view.textservice.TextServicesManager;
import android.view.translation.ITranslationManager;
import android.view.translation.TranslationManager;
import android.view.translation.UiTranslationManager;
import android.webkit.WebViewBootstrapFrameworkInitializer;

import com.android.internal.R;
import com.android.internal.app.IAppOpsService;
@@ -1660,12 +1661,17 @@ public final class SystemServiceRegistry {
            OnDevicePersonalizationFrameworkInitializer.registerServiceWrappers();
            DeviceLockFrameworkInitializer.registerServiceWrappers();
            VirtualizationFrameworkInitializer.registerServiceWrappers();
            // This code is executed on zygote during preload, where only read-only
            // flags can be used. Do not use mutable flags.
            if (android.permission.flags.Flags.enhancedConfirmationModeApisEnabled()) {
                EnhancedConfirmationFrameworkInitializer.registerServiceWrappers();
            }
            if (android.server.Flags.telemetryApisService()) {
                ProfilingFrameworkInitializer.registerServiceWrappers();
            }
            if (android.webkit.Flags.updateServiceIpcWrapper()) {
                WebViewBootstrapFrameworkInitializer.registerServiceWrappers();
            }
        } finally {
            // If any of the above code throws, we're in a pretty bad shape and the process
            // will likely crash, but we'll reset it just in case there's an exception handler...
+13 −0
Original line number Diff line number Diff line
@@ -6561,6 +6561,19 @@ public abstract class Context {
    @FlaggedApi(android.os.Flags.FLAG_TELEMETRY_APIS_FRAMEWORK_INITIALIZATION)
    public static final String PROFILING_SERVICE = "profiling";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a {@link
     * android.webkit.WebViewUpdateManager} for accessing the WebView update service.
     *
     * @see #getSystemService(String)
     * @see android.webkit.WebViewUpdateManager
     * @hide
     */
    @FlaggedApi(android.webkit.Flags.FLAG_UPDATE_SERVICE_IPC_WRAPPER)
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @SuppressLint("ServiceName")
    public static final String WEBVIEW_UPDATE_SERVICE = "webviewupdate";

    /**
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ interface IWebViewUpdateService {
     * it would then try to update the provider to such a package while in reality the update
     * service would switch to another one.
     */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)")
    String changeProviderAndSetting(String newProvider);

    /**
+16 −8
Original line number Diff line number Diff line
@@ -3087,6 +3087,13 @@ public class WebView extends AbsoluteLayout
            return webviewPackage;
        }

        if (Flags.updateServiceIpcWrapper()) {
            WebViewUpdateManager manager = WebViewUpdateManager.getInstance();
            if (manager == null) {
                return null;
            }
            return manager.getCurrentWebViewPackage();
        } else {
            IWebViewUpdateService service = WebViewFactory.getUpdateService();
            if (service == null) {
                return null;
@@ -3097,6 +3104,7 @@ public class WebView extends AbsoluteLayout
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Receive the result from a previous call to {@link #startActivityForResult(Intent, int)}.
Loading