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

Commit 7a002a21 authored by Gustav Sennton's avatar Gustav Sennton Committed by Android (Google) Code Review
Browse files

Merge "Move current WebView provider from Settings.Secure to Settings.Global" into nyc-dev

parents d817dfd5 14c033c7
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -5906,13 +5906,6 @@ public final class Settings {
        public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
                "camera_double_tap_power_gesture_disabled";

        /**
         * Name of the package used as WebView provider (if unset the provider is instead determined
         * by the system).
         * @hide
         */
        public static final String WEBVIEW_PROVIDER = "webview_provider";

        /**
         * This are the settings to be backed up.
         *
@@ -6940,6 +6933,13 @@ public final class Settings {
        public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
                "webview_data_reduction_proxy_key";

        /**
         * Name of the package used as WebView provider (if unset the provider is instead determined
         * by the system).
         * @hide
         */
        public static final String WEBVIEW_PROVIDER = "webview_provider";

       /**
        * Whether Wifi display is enabled/disabled
        * 0=disabled. 1=enabled.
+14 −20
Original line number Diff line number Diff line
@@ -97,22 +97,12 @@ public class WebViewProviderInfo implements Parcelable {
     */
    public boolean isEnabled() {
        try {
            PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
            int enabled_state = pm.getApplicationEnabledSetting(packageName);
            switch (enabled_state) {
                case PackageManager.COMPONENT_ENABLED_STATE_ENABLED:
                    return true;
                case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
                    ApplicationInfo applicationInfo = getPackageInfo().applicationInfo;
                    return applicationInfo.enabled;
                default:
                    return false;
            }
            // Explicitly fetch up-to-date package info here since the enabled-state of the package
            // might have changed since we last fetched its package info.
            updatePackageInfo();
            return getPackageInfo().applicationInfo.enabled;
        } catch (WebViewPackageNotFoundException e) {
            return false;
        } catch (IllegalArgumentException e) {
            // Thrown by PackageManager.getApplicationEnabledSetting if the package does not exist
            return false;
        }
    }

@@ -124,8 +114,7 @@ public class WebViewProviderInfo implements Parcelable {
        return availableByDefault;
    }

    public PackageInfo getPackageInfo() {
        if (packageInfo == null) {
    private void updatePackageInfo() {
        try {
            PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
            packageInfo = pm.getPackageInfo(packageName, PACKAGE_FLAGS);
@@ -133,6 +122,11 @@ public class WebViewProviderInfo implements Parcelable {
            throw new WebViewPackageNotFoundException(e);
        }
    }

    public PackageInfo getPackageInfo() {
        if (packageInfo == null) {
            updatePackageInfo();
        }
        return packageInfo;
    }

+6 −6
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.provider.Settings.Global;
import android.util.AndroidRuntimeException;
import android.util.Slog;
import android.webkit.IWebViewUpdateService;
@@ -91,7 +91,7 @@ public class WebViewUpdateService extends SystemService {
                    // change provider when the new version of the package is being installed).
                    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)
                        && intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) {
                        synchronized(this) {
                        synchronized(WebViewUpdateService.this) {
                            if (mCurrentWebViewPackage == null) return;

                            String webViewPackage = "package:" + mCurrentWebViewPackage.packageName;
@@ -268,13 +268,13 @@ public class WebViewUpdateService extends SystemService {
    }

    private static String getUserChosenWebViewProvider() {
        return Settings.Secure.getString(AppGlobals.getInitialApplication().getContentResolver(),
                Settings.Secure.WEBVIEW_PROVIDER);
        return Settings.Global.getString(AppGlobals.getInitialApplication().getContentResolver(),
                Settings.Global.WEBVIEW_PROVIDER);
    }

    private void updateUserSetting(String newProviderName) {
        Settings.Secure.putString(getContext().getContentResolver(),
                Settings.Secure.WEBVIEW_PROVIDER,
        Settings.Global.putString(getContext().getContentResolver(),
                Settings.Global.WEBVIEW_PROVIDER,
                newProviderName == null ? "" : newProviderName);
    }