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

Commit 57015b18 authored by Gustav Sennton's avatar Gustav Sennton Committed by android-build-merger
Browse files

Merge "Provide command to change WebView implementation." into nyc-dev

am: 3d48074e

* commit '3d48074e':
  Provide command to change WebView implementation.

Change-Id: I9771561bb13ee0978e5791aa1300746fbe972a11
parents 517dad11 3d48074e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -613,7 +613,12 @@ public class WebViewUpdateService extends SystemService {
                throw new SecurityException(msg);
            }

            long callingId = Binder.clearCallingIdentity();
            try {
                return WebViewUpdateService.this.changeProviderAndSetting(newProvider);
            } finally {
                Binder.restoreCallingIdentity(callingId);
            }
        }

        @Override // Binder call
+19 −1
Original line number Diff line number Diff line
@@ -36,12 +36,13 @@ class WebViewUpdateServiceShellCommand extends ShellCommand {

        final PrintWriter pw = getOutPrintWriter();
        try {
            // TODO(gsennton) add command for changing WebView provider
            switch(cmd) {
                case "enable-redundant-packages":
                    return enableFallbackLogic(false);
                case "disable-redundant-packages":
                    return enableFallbackLogic(true);
                case "set-webview-implementation":
                    return setWebViewImplementation();
                default:
                    return handleDefaultCommands(cmd);
            }
@@ -58,6 +59,21 @@ class WebViewUpdateServiceShellCommand extends ShellCommand {
        return 0;
    }

    private int setWebViewImplementation() throws RemoteException {
        final PrintWriter pw = getOutPrintWriter();
        String shellChosenPackage = getNextArg();
        String newPackage = mInterface.changeProviderAndSetting(shellChosenPackage);
        if (shellChosenPackage.equals(newPackage)) {
            pw.println("Success");
            return 0;
        } else {
            pw.println(String.format(
                        "Failed to switch to %s, the WebView implementation is now provided by %s.",
                        shellChosenPackage, newPackage));
            return 1;
        }
    }

    @Override
    public void onHelp() {
        PrintWriter pw = getOutPrintWriter();
@@ -72,6 +88,8 @@ class WebViewUpdateServiceShellCommand extends ShellCommand {
        pw.println("  disable-redundant-packages");
        pw.println("    Disallow installing and enabling fallback packages when a more-preferred");
        pw.println("    package is available.");
        pw.println("  set-webview-implementation PACKAGE");
        pw.println("    Set the WebView implementation to the specified package.");
        pw.println();
    }
}