Android's own WebView browser kernel update

Android's native WebView update

1. Android 7

In the Android 7 system, the built-in browser kernel is usually a very low version, such as 52.0.2743.100. As a result, the new syntax of the front end is not supported, such as the most basic async syntax of ES6, which is comparable to the environment of old IE.

foreword

In Settings - Application - Display System Application, there is an Android System WebView program, but the version is very low. Developer Options - In the implementation of WebView, there is generally only one Android WebView, and the package name is com.android.webview.

Then can we install a WebView by ourselves, and then set it in the WebView implementation? The actual test does not work, even if the installation is successful, there will be no newly installed WebView option.

Let's start the upgrade tutorial, prerequisite: ROOT; recommended tool: MT manager.

1. Prepare the version of WebView you want

You can search for WebView in "Ku'an", and then find the latest version carried by my brother in the comment area (Salute to my brother).

Or download from a mirror website on the external network, such as Android System WebView APK Download (softpedia.com) website (turtle speed).

2. Install WebView as system software

Here I directly use the MT file manager to change the file name of the apk a little bit, then put it in the /system./app directory, change the permissions to -rw-r–r–, and then restart.

After restarting, go to Settings-Application-"Show System Process" in the upper right corner to see if there are any newly installed WebView applications.

If not, you can try to delete the WebView apk just placed under /system./app, then install it according to the normal application installation process, and then use titanium backup to convert it to a system application.

It may be possible to install it directly as a normal application. I haven't tried it, but my intuition tells me it should work (dog head).

Attach the warehouse I created: Aken/Android-WebView (gitee.com) , which contains several old and new versions of WebView APK that I searched for.

3. Decompile and modify framework-res.apk configuration
  • Find the framework-res.apk file in the /system/framework folder

  • Copy the framework-res.apk file to another place for backup , so as not to overturn and replace it.

  • Click apk - view, enter res/xml, find config_webview_packages.xml, open it, and select decompile.

  • At this time, I saw that in this xml file, there is already a webviewprovider, and the package name in it is the built-in webview of the system. The com.android.webview is very old, and the updated webview has been changed to com.google.android.webview.

  • To imitate the existing one, add the following code:

    description: Define a name yourself, which will be displayed in Developer Options - WebView Implementation.

    packageName: The package name of the newly installed WebView program, and now the new version is com.google.android.webview.

    availableByDefault: directly set the new WebView to true, which is used by default. However, it is useless to set it in the actual test, it still needs to be set after the developer option is set. So true/false is fine here, but there should be only one true for all webviewproviders.

    <?xml version="1.0" encoding="utf-8"?>
    <webviewproviders>
        <webviewprovider
            description="WebView103"
            packageName="com.google.android.webview"
            availableByDefault="true" />
            
            <webviewprovider
            description="Android WebView"
            packageName="com.android.webview"
            availableByDefault="false" />
    </webviewproviders>
    
  • After saving, return to the previous level, it will prompt that the file has been modified, click OK, do not check "Automatic Signature".

  • Go back to /system/framework layer by layer, and you will see more framework-res.apk.bak (MT Manager's own backup) and modified framework-res.apk.

  • Reboot the device.

4. Set in developer options
  • Generally, in Settings - About, click the system version number continuously to trigger the hidden developer options.

  • In the developer options, you can see the newly added WebView103 in the WebView implementation, select it.

5. Inspection results

2. Android 9

In the Android 9 system, the built-in browser kernel is not too old, and basically meets the syntax of the front end. Here's my upgrade process:

  • First of all, seeing that the package name of the built-in WebView is also com.google.android.webview, then I thought of installing it directly.
  • If it can be installed directly, there is a high probability that the upgrade will be successful directly, so there is no need to continue to look down.
  • But I encountered a different signature that caused the installation to fail. So enter the /system/app/webview folder, back up the files inside, then clear the folder, and then rename the WebView apk you want to install to the apk name that existed before in the folder, for example, here is webview.apk, change Permissions are -rw-r–r–, then reboot. (replace Dafa)
  • The signature conflict here should also be resolved through core cracking, which is another way.
  • Just use the website above to test your results.

Three, afterword

1. I saw a friend said that after installing WebView, you can directly use ADB to add a new WebView option to WebView. The code is:

adb shell settings put global webview_provider com.google.android.webview

But after I reset it, it still didn't work. Of course, this may be because my system is not working, you can try this method first.

You can view it with the following code:

adb shell settings get global webview_provider

ps: After manually modifying the framework-res.apk, I get the configuration again, but there are still no new additions, but there are already candidates in the WebView implementation.

2. If the installation fails, you can use the MT manager to go to the apk file in the /system/app/webview folder to see the package name of the built-in WebView apk. If the package name is the same, it may be a signature problem. It is estimated that there is no root. no.

3. Friends who develop Android, generally do not set software acceleration when using WebView, unless you encounter some display problems. Software acceleration When I tested, the animation of the web page dropped frames. . The default is hardware acceleration, no need to manually set it.

// 设置为软件加速
setLayerType(View.LAYER_TYPE_SOFTWARE, null)

4. The WebView 104 version seems to require at least Android 10 to be installed, so pay attention to the compatibility of Android versions.

5. You can also refer to other Android versions, the idea should be similar.

Guess you like

Origin blog.csdn.net/weixin_44565784/article/details/126370271