A method and device for deeply customizing WebView and providing independent Webview AAR to the outside world

By compiling the Android WebView modules as a whole into Custom WebView AAR and providing them to three-party developers to compile dependencies, the problem that APP developers cannot customize and upgrade WebView is solved, and the free customization and independent upgrade of the WebView kernel is achieved, avoiding conflicts and pollution between kernels.

CN114594957BActive Publication Date: 2025-05-23SERAPHIC INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111654443.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-05-23
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The existing Android WebView has the following problems: ordinary APP developers cannot add or modify interfaces, and the preset System WebView APK cannot be upgraded without Root permissions, which cannot meet the special needs of application developers in specific scenarios.

Method used

Provide a method to deeply customize WebView and provide independent WebView AAR to the outside world. By compiling the modules in the native WebView APK into Custom WebView AAR as a whole, and providing them to the three-party developers to compile and depend on the compilation, the three-party APP can freely customize the WebView kernel and upgrade independently.

Benefits of technology

This enables APP developers to freely customize and upgrade the WebView kernel, avoid conflicts and pollution between the WebView kernels used by different APPs, and meets the special needs of applications in specific scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0003445483460000061
    Figure BDA0003445483460000061
  • Figure BDA0003445483460000071
    Figure BDA0003445483460000071
  • Figure BDA0003445483460000081
    Figure BDA0003445483460000081
Patent Text Reader

Abstract

The present invention discloses a method for deeply customizing WebView and providing an independent Webview AAR to the outside. On the basis of the original channel of the native WebView APK, many modules in the native WebView APK are compiled into a Custom WebView AAR as a whole, and the Custom WebView AAR is provided separately to third-party developers for compilation dependency. The Custom WebView AAR and the third-party APP are finally compiled in the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs to the greatest extent. The present invention provides a method and device for deeply customizing WebView and providing an independent Webview AAR to the outside, so that third-party apps can freely customize the WebView kernel, and third-party apps can independently upgrade the WebView kernel without any impact on other APPs that also use the WebView interface. The Custom WebView AARs integrated and used by different APPs are isolated from each other to avoid conflicts and pollution during use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer browsers, and in particular to a method and device for deeply customizing a WebView and providing an independent Webview AAR to the outside. Background Art

[0002] Android WebView is an embed view component provided by the FrameWork layer of the Android platform. It is used to embed a view area in the Android app to display web content.

[0003] The overall architecture of Android WebView adopts an architecture that separates interfaces from implementations, and is mainly divided into WebView HostAPK and System WebView APK.

[0004] The application calls the WebView interface provided by the Android FWK layer to generate the WebView Host APK on the left, and at the same time, the interface layer will reflectively call the System WebView APK. The actual web page loading, parsing and rendering logic is all in the SystemWebView APK. The System WebView APK is compiled independently by Chromium and pre-installed in the Android system. The interface layer calls the Glue bridge layer of the System WebView APK through reflection, and then through the reasonable internal layered architecture of Chromium, it passes through the AWContent layer, the Content layer, the WebKit Glue layer, and finally calls the core Blink module.

[0005] But currently Android WebView has the following defects and disadvantages.

[0006] 1. The interface definition and implementation of the WebView interface layer are fixed by the system, and ordinary app developers cannot add or modify the interface.

[0007] 2. System WebView APK is usually pre-installed in the Android system in a fixed version, and the version and package name of the pre-installed System WebView APK are different depending on the Android system version and whether GMS is available. Without root permissions, these pre-installed System WebView APKs cannot be upgraded to the new version of System WebView APK compiled by Chromium.

[0008] 3. System WebView cannot meet the special needs of application developers in specific scenarios. Such needs require modifying the Chromium kernel and customizing their own WebView to meet them. Summary of the invention

[0009] In view of the above-mentioned defects of the prior art, the technical problem to be solved by the present invention is that ordinary APP developers cannot add or modify interfaces in the existing AndroidWebView, and the preset System WebView APK cannot be upgraded to the System WebView APK compiled by the new version of Chromium without Root privileges, and at the same time cannot meet the special needs of application developers in specific scenarios. Therefore, the present invention provides a method and device for deeply customizing WebView and providing an independent Webview AAR to the outside world, so that third-party apps can freely customize the WebView kernel, and third-party apps can independently upgrade the WebView kernel without any impact on other apps that also use the WebView interface. The Custom WebView AARs integrated and used by different apps are isolated from each other to avoid conflicts and pollution during use.

