Off-line H5 non-inductive updating method and system based on atomization version switching

By adopting an atomic version switching offline H5 seamless update method in the power grid inspection micro-application, the problems of compatibility risks and platform limitations are solved, and stable and secure updates are achieved in weak network environments.

CN121151384APending Publication Date: 2025-12-16HENAN TENGLONG INFORMATION ENG

Patent Information

Application Number
CN202511301728.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-12
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

Existing technologies have compatibility risks and platform limitations in power grid inspection micro-application scenarios, and updates are unstable in weak network environments, making it difficult to achieve seamless updates.

Method used

The offline H5 seamless update method adopts atomic version switching. By packaging and compressing H5 resources in the HarmonyOS application, the version is replaced using the atomic renaming semantics of the HarmonyOS operating system. The security and stability of the update are ensured by MD5 verification and offline resource package management.

Benefits of technology

It reduces compatibility risks caused by platform differences, improves the stability and security of updates, reduces the occurrence of white screens and anomalies, and enables seamless updates in weak network environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121151384A_ABST
    Figure CN121151384A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of mobile terminal software updating, and provides an off-line H5 non-inductive updating method based on atomization version switching, which comprises the following steps: packaging and compressing H5 resources, calling a system interface to obtain an application writable sandbox path, and comparing version numbers in the application writable sandbox path and a server; creating a target version isolation catalogue and a temporary catalogue, writing the temporary file into a sandbox catalogue in an atomic in-place manner in a blocking manner, traversing the catalogue to confirm an entry file, constructing a symbolic link to point to a new target version isolation catalogue, and replacing an original symbolic link; establishing an off-line resource management structure under an application sandbox path, judging updating according to a network strategy and a gray rule, and evaluating a system abnormal index after updating; the invention further provides an off-line H5 non-inductive updating system based on atomization version switching. The off-line H5 non-inductive updating system comprises a resource presetting module, a sandbox management module, a non-inductive updating engine, a protocol adaptation layer and a safety verification module.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mobile terminal software update technology, specifically an offline H5 seamless update method and system based on atomic version switching. Background Technology

[0002] The rise and development of hot update technology is a product of the combination of market demand and technological feasibility, and it has become an indispensable key technology, especially in fields with high-frequency updates, stringent usability requirements, and sensitive distribution costs. At the same time, it also faces key issues such as technological complexity, security challenges, and platform policy compliance.

[0003] The Chinese patent application (CN201811478816.X) discloses a method and apparatus for updating and processing pages. The method includes: during compilation of local code based on a target project, using a isomorphic compilation plugin to perform isomorphic compilation conversion of the local code using the cross-platform mobile application development framework React Native (RN) to obtain an RN executable file; storing the RN executable file in an offline file containing the target project's local offline resource files; and updating the local business page based on the RN executable file in the offline file and the local offline resource files, enabling direct invocation of original client components within existing H5 business logic, thereby improving user experience.

[0004] In the field of mobile terminal software update technology, although there are existing solutions that utilize isomorphic compilation plugins to perform isomorphic compilation conversion of React Native (RN), directly calling RN executable files in offline files for page rendering, and enabling existing H5 services to directly call the original client components, in the scenario of power grid inspection micro-applications, since the work is usually carried out in a weak network environment, the micro-application is often offline, and the background silent updates of front-end resources and configurations cannot interrupt the work process. Therefore, existing technologies still have the following technical defects and shortcomings:

[0005] 1. The native hot update method has the risk of compatibility failure on different ROMs, and class loading solutions are often limited by the platform, making it difficult to implement stably on a large scale.

[0006] 2. Existing solutions rely on online fetching, which is slow and unstable in weak network environments. They also lack unified management of access control, which can easily lead to problems such as path privilege escalation and chaotic cross-domain configurations.

[0007] Therefore, there is a need for an offline H5 seamless update method and system based on atomic version switching in the scenario of power grid inspection micro-application. Summary of the Invention

[0008] This invention provides an offline H5 seamless update method and system based on atomic version switching, aiming to solve the problems of compatibility risks and platform limitations, as well as the lack of unified management of access control in existing update methods.

[0009] The technical solution adopted by this invention to solve the above-mentioned technical problems is: an offline H5 seamless update method based on atomic version switching, comprising:

