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

Commit f02e6fd4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Correct annotations for WebViewUpdateService/Manager." into main

parents eb4e2440 a113ac8d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -673,8 +673,8 @@ package android.webkit {
    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 @RequiresPermission(allOf={android.Manifest.permission.INTERACT_ACROSS_USERS, android.Manifest.permission.QUERY_ALL_PACKAGES}) public android.webkit.WebViewProviderInfo[] getValidWebViewPackages();
    method @NonNull public static android.webkit.WebViewUpdateManager getInstance();
    method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.webkit.WebViewProviderInfo[] getValidWebViewPackages();
    method @NonNull public android.webkit.WebViewProviderResponse waitForAndGetProvider();
  }

+1 −1
Original line number Diff line number Diff line
@@ -18769,7 +18769,7 @@ package android.webkit {
  public final class WebViewUpdateService {
    method public static android.webkit.WebViewProviderInfo[] getAllWebViewPackages();
    method public static String getCurrentWebViewPackageName();
    method public static android.webkit.WebViewProviderInfo[] getValidWebViewPackages();
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public static android.webkit.WebViewProviderInfo[] getValidWebViewPackages();
  }
}
+23 −14
Original line number Diff line number Diff line
@@ -43,22 +43,29 @@ public final class WebViewUpdateManager {
    /**
     * Get the singleton instance of the manager.
     *
     * This exists for the benefit of callsites without a {@link Context}; prefer
     * <p>This exists for the benefit of callsites without a {@link Context}; prefer
     * {@link Context#getSystemService(Class)} otherwise.
     *
     * This can only be used on devices with {@link PackageManager#FEATURE_WEBVIEW}.
     * <p>This must only be called on devices with {@link PackageManager#FEATURE_WEBVIEW},
     * and will WTF or throw {@link UnsupportedOperationException} otherwise.
     */
    @SuppressLint("ManagerLookup") // service opts in to getSystemServiceWithNoContext()
    @RequiresFeature(PackageManager.FEATURE_WEBVIEW)
    public static @Nullable WebViewUpdateManager getInstance() {
        return (WebViewUpdateManager) SystemServiceRegistry.getSystemServiceWithNoContext(
    public static @NonNull WebViewUpdateManager getInstance() {
        WebViewUpdateManager manager =
                (WebViewUpdateManager) SystemServiceRegistry.getSystemServiceWithNoContext(
                        Context.WEBVIEW_UPDATE_SERVICE);
        if (manager == null) {
            throw new UnsupportedOperationException("WebView not supported by device");
        } else {
            return manager;
        }
    }

    /**
     * Block until system-level WebView preparations are complete.
     *
     * This also makes the current WebView provider package visible to the caller.
     * <p>This also makes the current WebView provider package visible to the caller.
     *
     * @return the status of WebView preparation and the current provider package.
     */
@@ -86,7 +93,7 @@ public final class WebViewUpdateManager {
    /**
     * Get the complete list of supported WebView providers for this device.
     *
     * This includes all configured providers, regardless of whether they are currently available
     * <p>This includes all configured providers, regardless of whether they are currently available
     * or valid.
     */
    @SuppressLint({"ParcelableList", "ArrayReturn"})
@@ -101,13 +108,15 @@ public final class WebViewUpdateManager {
    /**
     * Get the list of currently-valid WebView providers for this device.
     *
     * This only includes providers that are currently present on the device and meet the validity
     * criteria (signature, version, etc), but does not check if the provider is installed and
     * enabled for all users.
     * <p>This only includes providers that are currently present on the device and meet the
     * validity criteria (signature, version, etc), but does not check if the provider is installed
     * and enabled for all users.
     *
     * <p>Note that this will be filtered by the caller's package visibility; callers should
     * have QUERY_ALL_PACKAGES permission to ensure that the list is complete.
     */
    @SuppressLint({"ParcelableList", "ArrayReturn"})
    @RequiresPermission(allOf = {android.Manifest.permission.INTERACT_ACROSS_USERS,
            android.Manifest.permission.QUERY_ALL_PACKAGES})
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
    public @NonNull WebViewProviderInfo[] getValidWebViewPackages() {
        try {
            return mService.getValidWebViewPackages();
@@ -132,7 +141,7 @@ public final class WebViewUpdateManager {
    /**
     * Ask the system to switch to a specific WebView implementation if possible.
     *
     * This choice will be stored persistently.
     * <p>This choice will be stored persistently.
     *
     * @param newProvider the package name to use.
     * @return the package name which is now in use, which may not be the
@@ -162,7 +171,7 @@ public final class WebViewUpdateManager {
    /**
     * Get the WebView provider which will be used if no explicit choice has been made.
     *
     * The default provider is not guaranteed to be a valid/usable WebView implementation.
     * <p>The default provider is not guaranteed to be a valid/usable WebView implementation.
     *
     * @return the default WebView provider.
     */
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.webkit;

import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.RemoteException;
@@ -54,7 +55,11 @@ public final class WebViewUpdateService {

    /**
     * Fetch all packages that could potentially implement WebView and are currently valid.
     *
     * <p>Note that this will be filtered by the caller's package visibility; callers should
     * have QUERY_ALL_PACKAGES permission to ensure that the list is complete.
     */
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
    public static WebViewProviderInfo[] getValidWebViewPackages() {
        if (Flags.updateServiceIpcWrapper()) {
            if (WebViewFactory.isWebViewSupported()) {
+0 −2
Original line number Diff line number Diff line
@@ -520,8 +520,6 @@ public class Utils {

        if (android.webkit.Flags.updateServiceIpcWrapper()) {
            if (pm.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)) {
                // WebViewUpdateManager.getInstance() will not return null on devices with
                // FEATURE_WEBVIEW.
                provider = WebViewUpdateManager.getInstance().getDefaultWebViewPackage();
            }
        } else {