[0010] To achieve the above objectives, the present invention provides a method for deeply customizing WebView and providing an independent WebviewAAR to the outside. Based on the original channel of the native WebView APK, many modules in the native WebView APK are compiled into a Custom WebView AAR as a whole, and the Custom WebView AAR is provided separately to third-party developers for compilation dependency. The Custom WebView AAR and the third-party APP are finally compiled into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs to the greatest extent.

[0011] Furthermore, Custom WebView AAR includes two modules: the lower module is the CustomWebView AAR module, which compiles and packages the entire Chromium module into an independent AAR; the upper module is the third-party app module that uses the WebView interface.

[0012] Furthermore, Custom WebView AAR is directly compiled into the third-party APP, which directly calls the Glue bridge layer of Custom WebViewAAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, Content layer, WebKit Glue layer, and finally calls the core Blink module.

[0013] Furthermore, to quickly transform an APP built based on System WebView to use CustomWebView AAR, that is, to transform a third-party APP to use Custom WebView AAR, the following steps are included:

[0014] Change the package name of System WebView in the original Chromium to Custom WebView AAR package name;

[0015] Change the System WebView used in the layout file to the full name of the Custom WebView AAR package name;

[0016] Add dependency on the Custom WebView AAR package and recompile.

[0017] Furthermore, generate the Custom WebView AAR, which specifically includes the following steps:

[0018] Ported AOSP FWK WebView SDK code, added android_library template and compiled it into a separate jar;

[0019] Modify Chromium Code and compile to generate Custom WebView AAR;

[0020] Write a Demo based on the Custom WebView AAR interface to verify the Custom WebView AAR function.

[0021] Furthermore, port the AOSP FWK WebView SDK code, add the android_library template and compile it into a separate jar. Specifically, move the java files in the frameworks / base / core / java / android / webkit / directory in the AOSP FWK to the pre-selected directory of the chromium code repository, and then change the dependent package name to the Custom WebView package name (for example, custom.webkit.webview), add the android_library gn template, and compile it into a CustomWebView JAR.

[0022] Furthermore, port the AOSP FWK WebView SDK code, add the android_library template and compile it into a separate jar, which includes the following steps:

[0023] Move the java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the pre-selected directory of the Chromium code repository, and change the package name to Custom WebView package name;

[0024] Change the original reflection call to WebView APK in the original AOSP FWK layer frameworks / base / core / java / android / webkit / directory to direct call;

[0025] Compile the android_library template and compile the Custom WebView JAR for later compilation of the CustomWebView AAR dependency.

[0026] Furthermore, modify the Chromium Code and compile to generate Custom WebView AAR. Specifically, modify the src / android_webview directory, change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface, and finally compile the many modules inside Chromium together to generate CustomWebView AAR through the dist_aar template of the gn build system inside Chromium and refer to the gn compilation chain of the native webview apk.

[0027] Further, modify the Chromium Code and compile to generate the Custom WebView AAR, which includes the following steps:

[0028] Change the original dependency on System WebView interface in the src / android_webview directory to dependency on CustomWebView interface;

[0029] Sort out the WebView gn compilation dependency chain to prepare for subsequent work;

[0030] Through the dist_aar template, all modules involved in the compiled WebView gn dependency chain are compiled and packaged into aar.

[0031] Furthermore, through the dist_aar template, all the modules involved in the compiled WebView gn dependency chain are compiled and packaged into aar. Specifically, when generating aar through the dist_aar template, specific res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled CustomWebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

[0032] Another preferred embodiment of the present invention provides a device for deeply customizing WebView and providing an independent Webview AAR to the outside. Based on the original channel of the native WebView APK, the device compiles many modules in the native WebView APK into a Custom WebView AAR as a whole, and provides the Custom WebView AAR separately to third-party developers for compilation dependencies. The Custom WebView AAR and the third-party APP are finally compiled into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs to the greatest extent.