[0010] Package and compress H5 resources, place them in the rawfile resource directory of the HarmonyOS application, compile them to HAP and upload them to the plugin management platform, call the system interface to obtain the application's writable sandbox path, and use it to decompress and store resources for various offline versions;

[0011] Compare the version number obtained from the server with the version number in the writable sandbox path of the local application. If the version numbers match, continue to use the local resources. If they do not match, download the offline resource package to the sandbox directory via HTTPS protocol, check the file integrity, calculate the MD5 value of the offline resources block by block, and compare it with the server.

[0012] Create a target version isolation directory and a temporary directory, decompress the offline resource package, write it to the sandbox directory in chunks by first creating temporary files and then atomically placing them, traverse the directory to confirm the entry file, construct symbolic links pointing to the new target version isolation directory, replace the original symbolic links with the atomic renaming semantics of the HarmonyOS operating system, and remove write permissions from the old version isolation directory.

[0013] An offline resource management structure is established under the application sandbox path. Updates are determined based on network policies and canary release rules. For updates that need to be made, the target package is downloaded and verified in the background. After the update, the abnormal indicators of the system are evaluated and compared with the preset threshold to determine whether to roll back the version.

[0014] As a preferred implementation, the specific steps for packaging and integrating H5 resources and initializing the runtime environment are as follows: compress the front-end H5 resources into a single package in zip format according to the original relative path, keep the directory hierarchy of each file unchanged, place the compressed package in the rawfile resource directory of the HarmonyOS application, compile and package it into HAP along with the application, and upload the compressed package to the plugin management platform, so that the server can generate verification information for the package.

[0015] In ArkTS UI, instantiate a Web component, obtain the application's writable sandbox path through the system interface, and establish an offline resource root directory using this path as the landing point for each version of the resource. When the client starts, send a request to the server to obtain the current offline package version number and verification value.

[0016] Associate a dedicated Web controller with the corresponding Web component to issue page loading commands, receive lifecycle events and exception callbacks at runtime. Then, create and bind a Web security controller, and pre-define the local offline resource directory accessed by the component by adding a whitelist. At the same time, only files on the file path in the local storage device are allowed to be accessed, and no network requests or mixed content loading are allowed, so that the page can be loaded from the local machine and is available in offline mode. Set the Web component to full width and full height mode so that the H5 page can adapt to the terminal screen and be presented in the same layout layer as the native UI.

[0017] As a preferred implementation, the specific steps for obtaining the compressed package version comparison and calculating MD5 verification security are as follows: read the stored local version identifier file from the root directory established in the application writable sandbox path, obtain the latest offline package version number and corresponding integrity verification information from the server, compare the local version number with the version number obtained from the server, if the two versions are the same, there is no need to download an update and continue to use the local resources, if the two versions are different, download the latest offline compressed package from the server to the offline resource directory under the sandbox through the HTTPS protocol, check the file integrity after the download is completed, call the message digest algorithm interface provided by the system, calculate the MD5 value of the offline package file block by block, and compare it with the returned MD5 value from the server;

[0018] The downloaded offline compressed file is read sequentially in fixed-size blocks, and each block is iteratively processed using the MD5 hash algorithm. The initial chain value is set to a constant. The chain value of each block is calculated using the following formula:

[0019] ,

[0020] Where i represents the index of each block, This represents the MD5 compression function. This represents the intermediate chain value of the i-th block. This represents the i-th data block;

[0021] After processing all data blocks, the final chain value is output as the MD5 digest value of the entire packet, i.e. Where n represents the total number of data blocks and MD5 represents the digest value, the MD5 digest values ​​of the local machine and the server are compared. If they are the same, the package body is complete and trustworthy, and subsequent decompression and switching are allowed. If they are different, it is considered that the verification has failed, the update is stopped and the old version is rolled back, and the built-in page is loaded to prompt the user.

