A method, device, and storage medium for running Android H5 in Hongmeng compatibility
By installing the data processor and cross -system data parser in the Hongmeng system, the problem of being unable to run the Android H5 application of the Hongmeng system can be solved, and the compatible operation and two -way communication of the H5 application on the Hongmeng system are reduced, reducing the development complexity And resource consumption.
Patent Information
- Application Number
- CN202111423370.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2041-11-26
AI Technical Summary
The Hongmeng system is not compatible with running Android H5 applications, and it needs to modify the underlying code of H5, which makes development cumbersome and time-consuming.
Install a data processor and a cross-system data parser in the Hongmeng system to process and parse the data interaction between H5 applications and Hongmeng HAP to ensure consistent data structures.
Through the cooperation of the data parser and the data processor, the compatible operation of the H5 application on the Hongmeng system is realized, reducing the time consumption and flow consumption of resource loading, realizing two -way communication, and supplementing the functions that the native WebView cannot achieve.
Smart Images

Figure CN114116062B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Hongmeng application development, and in particular to a method, device, and storage medium for running Android H5 in Hongmeng compatibility. Background Art
[0002] As an emerging domestic system, Hongmeng has attracted much attention in China since its release. Hongmeng, like Android, is developed based on the Linux kernel. Hongmeng and Android are compatible to the greatest extent. The original intention was to benchmark the Android system, not to surpass or subvert Android, but to coexist with Android for a long time. Due to compatibility, the ecosystems of the two are highly similar.
[0003] Although Hongmeng is compatible with Android applications to the greatest extent, it is not all. For example, H5 applications on the Android system that use Webview as the main interactive medium usually customize communication. However, if the H5 application on Android wants to run on Hongmeng, the underlying code of H5 needs to be modified, otherwise it will not be able to run on Hongmeng.
[0004] In order to reduce the repeated development of H5, when the Hongmeng system develops applications that use Webview as the interactive medium, it is necessary to develop a solution for Hongmeng native applications that can be compatible with H5 running on the Android system on Hongmeng. Summary of the invention
[0005] This application provides a method for running Android H5 on Hongmeng, which solves the cumbersome, time-consuming and labor-intensive technical problem caused by the inability of Hongmeng to run Android H5 and the need to modify the underlying logic of H5.
[0006] A method for running Android H5 in Hongmeng compatibility, wherein a data processor and a cross-system data parser are installed in the Hongmeng system and applied to the data interaction process between Hongmeng end HAP and H5, including:
[0007] When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic;
[0008] Then the standard data is parsed into second business data by the data parser;
[0009] When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0010] In one embodiment of the present application, when the Hongmeng-side HAP receives the first business data from the H5 application, it specifically includes: the Hongmeng-side HAP intercepts the resource request according to whether the uniform resource locator isNeedLoadUrl instruction needs to be loaded, and obtains the request uniform resource locator URL; encodes the request URL to obtain the original URL string; and determines the processing method of the first business data according to the data structure of the original URL string.
[0011] In one embodiment of the present application, a data processor is also installed in the Hongmeng system; according to the data structure of the original URL string, a processing method for the first business data is determined, specifically including: analyzing the data structure of the URL string by the cross-system data parser, and judging whether it is a URL that needs to be processed or a normally overloaded URL according to the data structure; if it needs to be processed, parsing it into standard data by the data parser, and then converting the standard data into second business data; sending the second business data to the processor; if it is a normally overloaded URL, directly loading H5 through the Hongmeng system's web view Webview.
[0012] In one embodiment of the present application, before the Hongmeng HAP interacts with the H5 application for data, the method also includes: enabling application permissions to enable the Hongmeng system to support business processing; the application permissions that need to be enabled include security mode SecurityMode, image permission ImagePermit, data capability DataAbility, positioning permission locationPermit, and web page storage permission webStoragePremit; wherein, SecurityMode is set to fully allow to support H5 links using HTTP protocol and HTTPS protocol.
[0013] In one embodiment of the present application, during the process of data interaction between the Hongmeng-end HAP and the H5 application, the method also includes: when the Webview completes loading of the H5 and triggers the onPageLoaded instruction, the js file in the rawfile folder is loaded to the H5 application through the load instruction of the Webview for building jsbridge communication.
[0014] In one embodiment of the present application, before the Hongmeng-end HAP interacts with the H5 application for data, the method further includes: enabling the Hongmeng system Webview to support JavaScript through the web page configuration WebConfig so that the js file can be loaded normally.
[0015] In one embodiment of the present application, before the Hongmeng-end HAP interacts with the H5 application for data, the method further includes: marking the system for data interaction by setting a UserAgent identifier, so that the visited website displays different layouts depending on the type of browser.
[0016] A device compatible with Hongmeng and running Android H5, characterized by comprising:
[0017] at least one processor; and,
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0020] When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic;
[0021] Then the standard data is parsed into second business data by the data parser;
[0022] When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0023] In one embodiment of the present application, the at least one processor is also used for: the Hongmeng-end HAP intercepts the resource request according to whether the uniform resource locator isNeedLoadUrl instruction needs to be loaded, and obtains the request uniform resource locator URL; encodes the request URL to obtain the original URL string; determines the processing method of the first business data according to the data structure of the original URL string; and transmits the processed first business data to the Hongmeng-end HAP.
[0024] A non-volatile storage medium storing computer executable instructions, wherein the computer executable instructions are configured to:
[0025] When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic;
[0026] Then the standard data is parsed into second business data by the data parser;
[0027] When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0028] This application provides a method for running Android H5 in Hongmeng compatibility, which includes at least the following beneficial effects: by placing the interactive js files that each H5 needs to load on the Hongmeng end, the time and traffic consumption of resource loading are reduced; the business data is converted into a standardized data structure through a data parser, and the standard data is parsed, and then the corresponding business implementation on each system is processed through a systematic data processor to realize the processing of H5 cross-system interaction. Through the custom communication of H5, the two-way communication between Hongmeng native applications and H5 is realized, which effectively supplements the function of running Android H5 compatibility that the native Webview cannot realize alone. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0030] Figure 1 A schematic diagram of the steps of a method for running Android H5 in Hongmeng compatibility provided in an embodiment of the present application;
[0031] Figure 2 A schematic diagram of the composition of a device that is compatible with Hongmeng and runs Android H5 is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described clearly and completely in conjunction with the specific embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0033] In the existing technology, Hongmeng system, as an emerging domestic system, has attracted much attention in China since its release. As a completely domestic distributed system, although it is compatible with running Android applications, no matter what the considerations are, it is necessary to develop Hongmeng applications that are completely based on the Hongmeng system application programming interface (Application Programming Interface, API).
[0034] In order to facilitate interaction with Hongmeng native applications, applications using the fifth version of the Hypertext Markup Language (HTML5, H5) on the Android system that use the web view Webview as the main interactive medium usually customize communication. When developing applications using Webview as the interactive medium on the Hongmeng system, in order to reduce the duplication of H5 development, it is necessary to develop a hybrid development architecture for Hongmeng native applications that can be compatible with H5 running on the Android system on Hongmeng and can communicate according to custom standards. In this way, H5 applications that can run on Android can also run on Hongmeng without modifying the underlying code.
[0035] By placing the interactive js files that each H5 needs to load on the Hongmeng side, the time and traffic consumption of resource loading are reduced; the business data is converted into a standardized data structure through the data parser, the standard data is parsed, and then the corresponding business implementation on each system is processed through the systematic data processor to realize the processing of H5 cross-system interaction. Through the custom communication of H5, the two-way communication between Hongmeng native applications and H5 is realized, which effectively supplements the compatibility and running of Android H5 that the native Webview cannot realize alone. The following is a detailed explanation.
[0036] In one embodiment of the present application, a method for running Android H5 in HarmonyOS compatibility is provided by the present application, which is implemented through a hybrid development architecture based on HarmonyOS Webview. The hybrid development architecture HarmonyOS Webview supports JavaScript and has built-in Js files for supporting two-way communication. The framework includes a cross-system standard data parser and a data processor for the HarmonyOS system.
[0037] The data parser is responsible for passing the standard data from H5 to the Hongmeng native application, parsing the business data, and then passing the business data to the data processor of the Hongmeng Ability Package (HAP) on the Hongmeng side. Or it converts the data processed by the Hongmeng HAP data processor into standard communication data, and then passes or calls back to the H5 application.
[0038] The data processor of the Hongmeng system is responsible for processing the business data parsed by the data parser according to the business rules. After processing, if no callback is required, it will not be processed again; if callback data needs to be sent to H5, the callback data will be passed to the parser and then called back to H5.
[0039] Before the Hongmeng HAP and H5 application interact with each other, the following settings need to be made:
[0040] Enable JavaScript support in the HarmonyOS Webview through the WebConfig command on the web page so that the js file can be loaded normally and the normal communication between the H5 application and the HarmonyOS HAP can be ensured.
[0041] Since it is necessary to ensure that H5 applications can interact normally across systems, the data parser uses the same logic as the Android system to ensure the same data structure and can be used compatible with both systems.
[0042] Set the UserAgent identifier to mark the system that interacts with data to ensure that different systems can be identified, so that the visited website displays different layouts depending on the type of browser.
[0043] Enable the application permissions of Hongmeng system, including setting the security mode SecurityMode to fully allow WebConfig.SECURITY_ALLOW through WebConfig, so that Webview can load Hypertext Transfer Protocol (HTTP) links or load HTTP resources, and support H5 links using HTTP protocol and Hypertext Transfer Protocol Secure (HTTPS).
[0044] Use WebConfig to set application permissions such as image permission ImagePermit, data capability DataAbility, positioning permission locationPermit, web storage permission webStoragePremit, etc., so that the Hongmeng system can support business processing.
[0045] Figure 1 A schematic diagram of a method for running Android H5 in Hongmeng compatibility provided in an embodiment of the present application may include the following steps:
[0046] S101: When the Hongmeng-end HAP receives the first business data from the H5 application, the first business data is parsed into standard data through the data parser; wherein the data parser and the Android system use the same parsing logic.
[0047] In one embodiment of the present application, the first business data is the business data processed by the Hongmeng end HAP, and the second business data is the business data processed on the H5 application. Since the H5 application and the Hongmeng end HAP cannot directly process each other's data, the business data of both parties must be converted into standard data and then converted into business data that can be processed by both parties. In this way, the compatibility between the H5 application and the Hongmeng system is achieved.
[0048] During the data interaction between Hongmeng HAP and H5 application, when Webview finishes loading H5 and triggers the onPageLoaded instruction, the js file in the rawfile folder is loaded to the H5 application through the load instruction of Webview for building jsbridge communication.
[0049] When the jsbridge communication is built, the Hongmeng-side HAP intercepts the resource request based on whether the uniform resource locator isNeedLoadUrl instruction needs to be loaded, and obtains the request uniform resource locator URL; then encodes the request URL to obtain the original URL string; and determines the processing method of the first business data based on the data structure of the original URL string.
[0050] After obtaining the original URL string, the data structure of the URL string is analyzed by the cross-system data parser, and the data structure is used to determine whether it is a URL that needs to be processed or a normal overloaded URL; the first business data is processed according to the determined processing method. If it is a URL that needs to be processed, such as "icity: / / return / {timestamp} / {check code} / encoded data", it is parsed into standard data through the data parser, and then the standard data is converted into second business data; the second business data is sent to the processor; if it is a normal overloaded URL, such as "https: / / www.****.com", it is handed over to the parent class for processing, that is, the web view Webview of the Hongmeng system directly loads H5. In this way, H5 converts the first business data into standard data through the data parser through custom communication and transmits it to the Hongmeng end HAP.
[0051] S102: Then the standard data is parsed into second business data by a data parser.
[0052] S103: When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0053] Specifically, based on the Hongmeng Webview hybrid development architecture, when the Hongmeng-side HAP needs to pass the second business data to H5, it first needs to pass the second business data to the data parser, convert the second business data into standard data, and then pass it to H5 through custom communication.
[0054] The above is a method for running Android H5 in Hongmeng compatibility provided by the embodiment of the present application. Based on the same inventive idea, the embodiment of the present application also provides a corresponding device for running Android H5 in Hongmeng compatibility, such as Figure 2 shown.
[0055] This embodiment provides a device running Android H5 in Hongmeng compatibility, including:
[0056] at least one processor; and,
[0057] a memory communicatively connected to at least one processor; wherein,
[0058] The memory stores instructions executable by at least one processor, the instructions being executed by at least one processor to enable the at least one processor to:
[0059] When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic;
[0060] Then the standard data is parsed into second business data by the data parser;
[0061] When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0062] In one embodiment of the present application, the at least one processor is also used for: the Hongmeng-end HAP intercepts the resource request according to whether the uniform resource locator isNeedLoadUrl instruction needs to be loaded, and obtains the request uniform resource locator URL; encodes the request URL to obtain the original URL string; determines the processing method of the first business data according to the data structure of the original URL string; and transmits the processed first business data to the Hongmeng-end HAP.
[0063] Based on the same idea, some embodiments of the present application also provide a medium corresponding to the above method.
[0064] Some embodiments of the present application provide a storage medium that runs Android H5 in a Hongmeng-compatible manner, storing computer-executable instructions, where the computer-executable instructions are set to:
[0065] When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic;
[0066] Then the standard data is parsed into second business data by the data parser;
[0067] When the Hongmeng-end HAP sends the second business data to the H5 application, the second business data is parsed into standard data by the data parser, and then the standard data is converted into first business data and sent to the H5 application.
[0068] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the method and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0069] The methods and media provided in the embodiments of the present application correspond one-to-one to the method, and therefore, the methods and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the methods and media will not be repeated here.
[0070] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or method. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or method including the elements.
[0071] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for running Android H5 in Hongmeng compatibility, characterized in that: The cross-system data parser is installed in the Hongmeng system and applied to the data interaction between the Hongmeng end HAP and H5, including: When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic; the first service data is converted into a standardized data structure by the data parser, and the standard data is parsed; Then, the standard data is parsed into second business data by the data parser; the first business data is business data processed by the Hongmeng end HAP, and the second business data is business data processed on the H5 application; When the Hongmeng-end HAP sends the second service data to the H5 application, the second service data is parsed into standard data by the data parser, and then the standard data is converted into the first service data and sent to the H5 application; When the Hongmeng-end HAP receives the first service data from the H5 application, specifically includes: The Hongmeng-side HAP intercepts the resource request based on the isNeedLoadUrl instruction whether the uniform resource locator needs to be loaded, and obtains the request uniform resource locator URL; Encode the request URL to obtain the original URL string; Determining a processing method for the first business data according to the data structure of the original URL character string; The Hongmeng system is also equipped with a data processor; The determining, according to the data structure of the original URL character string, a processing method of the first business data specifically includes: Analyze the data structure of the URL string by the cross-system data parser, and determine whether it is a URL that needs to be processed or a normal overload according to the data structure; If it needs to be processed, the data is parsed into standard data by the data parser, and then the standard data is converted into second business data; sending the second service data to the data processor for processing; If it is a normal overloaded URL, H5 will be directly loaded through the Hongmeng system's web view Webview.
2. The method according to claim 1, characterized in that Before the Hongmeng-end HAP interacts with the H5 application, the method further includes: Enable application permissions to enable the Hongmeng system to support business processing; The application permissions that need to be enabled include security mode SecurityMode, image permission ImagePermit, data capability DataAbility, location permission locationPermit, and web storage permission webStoragePremit; Among them, set SecurityMode to fully allow to support H5 links using HTTP and HTTPS protocols.
3. The method according to claim 1, characterized in that: During the data interaction between the Hongmeng-end HAP and the H5 application, the method further includes: When Hongmeng Webview finishes loading H5 and triggers the onPageLoaded instruction, the js file in the rawfile folder is loaded to the H5 application through the load instruction of Webview for building the communication of jsbridge.
4. The method according to claim 1, characterized in that: Before the Hongmeng-end HAP interacts with the H5 application, the method further includes: Enable JavaScript support in Hongmeng system Webview through the web configuration WebConfig so that js files can be loaded normally.
5. The method according to claim 1, characterized in that Before the Hongmeng-end HAP interacts with the H5 application, the method further includes: By setting the UserAgent identifier, the system that interacts with data is marked so that the visited website displays different layouts depending on the type of browser.
6. A device running Android H5 in Hongmeng compatibility, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic; the first service data is converted into a standardized data structure by the data parser, and the standard data is parsed; Then, the standard data is parsed into second business data by the data parser; the first business data is business data processed by the Hongmeng end HAP, and the second business data is business data processed on the H5 application; When the Hongmeng-end HAP sends the second service data to the H5 application, the second service data is parsed into standard data by the data parser, and then the standard data is converted into the first service data and sent to the H5 application; When the Hongmeng-end HAP receives the first service data from the H5 application, specifically includes: The Hongmeng-side HAP intercepts the resource request based on the isNeedLoadUrl instruction whether the uniform resource locator needs to be loaded, and obtains the request uniform resource locator URL; Encode the request URL to obtain the original URL string; Determining a processing method for the first business data according to the data structure of the original URL character string; The Hongmeng system is also equipped with a data processor; The determining, according to the data structure of the original URL character string, a processing method of the first business data specifically includes: Analyze the data structure of the URL string by the cross-system data parser, and determine whether it is a URL that needs to be processed or a normal overload according to the data structure; If it needs to be processed, the data is parsed into standard data by the data parser, and then the standard data is converted into second business data; sending the second service data to the data processor for processing; If it is a normal overloaded URL, H5 will be directly loaded through the Hongmeng system's web view Webview.
7. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured to: When the Hongmeng-end HAP receives the first service data from the H5 application, the first service data is parsed into standard data by the data parser; wherein the data parser and the Android system use the same parsing logic; the first service data is converted into a standardized data structure by the data parser, and the standard data is parsed; Then, the standard data is parsed into second business data by the data parser; the first business data is business data processed by the Hongmeng end HAP, and the second business data is business data processed on the H5 application; When the Hongmeng-end HAP sends the second service data to the H5 application, the second service data is parsed into standard data by the data parser, and then the standard data is converted into the first service data and sent to the H5 application; When the Hongmeng-end HAP receives the first service data from the H5 application, specifically includes: The Hongmeng-side HAP intercepts the resource request based on the isNeedLoadUrl instruction whether the uniform resource locator needs to be loaded, and obtains the request uniform resource locator URL; Encode the request URL to obtain the original URL string; Determining a processing method for the first business data according to the data structure of the original URL character string; The Hongmeng system is also equipped with a data processor; The determining, according to the data structure of the original URL character string, a processing method of the first business data specifically includes: Analyze the data structure of the URL string by the cross-system data parser, and determine whether it is a URL that needs to be processed or a normal overload according to the data structure; If it needs to be processed, the data is parsed into standard data by the data parser, and then the standard data is converted into second business data; sending the second service data to the data processor for processing; If it is a normal overloaded URL, H5 will be directly loaded through the Hongmeng system's web view Webview.
Citation Information
Patent Citations
Image input method and device, equipment and medium
CN112328140A
Business function calling method, mobile terminal and storage medium
CN112667482A