[0033] Furthermore, Custom WebView AAR includes two modules: the lower module is the CustomWebView AAR module, which compiles and packages the entire Chromium module into an independent AAR; the upper module is the third-party app module that uses the WebView interface.

[0034] Furthermore, Custom WebView AAR is directly compiled into the third-party APP, which directly calls the Glue bridge layer of Custom WebViewAAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, Content layer, WebKit Glue layer, and finally calls the core Blink module.

[0035] Furthermore, an app built on System WebView can be quickly transformed to use CustomWebView AAR, including the following modules:

[0036] The first renaming module is used to change the relevant package name of System WebView in the original Chromium to the relevant package name of Custom WebView AAR;

[0037] The second renaming module is used to change the System WebView used in the layout file to the full name of the CustomWebView AAR package name;

[0038] Add a module to add dependency on the Custom WebView AAR package and recompile.

[0039] Furthermore, the following modules are specifically included:

[0040] Porting module, used to port AOSP FWK WebView SDK code, add android_library template to compile into a separate jar;

[0041] Compilation module, used to modify Chromium Code and compile to generate Custom WebView AAR;

[0042] Verification module, used to write Demo based on Custom WebView AAR interface and verify Custom WebViewAAR function.

[0043] Furthermore, transplant the module, specifically move the java files in the frameworks / base / core / java / android / webkit / directory in AOSP FWK to the pre-selected directory of the chromium code repository, then change the dependent package name to the Custom WebView package name (for example, custom.webkit.webview), add the android_library gn template, and compile it into Custom WebView JAR.

[0044] Furthermore, the transplantation module specifically includes the following units:

[0045] The mobile unit is used to move the Java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the pre-selected directory of the Chromium code repository, and change the package name to Custom WebView package name;

[0046] The call modification unit is used to change the original reflective call to WebView APK in the original AOSP FWK layer frameworks / base / core / java / android / webkit / directory to a direct call;

[0047] Compilation unit, used to compile android_library template and Custom WebView JAR for later compilation of Custom WebView AAR dependency.

[0048] Furthermore, compile the module, specifically modify the src / android_webview directory, change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface, and finally compile many modules inside Chromium together to generate Custom WebView AAR through the dist_aar template of the Chromium internal gn build system and refer to the gn compilation chain of the native webview apk.

[0049] Furthermore, the compilation module specifically includes the following units:

[0050] Modify the unit to change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface;

[0051] The combing unit is used to comb the WebView gn compilation dependency chain to prepare for subsequent work;

[0052] The packaging unit compiles and packages all the modules involved in the compiled WebView gn compilation dependency chain into aar through the dist_aar template.

[0053] Furthermore, when the packaging unit generates aar through the dist_aar template, specific res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled Custom WebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

[0054] Another preferred embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements any of the above methods.

[0055] Another preferred embodiment of the present invention provides a computer-readable storage medium storing a computer program, characterized in that the computer program enables the computer to implement a method of deeply customizing a WebView as described above and providing an independent Webview AAR to the outside when the computer is executed.

[0056] Technical Effects

[0057] The present invention provides a method, device and electronic device for deeply customizing WebView, providing an independent Webview AAR to the outside world, compiling the content of the original Custom WebView APK into a Custom WebView AAR as a whole, and then providing the Custom WebView AAR to the developer of the third-party App as a compilation dependency when compiling the third-party App, so that the CustomWebView AAR and the third-party App are compiled together. This allows the third-party App to freely customize the WebView kernel, and at the same time, the third-party App can independently upgrade the WebView kernel without any impact on other Apps that also use the WebView interface, so that application developers can freely modify the customized WebView kernel without worrying about the impact on other Apps, meeting the special needs of the application and making up for the shortcomings of System WebView.

[0058] The concept, specific structure and technical effects of the present invention will be further described below to fully understand the purpose, characteristics and effects of the present invention. DETAILED DESCRIPTION

[0059] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0060] In the following description, specific details such as specific internal procedures and techniques are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0061] The present invention provides a method for deeply customizing WebView and providing an independent Webview AAR to the outside. Based on the original channel of the native WebView APK, many modules in the native WebView APK are compiled into a CustomWebView AAR as a whole, and the Custom WebView AAR is provided separately to third-party developers for compilation dependency. The Custom WebViewAAR and the third-party APP are finally compiled into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs to the greatest extent.