[0022] As a preferred implementation, the specific steps of decompressing the files into the sandbox directory and switching versions atomically are as follows: create a target version isolation directory and a temporary working directory under the application's writable sandbox root path; open the offline package that has passed MD5 verification using a streaming decompressor interface; read the file table inside the package and obtain the total number of bytes in the compressed package and the metadata of each entry; start the decompression task in an independent working thread; allocate a reasonable buffer size; read data blocks from the compressed package stream in a loop and send them to the decompressor; for each decompressed file entry, adopt a strategy of writing to a temporary file first and then atomically placing the decompressed data into the temporary file in blocks; compare the MD5 digest value to verify the integrity of a single file; traverse the target version isolation directory and confirm that the entry file and the predefined resource files exist and are readable;

[0023] Construct symbolic links containing only target path references under the sandbox root path, pointing to the newly created and verified target version isolation directory. Use the atomic renaming semantics provided by the HarmonyOS operating system to replace the existing symbolic links with symbolic links pointing to the new version. After the replacement is completed, perform permission adjustment on the old version directory pointed to by the previous symbolic links, remove write permissions from the old version directory and set it to read-only permissions, while retaining write permissions for the new version directory before replacement for deployment.

[0024] As a preferred implementation, the specific steps for establishing the caching and update mechanism and setting the exception handling strategy are as follows: an offline H5 resource management structure is established under the application writable sandbox path, and offline loading, caching and seamless updates are implemented according to the closed-loop strategy. The latest version metadata is requested from the server periodically. When it is determined that an update is needed and the network policy is met, the target package is downloaded in the background and written to a temporary directory. After the download is completed, the integrity and trustworthiness of the target package are verified. Preparation work is completed in the background, but the atomic replacement is delayed until the conditions of job idleness and user-acceptable time are met, so as to minimize the impact on the business logic being executed. After the update, the system observes the new version's running indicators and evaluates the abnormal indicators by comparing them with the pre-set threshold.

[0025] Key performance indicators (KPIs) are prioritized and ranked, including page load success rate, first-screen interaction time, white screen rate, and crash rate. Corresponding weights are assigned, and hourly observations of each KPI are collected and mapped to a range of 0 to 1. Anomaly scores are then calculated using the following formula:

[0026] ,

[0027] Where Q represents the overall anomaly score, S represents the set of key operational indicators, and k represents the element in the set. This indicates the weight of the k-index. This represents the mapping value of the k-index;

[0028] Set a comprehensive anomaly score threshold, and perform a reverse atomic replacement operation on those scores below the threshold to achieve instantaneous version rollback in a zero-interruption manner.

[0029] To achieve the same inventive objective as the above-mentioned technical solutions, the present invention also provides an offline H5 seamless update system based on atomic version switching, including: a resource pre-configuration module, a sandbox management module, a seamless update engine, a protocol adaptation layer, and a security verification module.

[0030] As a preferred implementation, the specific steps of the offline H5 seamless update system based on atomic version switching are as follows: The resource pre-configuration module is used to import the pre-configured offline H5 resources into the application writable sandbox during the initial startup phase. First, it reads the local version record to determine whether a valid version exists. Then, it locates the pre-configured package through the system resource management interface and reads it in a streaming interface manner. It performs package-level digest calculation and compares it with the verification value of the manifest record. It verifies the signature and package-level integrity in a trusted execution environment and decompresses it to the target version isolation directory in a block manner.

[0031] The sandbox management module is used to provide a versioned resource landing environment and runtime access boundary within the terminal application sandbox. It obtains the application's writable sandbox root path through the system interface, creates and maintains the namespace, and prioritizes cleaning up old versions when available space is insufficient. When available space is sufficient, it creates the target version isolation directory and the corresponding temporary working directory. It provides a block write interface to receive incoming files, writes data in blocks to temporary files, and performs system synchronization. After synchronization, it replaces the temporary files with the target file name in an atomic renaming manner.

[0032] The seamless update engine is responsible for version detection decisions, update process orchestration, switching timing determination, observation and rollback decisions, calling interfaces to perform end-to-end update transactions, listening to trigger events to read server metadata, judging update conditions according to canary rules and network policies, and calling the atomic switching interface of the sandbox management module to switch if the update conditions are met.

[0033] The protocol adaptation layer is responsible for network interaction with the server, download management, breakpoint resumption, and bandwidth control. It pulls the version manifest and differential information from the server, parses it and returns it to the seamless update engine. According to the transmission policy, it creates download tasks and records task metadata. When there is a network transmission error, it executes the backoff and retry policy and reports it. After the download is completed, it notifies the seamless update engine to enter the verification. It dynamically adjusts the number of concurrent connections and the rate according to the configuration.

