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

Commit 6258dcd7 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add functionality for changing WebView provider.

Make it possible to change WebView provider (through a Developer
setting) and kill all apps using the old provider.
This includes checking the signatures of the WebView providers to make
sure they are valid.

Now that we can change WebView provider through a setting it is possible
to change provider while some provider is being updated. Because of this
we now keep track of which provider should be in use in
WebViewUpdateService to make sure we use the correct provider at all
times.

We now also read WebView package meta data (name, package name, and
signature) from a separate xml file.

Main bug: crbug.com/546185

Bug: 25338573

Change-Id: I660fd1a40a5388f6569a06a7f0d029e8ff65945a
parent 752b070e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -46474,8 +46474,6 @@ package android.webkit {
    method public static android.content.pm.PackageInfo getLoadedPackageInfo();
    method public static java.lang.String getWebViewPackageName();
    method public static int loadWebViewNativeLibraryFromPackage(java.lang.String);
    method public static void onWebViewUpdateInstalled();
    method public static void prepareWebViewInSystemServer();
    method public static void prepareWebViewInZygote();
    field public static final java.lang.String CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY = "persist.sys.webview.vmsize";
    field public static final int LIBLOAD_ADDRESS_SPACE_NOT_RESERVED = 2; // 0x2
@@ -46484,7 +46482,9 @@ package android.webkit {
    field public static final int LIBLOAD_FAILED_TO_LOAD_LIBRARY = 6; // 0x6
    field public static final int LIBLOAD_FAILED_TO_OPEN_RELRO_FILE = 5; // 0x5
    field public static final int LIBLOAD_FAILED_WAITING_FOR_RELRO = 3; // 0x3
    field public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9; // 0x9
    field public static final int LIBLOAD_SUCCESS = 0; // 0x0
    field public static final int LIBLOAD_WEBVIEW_BEING_REPLACED = 8; // 0x8
    field public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; // 0x1
  }
+21 −0
Original line number Diff line number Diff line
@@ -1558,6 +1558,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case KILL_PACKAGE_DEPENDENTS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String packageName = data.readString();
            int userId = data.readInt();
            killPackageDependents(packageName, userId);
            reply.writeNoException();
            return true;
        }

        case FORCE_STOP_PACKAGE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String packageName = data.readString();
@@ -4736,6 +4745,18 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void killPackageDependents(String packageName, int userId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeString(packageName);
        data.writeInt(userId);
        mRemote.transact(KILL_PACKAGE_DEPENDENTS_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    public void forceStopPackage(String packageName, int userId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
+2 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ public interface IActivityManager extends IInterface {
    public void killBackgroundProcesses(final String packageName, int userId)
            throws RemoteException;
    public void killAllBackgroundProcesses() throws RemoteException;
    public void killPackageDependents(final String packageName, int userId) throws RemoteException;
    public void forceStopPackage(final String packageName, int userId) throws RemoteException;

    // Note: probably don't want to allow applications access to these.
@@ -912,4 +913,5 @@ public interface IActivityManager extends IInterface {
    int UNLOCK_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 351;
    int IN_MULTI_WINDOW_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 352;
    int IN_PICTURE_IN_PICTURE_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 353;
    int KILL_PACKAGE_DEPENDENTS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 354;
}
+7 −0
Original line number Diff line number Diff line
@@ -5748,6 +5748,13 @@ 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.
         *
+23 −3
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package android.webkit;

import android.content.pm.PackageInfo;
import android.webkit.WebViewProviderInfo;
import android.webkit.WebViewProviderResponse;

/**
 * Private service to wait for the updatable WebView to be ready for use.
 * @hide
@@ -25,12 +29,28 @@ interface IWebViewUpdateService {
    /**
     * Used by the relro file creator to notify the service that it's done.
     */
    void notifyRelroCreationCompleted(boolean is64Bit, boolean success);
    void notifyRelroCreationCompleted();

    /**
     * Used by WebViewFactory to block loading of WebView code until
     * preparations are complete.
     * preparations are complete. Returns the package used as WebView provider.
     */
    void waitForRelroCreationCompleted(boolean is64Bit);
    WebViewProviderResponse waitForAndGetProvider();

    /**
     * DevelopmentSettings uses this to notify WebViewUpdateService that a
     * new provider has been selected by the user.
     */
    void changeProviderAndSetting(String newProvider);

    /**
     * DevelopmentSettings uses this to get the current available WebView
     * providers (to display as choices to the user).
     */
    WebViewProviderInfo[] getValidWebViewPackages();

    /**
     * Used by DevelopmentSetting to get the name of the WebView provider currently in use.
     */
    String getCurrentWebViewPackageName();
}
Loading