[0062] The Custom WebView AAR consists of two modules: the lower one is the Custom WebViewAAR module, which compiles and packages the entire Chromium module into an independent AAR; the upper one is the third-party app module that uses the WebView interface. The lower Custom WebView AAR module compiles and packages the entire Chromium module into an independent AAR, which is provided to application developers as the Custom WebView interface layer in the form of custom.webkit.WebView package name.

[0063] The Custom WebView AAR module above compiles the Custom WebView AAR directly into the third-party APP. It does not need to reflect the call to the WebView Chromuim kernel. It directly calls the Glue bridge layer of the Custom WebView AAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, Content layer, WebKit Glue layer, and finally calls the core Blink module.

[0064] To quickly transform an APP built based on System WebView to use Custom WebView AAR, that is, to transform a third-party APP to use Custom WebView AAR, the following steps are included:

[0065] Change the package name of System WebView in the original Chromium to Custom WebView AAR package name;

[0066] Change the System WebView used in the layout file to the full name of the Custom WebView AAR package name;

[0067] Add dependency on the Custom WebView AAR package and recompile.

[0068] A preferred embodiment of the present invention provides a method for deeply customizing WebView and providing an independent Webview AAR to the outside world. Generating Custom WebView AAR specifically includes the following steps:

[0069] Step 100, port the AOSP FWK WebView SDK code, add the android_library template and compile it into a separate jar;

[0070] Step 200, modify the Chromium Code, compile and generate the Custom WebView AAR;

[0071] Step 300: Write a Demo based on the Custom WebView AAR interface to verify the Custom WebView AAR function.

[0072] Among them, step 100, transplant AOSP FWK WebView SDK code, add android_library template to compile into a separate jar, specifically, move the java files in the frameworks / base / core / java / android / webkit / directory in AOSP FWK to the pre-selected directory of the chromium code warehouse, and then modify the dependent package name to Custom WebView package name (such as custom.webkit.webview), add android_library gn template, and compile it into CustomWebView JAR. Specifically include the following steps:

[0073] Step 101, move the java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the pre-selected directory of the Chromium code repository, and change the package name to Custom WebView package name. In this embodiment, the present invention is changed to custom.webkit.xxx

[0074]

[0075] Step 102, change the original reflection call to WebView APK in the original AOSP FWK layer frameworks / base / core / java / android / webkit / directory to a direct call; because the Code of the native WebView interface layer is implemented by reflection call to WebView APK, now under the WebView AAR solution, reflection call is no longer required, and the original reflection call needs to be changed to a direct call.

[0076] Step 103, compile the android_library template and the Custom WebView JAR for later compilation of the Custom WebView AAR dependency. Compile the android_library template and the Custom WebView JAR for later compilation of the Custom WebView AAR dependency. The compilation method is as follows:

[0077]

[0078]

[0079] Step 200, modify the Chromium Code, compile and generate Custom WebView AAR, specifically modify the src / android_webview directory, change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface. In the embodiment of the present invention, taking the Custom WebView package name custom.webkit.WebView as an example, the import android.wekkit.xxx interface in the java file is changed to import custom.webkit.xxx, and finally, through the dist_aar template of the gn build system inside chromium, refer to the gn compilation chain of the native webview apk, and compile many modules inside chromium together to generate Custom WebViewAAR.

[0080] The specific steps include:

[0081] Step 201, change the original dependency on System WebView interface in the src / android_webview directory to dependency on Custom WebView interface; mainly change the original dependency on System WebView in the java code in the src / android_webview directory to dependency on Custom WebView (including import package name, return value package name, parameter package name, the present invention changes the original android.webkit.xxx to custom.webkit.xxx), which is roughly as follows:

[0082]

[0083] Step 202, sort out the WebView gn compilation dependency chain to prepare for subsequent work;

[0084] Step 203, compile and package all the modules involved in the compiled WebView gn compilation dependency chain into aar through the dist_aar template. When compiling the Custom WebView AAR with the dist_aar template, it is necessary to remove the redundant fields in the AndroidManifest.xml of the original WebView APK, such as