[0034] The security verification module is used to verify the trustworthiness of offline packages and their internal files, perform path security checks and permission verifications. It receives requests before the sandbox is ready, calculates the digest of the temporary package, compares it with the digest sent by the server, and after the sandbox management module completes the single file placement, it traverses the target files by manifest to perform hash comparisons, performs additional loadability tests on the entry file and key resources, normalizes each path entry and checks whether it exceeds the target directory.

[0035] The beneficial effects of this invention are as follows:

[0036] 1. This invention encapsulates H5 resources and Web runtime components within a sandbox, reducing the risk of crashes due to platform implementation differences and minimizing incompatibility with different ROMs and different vendors' implementations by not relying on class loading and native hot-plugging mechanisms that differ significantly across platforms.

[0037] 2. This invention constructs symbolic links containing only target path references through atomic version switching, so that there are only two cases of resource references at runtime: new and old, reducing the occurrence of white screens and exceptions caused by semi-updates.

[0038] Legend

[0039] Figure 1 This is a flowchart of an offline H5 seamless update method based on atomic version switching;

[0040] Figure 2 This is a module diagram of an offline H5 seamless update system based on atomic version switching;

[0041] Figure 3 This is a comparison chart of the offline H5 seamless update method and system effects based on atomic version switching. Detailed Implementation

[0042] To make the technical means, creative features, objectives, and effects of this invention easier to understand, the invention is further described below with reference to specific embodiments. However, the following embodiments are merely preferred embodiments of this invention and not all of them. Other embodiments obtained by those skilled in the art based on the embodiments described herein without creative effort are all within the protection scope of this invention.

[0043] Example 1, such as Figure 1 This is an offline, seamless H5 update method based on atomic version switching, which includes the following steps:

[0044] Package and integrate H5 resources, and initialize the runtime environment;

[0045] Obtain the compressed package for comparison and calculate the MD5 checksum for security.

[0046] Extract the files to the sandbox directory in chunks and switch versions atomically.

[0047] Establish a caching and update mechanism, and set up an exception handling strategy.

[0048] The following are the specific implementation steps: An offline H5 seamless update method based on atomic version switching, wherein the specific steps for packaging and integrating H5 resources and initializing the runtime environment are as follows:

[0049] Front-end H5 resources, such as HTML pages and CSS files, are compressed into a single zip package using their original relative paths, keeping the directory hierarchy of each file unchanged. The compressed package is placed in the rawfile resource directory of the HarmonyOS application and compiled and packaged into the HarmonyOS Ability Package (HAP) along with the application. At the same time, the compressed package is uploaded to the plugin management platform, and the server generates verification information such as MD5 for the package.

[0050] In ArkTS UI, instantiate web components and configure basic properties such as width, height, and ID. ArkTS is an integrated language based on TypeScript and designed for HarmonyOS client applications. It obtains the application's writable sandbox path through the system interface and establishes an offline resource root directory using this path as the landing point for each version of the resource. When the client starts, it sends a request to the server to obtain the current offline package version number and verification value.

[0051] Specifically, the instantiation of the Web component and configuration of its basic properties first involves associating a dedicated Web controller with the corresponding Web component to issue page loading commands, receive lifecycle events, and handle exception callbacks at runtime. Then, a Web security controller is created and bound, and the local offline resource directory accessed by the component is pre-defined by adding a whitelist. At the same time, access to files on the file path in the local storage device is only allowed, and no network requests or mixed content loading are allowed, so that the page can be loaded from the local storage and is available in offline mode. The Web component is then set to full-width and full-height mode so that the H5 page can adapt to the terminal screen and be presented in the same layout layer as the native UI.

[0052] The specific steps for obtaining the compressed file for comparison and calculating MD5 verification security are as follows:

[0053] The system reads the local version identifier file stored in the root directory created in the application's writable sandbox path, obtains the version number of the latest offline package and the corresponding integrity verification information such as MD5 from the server, compares the local version number with the version number obtained from the server, if the two versions are the same, no update is needed and the local resources can continue to be used, if the two versions are different, the system downloads the latest offline compressed package from the server to the offline resource directory under the sandbox via HTTPS protocol, checks the file integrity after the download is completed, calls the message digest algorithm interface provided by the system to calculate the MD5 value of the offline package file block by block, and compares it with the MD5 value returned to the server;

