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

Commit af862b0d authored by Ziad Youssef's avatar Ziad Youssef
Browse files

Add WebView default package to the essential packages

Test: verified that the option to disable WebView in TvSettings is removed

Bug: 308907090

Change-Id: I13fdb263fbfeb5ed516cbe80e16baaab9128fab9
parent ae9ef585
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
package com.android.settingslib;

import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_USER_LABEL;
import static android.webkit.Flags.updateServiceV2;

import android.annotation.ColorInt;
import android.app.admin.DevicePolicyManager;
@@ -34,6 +35,7 @@ import android.net.vcn.VcnTransportInfo;
import android.net.wifi.WifiInfo;
import android.os.BatteryManager;
import android.os.Build;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
@@ -44,6 +46,9 @@ import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.webkit.IWebViewUpdateService;
import android.webkit.WebViewFactory;
import android.webkit.WebViewProviderInfo;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -65,6 +70,8 @@ import java.util.List;

public class Utils {

    private static final String TAG = "Utils";

    @VisibleForTesting
    static final String STORAGE_MANAGER_ENABLED_PROPERTY =
            "ro.storage_manager.enabled";
@@ -76,6 +83,7 @@ public class Utils {
    private static String sPermissionControllerPackageName;
    private static String sServicesSystemSharedLibPackageName;
    private static String sSharedSystemSharedLibPackageName;
    private static String sDefaultWebViewPackageName;

    static final int[] WIFI_PIE = {
        com.android.internal.R.drawable.ic_wifi_signal_0,
@@ -445,6 +453,7 @@ public class Utils {
                || packageName.equals(sServicesSystemSharedLibPackageName)
                || packageName.equals(sSharedSystemSharedLibPackageName)
                || packageName.equals(PrintManager.PRINT_SPOOLER_PACKAGE_NAME)
                || (updateServiceV2() && packageName.equals(getDefaultWebViewPackageName()))
                || isDeviceProvisioningPackage(resources, packageName);
    }

@@ -458,6 +467,29 @@ public class Utils {
        return deviceProvisioningPackage != null && deviceProvisioningPackage.equals(packageName);
    }

    /**
     * Fetch the package name of the default WebView provider.
     */
    @Nullable
    private static String getDefaultWebViewPackageName() {
        if (sDefaultWebViewPackageName != null) {
            return sDefaultWebViewPackageName;
        }

        try {
            IWebViewUpdateService service = WebViewFactory.getUpdateService();
            if (service != null) {
                WebViewProviderInfo provider = service.getDefaultWebViewPackage();
                if (provider != null) {
                    sDefaultWebViewPackageName = provider.packageName;
                }
            }
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException when trying to fetch default WebView package Name", e);
        }
        return sDefaultWebViewPackageName;
    }

    /**
     * Returns the Wifi icon resource for a given RSSI level.
     *