[0085] <activity android:name="org.chromium.android_webview.devui.MainActivity"> Fields,<application android:extractNativeLibs> fields, etc. Otherwise, Custom WebView AAR will report an error when compiled when integrated with a third-party app.

[0086] At the same time, the template ("dist_aar") template provided in the official src / build / config / android / rules.gni only supports packaging the following resources by default

[0087] #Currently supports:

[0088] #*AndroidManifest.xml

[0089] #*classes.jar

[0090] #*jni /

[0091] #*res /

[0092] #*R.txt

[0093] #*proguard.txt

[0094] The following resources are not currently supported for packaging, especially assets resources.

[0095] #Does not yet support:

[0096] #*public.txt

[0097] #*annotations.zip

[0098] #*assets /

[0099]

[0100]

[0101] The Custom WebView AAR we generate by default does not contain asset resources, so we need to write additional shell scripts to perform secondary processing on the generated Custom WebView AAR. The main work is to decompress the original aar, copy the asset resources to the decompressed directory, and then recompress it into Custom WebView AAR, because aar is essentially a compressed package.

[0102] Finally, through the dist_aar template, all the modules involved in the compiled dependency chain of WebView gn are compiled and packaged into aar. Specifically, when generating aar through the dist_aar template, specific res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled CustomWebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

[0103] An embodiment of the present invention provides a method for deeply customizing WebView and providing an independent Webview AAR to the outside world. The Custom WebView AAR solution is used to finally compile the AAR and the third-party APP into the same APK. Modifications to the WebView kernel will only affect the current APP, so that the third-party developers can freely customize the WebView kernel according to their own needs without worrying about the impact on other apps. The Custom WebView AARs integrated and used by different APPs are isolated from each other to avoid conflicts and contamination during use. The Custom WebView AAR solution has an independent Custom WebView interface layer and implementation layer. Application developers can freely modify and customize the Custom WebView AAR interface and implementation. Such modifications and customizations are only effective for this APP and will not have any impact on other APPs, thereby meeting the diverse needs of applications for WebView.

[0104] The interface definition and usage of Custom WebView AAR are very similar to those of System WebView (only the interface package name is different), which can maximize the reuse of previous experience or the transformation of previous applications based on System WebView. Application developers can seamlessly migrate to the integrated development of CustomWebView AAR based on their original System WebView integrated development experience. At the same time, an APP built on System WebView can also be quickly transformed to use Custom WebView AAR.

[0105] It should also be noted that after modifying the kernel, a deeply customized WebView provided by an embodiment of the present invention and a method for providing an independent Webview AAR to the outside will compile the modified kernel as a whole into an AAR, and the form and carrier of the modified kernel provided to the outside is AAR (AAR (Android Archive) is a compiled binary archive file format on the Android platform, but it cannot be installed independently). Moreover, an embodiment of the present invention provides a deeply customized WebView, and a method for providing an independent Webview AAR to the outside is used only for a single APP using the Custom WebView interface. This kernel belongs exclusively to this APP, and the kernel carrier in the form of AAR provided to the outside will eventually be compiled into the APP using the Custom WebView interface. The AAR kernels that multiple APPs depend on for compilation are isolated from each other and do not affect each other. Moreover, the interface layer and the implementation layer in this embodiment are not separated, and are compiled in the same AAR, and are eventually compiled into the final third-party app along with the AAR.

[0106] Another preferred embodiment of the present invention provides a device for deeply customizing WebView and providing an independent Webview AAR to the outside. Based on the original channel of the native WebView APK, the device compiles many modules in the native WebView APK into a Custom WebView AAR as a whole, and provides the Custom WebView AAR separately to third-party developers for compilation dependencies. The Custom WebView AAR and the third-party APP are finally compiled into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs to the greatest extent.

[0107] Furthermore, Custom WebView AAR includes two modules: the lower module is the CustomWebView AAR module, which compiles and packages the entire Chromium module into an independent AAR; the upper module is the third-party app module that uses the WebView interface.

[0108] Furthermore, Custom WebView AAR is directly compiled into the third-party APP, which directly calls the Glue bridge layer of Custom WebViewAAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, Content layer, WebKit Glue layer, and finally calls the core Blink module.