[0054] Specifically, the process of calculating the MD5 value block by block for the offline package file involves reading the downloaded offline compressed package file sequentially in blocks of fixed size, such as 4KB, and iteratively processing each block using the MD5 digest algorithm, with the initial chain value set to a constant. The chain value of each block is calculated using the following formula:

[0055] ,

[0056] Where i represents the index of each block, This represents the MD5 compression function. This represents the intermediate chain value of the i-th block. This represents the i-th data block;

[0057] After processing all data blocks, the final chain value is output as the MD5 digest value of the entire packet, i.e. Where n represents the total number of data blocks and MD5 represents the digest value, the MD5 digest values ​​of the local machine and the server are compared. If they are the same, the package body is complete and trustworthy, and subsequent decompression and switching are allowed. If they are different, it is considered that the verification has failed, the update is stopped and the old version is rolled back, and the built-in page is loaded to prompt the user.

[0058] The specific steps for decompressing the files into chunks to the sandbox directory and switching versions atomically are as follows:

[0059] Create a target version isolation directory and a temporary working directory under the application's writable sandbox root path. The temporary working directory is specifically used to write temporary files and intermediate state records. Use a streaming decompressor interface to open the offline package that has passed MD5 verification, read the file table inside the package such as the manifest, and obtain the total number of bytes in the compressed package, as well as the path and compressed length of each entry and other metadata. Start the decompression task in an independent worker thread, allocate a reasonable buffer size such as 16KB, and read data blocks from the compressed package stream in a loop and send them to the decompressor. For each decompressed file entry, adopt the strategy of writing to a temporary file first and then atomically placing it, and append the decompressed data to the temporary file in blocks. Compare the MD5 digest value to verify the integrity of a single file. Traverse the target version isolation directory and confirm that the entry file and predefined resource files such as the manifest and main.js file exist and are readable.

[0060] Construct symbolic links containing only the target path reference under the sandbox root path, pointing to the newly created and verified target version isolation directory. Use the atomic renaming semantics provided by the HarmonyOS operating system to replace the existing symbolic links with symbolic links pointing to the new version. After the replacement is completed, perform permission adjustment on the old version directory pointed to by the previous symbolic links, remove the write permissions of the old version directory and set it to read-only permissions, while retaining the write permissions of the new version directory before replacement for deployment.

[0061] The specific steps for establishing a caching and update mechanism and setting an exception handling strategy are as follows:

[0062] An offline H5 resource management structure is established under the writable sandbox path of the application. Offline loading, caching and seamless updates are implemented according to the closed-loop strategy. The latest version of metadata is requested from the server periodically. When it is determined that an update is needed and the network policy such as Wi-Fi conditions are met, the target package is downloaded in the background and written to a temporary directory. After the download is completed, the integrity and trustworthiness of the target package are verified. The preparation work is completed in the background but the atomic replacement is delayed until the conditions of job idleness and user-acceptable time are met, such as the current inspection task is completed, so as to minimize the impact on the business logic being executed. After the update, the system observes the new version's running indicators and evaluates the abnormal indicators by comparing them with the pre-set thresholds.

[0063] Specifically, the evaluation of abnormal indicators is compared with pre-set thresholds, and key operational indicators are prioritized and sorted, including page load success rate, first-screen interaction time, blank screen rate, and crash rate, with corresponding weights assigned. For example, page load success rate is 0.4, first-screen interaction time is 0.3, blank screen rate is 0.2, and crash rate is 0.1. Observations for each indicator are collected hourly and mapped to a range of 0 to 1, where a value close to 1 indicates a good indicator, and a value close to 0 indicates a poor indicator. An abnormal score is calculated based on the following formula:

[0064] ,

[0065] Where Q represents the overall anomaly score, S represents the set of key operational indicators, and k represents the element in the set. This indicates the weight of the k-index. This represents the mapping value of the k-index;

[0066] The overall anomaly score threshold is set at 0.95. For scores below the threshold, a reverse atomic replacement operation is performed to achieve instantaneous version rollback in a zero-interruption manner.

