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

Commit bf683e07 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add an API for retrieving information about the current WebView package.

Now that WebView can be loaded from one out of a set of packages we
provide an API for fetching information about this package.
Such API is especially useful for debugging crashes.

Bug: 30597460

Change-Id: I13dd746f7efcf2917b517053010b73ea35241325
parent 337f8fbd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45845,6 +45845,7 @@ package android.webkit {
    method public deprecated void freeMemory();
    method public android.net.http.SslCertificate getCertificate();
    method public int getContentHeight();
    method public static android.content.pm.PackageInfo getCurrentWebViewPackage();
    method public android.graphics.Bitmap getFavicon();
    method public android.webkit.WebView.HitTestResult getHitTestResult();
    method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
+1 −0
Original line number Diff line number Diff line
@@ -49122,6 +49122,7 @@ package android.webkit {
    method public deprecated void freeMemory();
    method public android.net.http.SslCertificate getCertificate();
    method public int getContentHeight();
    method public static android.content.pm.PackageInfo getCurrentWebViewPackage();
    method public android.graphics.Bitmap getFavicon();
    method public android.webkit.WebView.HitTestResult getHitTestResult();
    method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
+1 −0
Original line number Diff line number Diff line
@@ -46083,6 +46083,7 @@ package android.webkit {
    method public deprecated void freeMemory();
    method public android.net.http.SslCertificate getCertificate();
    method public int getContentHeight();
    method public static android.content.pm.PackageInfo getCurrentWebViewPackage();
    method public android.graphics.Bitmap getFavicon();
    method public android.webkit.WebView.HitTestResult getHitTestResult();
    method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ interface IWebViewUpdateService {
     */
    String getCurrentWebViewPackageName();

    /**
     * Used by public API for debugging purposes.
     */
    PackageInfo getCurrentWebViewPackage();

    /**
     * Used by Settings to determine whether a certain package can be enabled/disabled by the user -
     * the package should not be modifiable in this way if it is a fallback package.
+22 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.SystemApi;
import android.annotation.Widget;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -36,6 +37,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.StrictMode;
import android.os.RemoteException;
import android.print.PrintDocumentAdapter;
import android.security.KeyChain;
import android.util.AttributeSet;
@@ -2673,6 +2675,26 @@ public class WebView extends AbsoluteLayout
        return mProvider.getViewDelegate().findFocus(super.findFocus());
    }

    /**
     * If WebView has already been loaded into the current process this method will return the
     * package that was used to load it. Otherwise, the package that would be used if the WebView
     * was loaded right now will be returned; this does not cause WebView to be loaded, so this
     * information may become outdated at any time.
     * @return the current WebView package, or null if there is none.
     */
    public static PackageInfo getCurrentWebViewPackage() {
        PackageInfo webviewPackage = WebViewFactory.getLoadedPackageInfo();
        if (webviewPackage != null) {
            return webviewPackage;
        }

        try {
            return WebViewFactory.getUpdateService().getCurrentWebViewPackage();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Receive the result from a previous call to {@link #startActivityForResult(Intent, int)}.
     *
Loading