[0109] Furthermore, an app built on System WebView can be quickly transformed to use CustomWebView AAR, including the following modules:

[0110] The first renaming module is used to change the relevant package name of System WebView in the original Chromium to the relevant package name of Custom WebView AAR;

[0111] The second renaming module is used to change the System WebView used in the layout file to the full name of the CustomWebView AAR package name;

[0112] Add a module to add dependency on the Custom WebView AAR package and recompile.

[0113] Furthermore, the following modules are specifically included:

[0114] Porting module, used to port AOSP FWK WebView SDK code, add android_library template to compile into a separate jar;

[0115] Compilation module, used to modify Chromium Code and compile to generate Custom WebView AAR;

[0116] Verification module, used to write Demo based on Custom WebView AAR interface and verify Custom WebViewAAR function.

[0117] Furthermore, transplant the module, specifically move the java files in the frameworks / base / core / java / android / webkit / directory in AOSP FWK to the pre-selected directory of the chromium code repository, then change the dependent package name to the Custom WebView package name (for example, custom.webkit.webview), add the android_library gn template, and compile it into Custom WebView JAR.

[0118] Furthermore, the transplantation module specifically includes the following units:

[0119] The mobile unit is used to move the Java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the pre-selected directory of the Chromium code repository, and change the package name to Custom WebView package name;

[0120] The call modification unit is used to change the original reflective call to WebView APK in the original AOSP FWK layer frameworks / base / core / java / android / webkit / directory to a direct call;

[0121] Compilation unit, used to compile android_library template and Custom WebView JAR for later compilation of Custom WebView AAR dependency.

[0122] Furthermore, compile the module, specifically modify the src / android_webview directory, change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface, and finally compile many modules inside Chromium together to generate Custom WebView AAR through the dist_aar template of the Chromium internal gn build system and refer to the gn compilation chain of the native webview apk.

[0123] Furthermore, the compilation module specifically includes the following units:

[0124] Modify the unit to change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface;

[0125] The combing unit is used to comb the WebView gn compilation dependency chain to prepare for subsequent work;

[0126] The packaging unit compiles and packages all the modules involved in the compiled WebView gn compilation dependency chain into aar through the dist_aar template.

[0127] Furthermore, when the packaging unit generates aar through the dist_aar template, specific res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled Custom WebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

[0128] The above embodiment provides a device for deeply customizing a WebView and providing an independent Webview AAR to the outside world. The method for implementing a method for deeply customizing a WebView and providing an independent Webview AAR to the outside world is the same as above, so it will not be repeated here.

[0129] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, any of the above methods is implemented. This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, any of the above methods is implemented.

[0130] The computer device of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the above-mentioned data synchronization method embodiments are implemented. Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0131] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the computer device.

[0132] The computer device may be a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The computer device may include, but is not limited to, a processor and a memory.

[0133] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0134] The memory may be an internal storage unit of the computer device, such as a hard disk or memory of the computer device. The memory may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Furthermore, the memory may include both an internal storage unit and an external storage device of the computer device. The memory is used to store the computer program and other programs and data required by the computer device. The memory may also be used to temporarily store data that has been output or is to be output.

[0135] In another preferred embodiment of the present invention, the present invention provides a computer-readable storage medium storing a computer program, and the computer program enables the computer to implement a method of deeply customizing a WebView as any of the above items and providing an independent Webview AAR to the outside when executed.

[0136] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A method of deeply customizing WebView, It is characterized in that On the basis of the original channel of native WebView APK, many modules in native WebView APK are compiled into a Custom WebView AAR as a whole, and the CustomWebView AAR is provided to third-party developers for compilation dependency separately. The Custom WebView AAR and third-party APP are finally compiled into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs. The Custom WebView AAR includes two modules, the lower module is the Custom WebView AAR module, and the entire Chromium module is compiled and packaged into an independent AAR. AAR is provided to application developers as the Custom WebView interface layer in the form of custom.webkit.WebView package name; the upper module is the third-party app module that uses the WebView interface; The generated Custom WebView AAR does not contain assets. Write an additional shell script to perform secondary processing on the generated Custom WebView AAR to decompress the original aar, copy the assets to the decompressed directory, and then recompress it into Custom WebView AAR. The Custom WebView AARs integrated and used by different APPs are isolated from each other to avoid conflicts and contamination during use; the Custom WebView AAR solution has an independent Custom WebView interface layer and implementation layer. Application developers can freely modify and customize the Custom WebView AAR interface and implementation. Such modifications and customizations are only effective for this APP and will not have any impact on other APPs, thereby meeting the diverse needs of applications for WebView.