[0067] Example 2, as Figure 1 This is an offline H5 seamless update system based on atomic version switching, including a resource pre-configuration module, a sandbox management module, a seamless update engine, a protocol adaptation layer, and a security verification module. The specific implementation steps are as follows:

[0068] The resource pre-configuration module is used to import pre-configured offline H5 resources into the application writable sandbox during the initial startup phase. First, it reads the local version record to determine if a valid version exists. Then, it locates the pre-configured package through the system resource management interface and reads it in a streaming interface. It performs package-level digest calculation and compares it with the verification value of the manifest record. It verifies the signature and package-level integrity in a trusted execution environment and decompresses it to the target version isolation directory in a block manner.

[0069] The sandbox management module is used to provide a versioned resource landing environment and runtime access boundary within the terminal application sandbox. It obtains the application's writable sandbox root path through the system interface, creates and maintains the namespace, and prioritizes cleaning up old versions when available space is insufficient. When available space is sufficient, it creates the target version isolation directory and the corresponding temporary working directory. It provides a block write interface to receive incoming files, writes data in blocks to temporary files, and performs system synchronization. After synchronization, it replaces the temporary files with the target file name in an atomic renaming manner.

[0070] The seamless update engine is responsible for version detection decisions, update process orchestration, switching timing determination, observation and rollback decisions, and calls the interface to perform end-to-end update transactions. It reads server metadata by listening to trigger events such as system screen opening, and judges update conditions according to gray-scale rules and network policies. For example, if it is in a wireless LAN environment and the HarmonyOS version is the latest, it calls the atomic switching interface of the sandbox management module to switch if the update conditions are met.

[0071] The protocol adaptation layer is responsible for network interaction with the server, download management, breakpoint resumption, and bandwidth control. It pulls the version manifest and differential information from the server, parses it and returns it to the seamless update engine. According to the transmission policy, it creates download tasks and records task metadata. When there is a network transmission error, it executes the backoff and retry policy and reports it. After the download is completed, it notifies the seamless update engine to enter the verification. It dynamically adjusts the number of concurrent connections and the rate according to the configuration.

[0072] The security verification module is used to verify the trustworthiness of offline packages and their internal files, perform path security checks and permission verifications. It receives requests before the sandbox is ready, calculates the digest of the temporary package, compares it with the digest sent by the server, and after the sandbox management module completes the single file placement, it traverses the target files by manifest to perform hash comparisons, performs additional loadability tests on the entry file and key resources, normalizes each path entry and checks whether it exceeds the target directory.

[0073] The embodiments of the present invention described above are subject to modification and change of method by those skilled in the art without departing from the embodiments and broader aspects of the present invention. The appended claims are intended to include all such modifications and changes of method that do not depart from the present invention.

Claims

1. An offline H5 in-sensitive update method based on atomic version switching, characterized in that, The application comprises: Packaging and compressing H5 resources, placing them in the rawfile resource directory of the Hongmeng application, compiling them into HAP and uploading them to the plug-in management platform, calling the system interface to obtain the application writable sandbox path, and using it to decompress and store each offline version resource; Comparing the version number in the local application writable sandbox path and the version number obtained from the server, if the version numbers are consistent, the local resources are continued to be used, if the version numbers are inconsistent, the offline resource package is downloaded to the sandbox directory through the HTTPS protocol, the file integrity is checked, the MD5 value of the offline resource is calculated block by block, and the MD5 value is compared with the server; Creating a target version isolation directory and a temporary directory, decompressing the offline resource package, writing the offline resource package into the sandbox directory through a temporary file and then atomically placing it, traversing the directory to confirm the entry file, constructing a symbolic link pointing to the new target version isolation directory, replacing the original symbolic connection through the atomic renaming semantics of the Hongmeng operating system, and removing the write permission of the old version isolation directory; Establishing an offline resource management structure under the application sandbox path, determining the update according to the network strategy and the gray rule, downloading the target package in the background and performing verification for the offline resource package that needs to be updated, evaluating the system abnormal index after updating, and comparing the preset threshold to determine whether to roll back the version.