2. A method for deeply customizing WebView as claimed in claim 1, It is characterized in that The CustomWebView AAR is directly compiled into the third-party APP, which directly calls the Glue bridge layer of the Custom WebView AAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, the Content layer, the WebKit Glue layer, and finally calls the core Blink module.

3. A method for deeply customizing WebView as claimed in claim 1, It is characterized in that To quickly transform an APP built based on System WebView to use Custom WebView AAR, that is, to transform a third-party APP to use Custom WebView AAR, the following steps are included: Change the package name of System WebView in the original Chromium to Custom WebView AAR package name; Change the System WebView used in the layout file to the full name of the Custom WebView AAR package name; Add dependency on the Custom WebView AAR package and recompile.

4. A method for deeply customizing WebView as claimed in claim 1, It is characterized in that Generating CustomWebView AAR includes the following steps: Ported AOSP FWK WebView SDK code, added android_library template and compiled it into a separate jar; Modify Chromium Code and compile to generate Custom WebView AAR; Write a Demo based on the Custom WebView AAR interface to verify the Custom WebView AAR function.

5. A method for deeply customizing WebView as claimed in claim 4, It is characterized in that Port the AOSP FWKWebView SDK code, add the android_library template and compile it into a separate jar. Specifically, move the java files in the frameworks / base / core / java / android / webkit / directory in the AOSP FWK to the pre-selected directory of the chromium code repository, change the dependent package name to the Custom WebView package name, add the android_library gn template, and compile it into a Custom WebView JAR.

6. A method for deeply customizing WebView as claimed in claim 5, It is characterized in that Port the AOSP FWKWebView SDK code, add the android_library template and compile it into a separate jar. The specific steps include: Move the Java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the pre-selected directory of the Chromium code repository, and change the package name to Custom WebView package name; Change the original reflection call to WebView APK in the original AOSP FWK layer frameworks / base / core / java / android / webkit / directory to direct call; Compile the android_library template and compile the Custom WebView JAR for later compilation of the Custom WebViewAAR dependency.

7. A method for deeply customizing WebView as claimed in claim 4, It is characterized in that Modify ChromiumCode and compile to generate Custom WebView AAR. Specifically, modify the src / android_webview directory and change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface. Finally, through the dist_aar template of the gn build system inside Chromium, refer to the gn compilation chain of the native webview apk, and compile many modules inside Chromium together to generate Custom WebView AAR.

8. A method for deeply customizing WebView as claimed in claim 7, It is characterized in that Modify ChromiumCode and compile to generate Custom WebView AAR, including the following steps: Change the original dependency on System WebView interface in the src / android_webview directory to dependency on CustomWebView interface; Sort out the WebView gn compilation dependency chain to prepare for subsequent work; Through the dist_aar template, all modules involved in the compiled WebView gn dependency chain are compiled and packaged into aar.

9. A method for deeply customizing WebView as claimed in claim 8, It is characterized in that Through the dist_aar template, all the modules involved in the compiled WebView gn dependency chain are compiled and packaged into aar. Specifically, when generating aar through the dist_aar template, the specified res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled Custom WebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

10. A device for deeply customizing WebView, It is characterized in that Based on the original channel of the native WebView APK, the device compiles many modules in the native WebView APK into a Custom WebView AAR as a whole, provides the Custom WebView AAR separately to third-party developers for compilation dependency, and finally compiles the Custom WebView AAR and the third-party APP into the same APK, which can avoid conflicts and pollution between WebView kernels used by different APPs; the Custom WebView AAR includes two major modules, the lower module is the Custom WebView AAR module, which compiles and packages the entire Chromium module into an independent AAR; the upper module is the third-party app module using the WebView interface; The generated Custom WebView AAR does not contain assets. Write an additional shell script to perform secondary processing on the generated Custom WebView AAR to decompress the original aar, copy the assets to the decompressed directory, and then recompress it into Custom WebView AAR. The Custom WebView AARs integrated and used by different APPs are isolated from each other to avoid conflicts and contamination during use; the Custom WebView AAR solution has an independent Custom WebView interface layer and implementation layer. Application developers can freely modify and customize the Custom WebView AAR interface and implementation. Such modifications and customizations are only effective for this APP and will not have any impact on other APPs, thereby meeting the diverse needs of applications for WebView.