2. The off-line H5 in-sensitive update method based on atomic version switching according to claim 1, characterized in that: The specific steps of packaging and integrating H5 resources and initializing the runtime environment are: Compressing the front-end H5 resources into a single zip format package according to the original relative path, keeping the directory level of each file unchanged, placing the compressed package in the rawfile resource directory of the Hongmeng application, packaging it into HAP together with the application, and uploading the compressed package to the plug-in management platform, and the server generates verification information for the package; Instantiating the Web component in ArkTS UI, obtaining the application writable sandbox path through the system interface, and establishing the offline resource root directory as the landing place of each version resource, sending a request to the server to obtain the current offline package version number and verification value when the client starts.

3. The off-line H5 in-sensitive update method based on atomic version switching according to claim 2, characterized in that: The specific steps of packaging and integrating H5 resources and initializing the runtime environment further comprise: Associating a dedicated Web controller with the corresponding Web component to issue page loading commands, receive lifecycle events and exception callbacks at runtime, then creating and binding a Web security controller, pre-setting the local offline resource directory accessed by the component through adding a whitelist, and only allowing access to the files in the file path of the local storage device, not allowing any network request or mixed content loading, so that the page can be loaded locally and used in offline state, setting the Web component to full-width and full-height mode, making the H5 page adaptive to the terminal screen, and rendering it in the same layout level as the native UI.

4. The off-line H5 in-sensitive update method based on atomic version switching according to claim 1, characterized in that: The specific steps of obtaining the compressed package and comparing the version to calculate the MD5 verification security are: The local version identification file stored under the root directory established from the application writable sandbox path is read, the version number and corresponding integrity check information of the latest offline package are obtained from the server, the local version number is compared with the version number obtained from the server, when the versions are consistent, no update is needed, and the local resource is continued to be used, when the versions are inconsistent, the latest offline compressed package on the server is downloaded to the offline resource directory under the sandbox through the HTTPS protocol, and after the downloading is completed, the file integrity is checked, the message digest algorithm interface provided by the system is called, the MD5 value is calculated for the offline package file block by block, and the MD5 value is compared with the returned server MD5 value.

5. The off-line H5 cold update method based on atomic version switching according to claim 4, characterized in that: The specific steps of the method for obtaining the compressed package comparison version and calculating the MD5 check security further include: The downloaded offline compressed package file is read in fixed size blocks, and each block is processed iteratively using MD5 digest algorithm, and the initial chain value is set as a constant The chain value of each block is calculated, and the formula is: , where i denotes the index of each block, denotes the MD5 compression function, denotes the intermediate chain value of the i-th block, denotes the i-th data block; After all the data blocks are processed, the final chain value is output as the MD5 digest value of the entire package, that is where n represents the total number of data blocks, MD5 represents the digest value, and the MD5 digest values of the local and server are compared. If they are the same, the package body is complete and reliable, and subsequent decompression and switching are allowed. If they are not the same, the check fails, the update is aborted, and the old version is rolled back, and a built-in page is loaded to prompt the user.

6. The off-line H5 cold update method based on atomic version switching according to claim 1, characterized in that: The specific steps of the method for decompressing to the sandbox directory and switching the version atomically further include: A target version isolation directory and a temporary working directory are created under the application writable sandbox root path, an MD5 check passed offline package is opened by using a streaming decompressor interface, a file table in the package is read, and the total number of bytes of the compressed package and the meta information of each entry are obtained, a decompression task is started in an independent working thread, a reasonable buffer size is divided, data blocks are read from the compressed package stream in a loop and sent to the decompressor, for each file entry decompressed, a strategy of writing a temporary file first and then atomically placing is adopted, decompressed data is block-appended to the temporary file, and the MD5 digest value is compared to check the integrity of a single file, the target version isolation directory is traversed and the entry file is confirmed, and it is confirmed that the pre-defined resource file exists and is readable.

7. The off-line H5 cold update method based on atomic version switching according to claim 6, characterized in that: The specific steps of the method for decompressing to the sandbox directory and switching the version atomically further include: A symbolic link containing only a target path reference is constructed under the sandbox root path, and the symbolic link points to a newly created and check passed target version isolation directory, an existing symbolic link is replaced with a symbolic link pointing to a new version by using an atomic renaming semantic provided by the Hongmeng operating system, after the replacement is completed, the write permission of an old version directory pointed to by the previous symbolic link is removed and is set to a read-only permission, and the write permission of the new version directory before the replacement is retained to be used for deployment.

8. The off-line H5 cold update method based on atomic version switching according to claim 1, characterized in that: The specific steps of the method for establishing a cache and update mechanism and setting an exception handling strategy further include: An offline H5 resource management structure is established under the application writable sandbox path, offline loading, caching and no-sense updating are implemented according to a closed loop strategy, the latest version metadata is periodically requested from the server, when it is determined that updating is needed and the network strategy is met, a target package is downloaded and written into a temporary directory in the background, after the downloading is completed, the target package is checked for integrity and credibility, the atomic replacement is performed in the background after the preparation work is completed but is delayed, until the conditions of job idle and user acceptable time are met, so that the influence on the business logic being executed is minimized, after the updating, the new version running index is observed by the system, and the abnormal index is evaluated by comparing with a pre-set threshold.

9. The off-line H5 in-sensitive update method based on atomic version switching according to claim 8, characterized in that: The specific steps of the method for establishing a cache and update mechanism and setting an exception handling strategy further include: The key performance indicators are sorted according to priorities, including page loading success rate, first screen interaction time, white screen rate, crash rate, and corresponding weights are assigned, observation values of each indicator are collected every hour, and are mapped to the interval of 0 to 1, and the abnormal score is calculated comprehensively, and the formula is: , wherein Q represents a composite abnormality score, S represents a set of key operational indicators, k represents an element of the set, represents a weight of the k indicator, represents a mapped value of the k indicator; The comprehensive abnormal score threshold is set, and the reverse atomic replacement operation is performed on the low threshold to realize the instantaneous version rollback in the form of zero interruption.

10. An offline H5 in-sensitive update system based on atomic version switching, the offline H5 in-sensitive update method based on any one of claims 1-9, characterized in that, The method comprises the following steps: The resource preset module is used for importing preset offline H5 resources into the application writable sandbox in the first starting stage, first reading the local version record to determine whether there is a valid version, positioning the preset package through the system resource management interface and reading in the form of a streaming interface, performing package-level summary calculation, comparing with the verification value recorded in the manifest, verifying the signature and package-level integrity in the trusted execution environment, and decompressing in the form of blocks to the target version isolation directory; The sandbox management module is used for providing a versioned resource landing environment and a runtime access boundary in the terminal application sandbox, obtaining the application writable sandbox root path through the system interface, creating and maintaining the namespace, estimating the target directory and the available space, preferentially cleaning the old version when the available space is insufficient, creating the target version isolation directory and the corresponding temporary working directory when the available space is sufficient, providing a block writing interface to receive the incoming file, and simultaneously writing the data into the temporary file and performing system synchronization, and replacing the temporary file with the target file name in the form of atomic renaming after the synchronization is completed; The non-sensing update engine is used for being responsible for version detection decision, update process arrangement, switching time determination, observation and rollback decision, calling the interface to perform end-to-end update transaction, reading the server metadata by listening to the trigger event, judging the update condition according to the gray rule and the network strategy, calling the atomic switching interface of the sandbox management module to perform switching on the condition that the update condition is met; The protocol adaptation layer is used for being responsible for network interaction with the server, download management, breakpoint resume, bandwidth control, pulling the version manifest and differential information from the server, returning to the non-sensing update engine by analysis, establishing a download task and recording task metadata according to the transmission strategy, performing a backoff retry strategy and reporting when a transmission error occurs, notifying the non-sensing update engine to enter verification after the download is completed, and dynamically adjusting the number of concurrent connections and the rate according to the configuration; The security verification module is used for verifying the credibility of the offline package and the internal files, path safety detection and permission verification, receiving the request before the sandbox is ready, calculating the digest of the temporary package, comparing with the one sent by the server, performing hash comparison on the target files according to the manifest after the single file is positioned by the sandbox management module, and performing additional loadability test on the entry file and the key resources, normalizing each entry path and checking whether it exceeds the target directory.

Citation Information

Patent Citations

  • Page updating method and device and page processing method and device

    CN109857403A

Cited By

  • Implementation method for high-performance routing analysis and dynamic optimization in React framework

    CN121935446A

  • Implementation method of high-performance route resolution and dynamic optimization in React framework

    CN121935446B