11. A device for deeply customizing WebView as claimed in claim 10, It is characterized in that The CustomWebView AAR is directly compiled into the third-party APP, which directly calls the Glue bridge layer of the Custom WebView AAR, and then passes through the internal layered architecture of Chromium, through the AWContent layer, the Content layer, the WebKit Glue layer, and finally calls the core Blink module.

12. The device for deeply customizing WebView according to claim 10, It is characterized in that Quickly transform an APP built based on System WebView to use Custom WebView AAR, including the following modules: The first renaming module is used to change the relevant package name of System WebView in the original Chromium to the relevant package name of CustomWebView AAR; The second renaming module is used to change System WebView used in the layout file to the full name of the CustomWebView AAR package name; The addition module is used to add a dependency on the Custom WebView AAR package and recompile.

13. A device for deeply customizing WebView according to claim 10, characterized in that, specifically includes the following modules: The transplantation module is used to transplant the AOSP FWK WebView SDK code, add the android_library template and compile it into a separate jar; The compilation module is used to modify the Chromium Code and compile to generate the Custom WebView AAR; The verification module is used to write a Demo based on the Custom WebView AAR interface to verify the function of the Custom WebView AAR.

14. A device for deeply customizing WebView according to claim 13, characterized in that, The transplantation module specifically moves the java files in the frameworks / base / core / java / android / webkit / directory in AOSP FWK to the preselected directory of the chromium code repository, and then modifies the dependent package name to the Custom WebView package name, and then adds the android_library gn template and compiles it into the Custom WebView JAR.

15. A device for deeply customizing WebView according to claim 14, characterized in that, The transplantation module specifically includes the following units: The moving unit is used to move the java files in the frameworks / base / core / java / android / webkit / directory of the AOSP FWK layer to the preselected directory of the Chromium code repository and modify the package name to the Custom WebView package name; The call modification unit is used to change the original reflection call to the WebView APK in the frameworks / base / core / java / android / webkit / directory of the original AOSP FWK layer to a direct call; The compilation unit is used to compile the android_library template and compile the Custom WebView JAR for use in the subsequent compilation of the Custom WebView AAR dependency.

16. A device for deeply customizing WebView according to claim 13, characterized in that, The compilation module specifically modifies the src / android_webview directory, changes the original dependency on the SystemWebView interface in the src / android_webview directory to the dependency on the Custom WebView interface, and finally compiles many modules inside Chromium together to generate Custom WebView AAR through the dist_aar template of the Chromium internal gn build system and the reference to the gn compilation chain of the native webview apk.

17. A device for deeply customizing WebView as claimed in claim 16, It is characterized in that The compilation module specifically includes the following units: Modify the unit to change the original dependency on the System WebView interface in the src / android_webview directory to the dependency on the Custom WebView interface; The combing unit is used to comb the WebView gn compilation dependency chain to prepare for subsequent work; The packaging unit compiles and packages all the modules involved in the compiled WebView gn compilation dependency chain into aar through the dist_aar template.

18. A device for deeply customizing WebView as claimed in claim 17, It is characterized in that When the packaging unit generates aar through the dist_aar template, the specified res and classes are excluded through resource_included_patterns and jar_excluded_patterns. Otherwise, the compiled Custom WebView AAR will be very large, and when the third-party app also depends on the android.support package, the compilation will report an error.

19. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the method according to any one of claims 1 to 9 is implemented.

20. A computer-readable storage medium storing a computer program, It is characterized in that The computer program enables a computer to implement a method for deeply customizing a WebView as described in any one of claims 1-9 when executed.

Citation Information

Patent Citations

  • WebView deep customization method and device, and electronic equipment

    CN113672231A