System upgrading method, terminal and storage medium
Patent Information
- Application Number
- CN202611098127.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-13
AI Technical Summary
该方式存在以下缺陷:一方面,升级包下载过程高度依赖网络环境,若网络波动导致下载中断,极易造成升级包损坏或下载失败;另一方面,升级包下载至本地后还需进行解压,解压过程也需要占用额外的存储空间,当终端剩余存储空间不足时,解压极易失败,导致升级无法完成
[0018]本申请提出的一个或多个技术方案,至少具有以下技术效果:通过将升级数据包预先封装于系统升级应用中,在接收到系统升级请求时,由所述系统升级应用将提前封装于应用自身的升级数据包流式写入终端的预设缓存区,并发起升级命令;终端在接收到应用发起的升级命令时,基于升级命令直接调用缓存分区中的升级数据包执行系统升级;本申请通过将升级数据包封装于独立的系统升级应用中,用户仅需在终端安装并运行该应用即可触发系统升级,无需依赖PC及任何外部工具,也无需手动输入任何命令行指令,降低了操作难度,避免了因误操作导致的系统升级失败。同时基于系统升级应用即可将升级数据包写入预设缓存区,升级全程无需联网,防止网络波动对升级过程的影响;另外,基于将升级数据包采用流式写入方式直接写入终端的预设缓存分区,无需在终端额外存储完整的中间文件,避免了因存储空间不足而导致的升级失败。由此可见,本申请以系统升级应用为载体,实现了无需PC、无需联网、不依赖底层OTA服务、不占用存储空间的便捷升级,提高了升级操作的便捷性与升级的可靠性。
Smart Images

Figure CN122903018A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to system upgrade methods, terminals and storage media. Background Technology
[0002] As the system version is continuously updated, the terminal software version generally also needs to be updated accordingly to meet user needs and improve user experience.
[0003] For demonstration devices and after-sales service devices that require frequent flashing of specific operating system versions, traditional system upgrade methods typically require operators to connect the terminal to a computer (PC) via USB cable, install a dedicated flashing tool (such as Fastboot), and manually enter complex command-line instructions to complete the flashing process. This method demands a high level of technical skill from the operator, is cumbersome, and is highly susceptible to errors that could lead to flashing failures or even bricking the device. For OTA (Over-The-Air) upgrades aimed at ordinary consumers, the traditional method involves configuring the OTA environment and connecting to the network; downloading the upgrade package from the OTA server to the local machine; then decompressing it locally to generate a complete upgrade file; and finally rebooting into Recovery mode to complete the system upgrade. This method has the following drawbacks: Firstly, the upgrade package download process is highly dependent on the network environment; if network fluctuations cause download interruptions, the upgrade package is easily corrupted or the download fails. Secondly, the upgrade package needs to be decompressed after downloading, which also requires additional storage space. When the terminal's remaining storage space is insufficient, decompression is prone to failure, preventing the upgrade from completing. The aforementioned defects are particularly prominent in scenarios with limited storage space or weak network signals, severely impacting the user experience.
[0004] Therefore, there is an urgent need for a system upgrade method that is independent of the underlying OTA and does not require PC assistance, so as to achieve convenient and stable upgrades for terminals.
[0005] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The main purpose of this application is to provide a system upgrade method, terminal, and storage medium, which aims to improve the convenience and stability of system upgrades.
[0007] To achieve the above objectives, this application proposes a system upgrade method, applied to a terminal with a system upgrade application installed. The steps of the system upgrade method include: In response to a system upgrade request, the system upgrade application streams upgrade data packets into a preset buffer in the terminal, and the upgrade data packets are pre-encapsulated in the system upgrade application. When an upgrade command initiated by the system upgrade application is detected, the upgrade data packet stored in the preset cache is invoked; The system upgrade operation is performed based on the upgrade data package.
[0008] For example, before the step of the system upgrade application streaming the upgrade data packet into a preset buffer in the terminal in response to the system upgrade request, the method further includes: After installing the system upgrade application, obtain the system signature corresponding to the system upgrade application. The system signature is generated based on the system certificate of the terminal. Perform a signature verification operation on the system signature; After successful signature verification, the system upgrade application is granted preset system permissions, which include the first permission to write the upgrade data packet to the preset cache area and the second permission to initiate an upgrade command.
[0009] For example, the step of the system upgrade application streaming upgrade data packets into a preset buffer in the terminal includes: Obtain the remaining storage space corresponding to the preset cache area and the data volume corresponding to the upgrade data package; When the amount of data is less than or equal to the remaining storage space, the upgrade data packet is streamed into a preset cache area in the terminal.
[0010] For example, the step of streaming the upgrade data packet into a preset buffer in the terminal when the data volume is less than or equal to the remaining storage space includes: The system upgrade application reads the multi-volume files in the upgrade data package sequentially, and the upgrade data package is encapsulated in the system upgrade application in the form of multi-volume files; The split file is streamed into the preset cache area, which is the cache partition in the terminal.
[0011] For example, the step of calling the upgrade data packet stored in the preset cache based on the upgrade command when the upgrade command initiated by the system upgrade application is detected includes: The system upgrade application performs an integrity check on the upgrade data packet written to the preset cache area based on the data volume and / or preset hash value corresponding to the upgrade data packet; When the integrity verification passes, the step of calling the upgrade data packet stored in the preset cache based on the upgrade command is executed when the upgrade command initiated by the system upgrade application is detected.
[0012] For example, the steps of the system upgrade application initiating an upgrade command include: Obtain the storage path of the upgrade data package, generate an upgrade instruction based on the storage path, and write the upgrade instruction into a preset instruction partition; Obtain preset reboot parameters, and call the system reboot interface of the terminal based on the preset reboot parameters to trigger the terminal to reboot and enter Recovery mode.
[0013] For example, the step of invoking the upgrade data packet stored in the preset cache when an upgrade command initiated by the system upgrade application is detected includes: In response to the upgrade command, perform a reboot operation and enter Recovery mode; The upgrade command is read based on the Recovery mode, and the upgrade data packet in the preset cache is obtained according to the upgrade command.
[0014] For example, the upgrade data packet is encapsulated by the server in the system upgrade application, and the server generates a system signature based on the system certificate of the terminal, and performs a signing operation on the system installation application based on the system signature.
[0015] In addition, to achieve the above objectives, this application also proposes a terminal, the terminal comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the system upgrade method as described above.
[0016] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the system upgrade method described above.
[0017] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the system upgrade method described above.
[0018] The one or more technical solutions proposed in this application have at least the following technical effects: By pre-encapsulating the upgrade data packet in a system upgrade application, upon receiving a system upgrade request, the system upgrade application streams the pre-encapsulated upgrade data packet into the terminal's preset cache and initiates an upgrade command; when the terminal receives the upgrade command initiated by the application, it directly calls the upgrade data packet in the cache partition to perform the system upgrade based on the upgrade command; by encapsulating the upgrade data packet in an independent system upgrade application, the user only needs to install and run the application on the terminal to trigger the system upgrade, without relying on a PC or any external tools, and without manually entering any command line instructions, reducing the difficulty of operation and avoiding system upgrade failure due to misoperation. Simultaneously, the upgrade data packet can be written to the preset cache partition based on the system upgrade application, and the entire upgrade process does not require an internet connection, preventing network fluctuations from affecting the upgrade process; furthermore, by using a streaming method to directly write the upgrade data packet to the terminal's preset cache partition, there is no need to store complete intermediate files on the terminal, avoiding upgrade failure due to insufficient storage space. Therefore, this application uses system upgrade applications as a carrier to achieve convenient upgrades without PC, network connection, reliance on underlying OTA services, or storage space, thereby improving the convenience and reliability of upgrade operations. Attached Figure Description
[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating the first embodiment of the system upgrade method of this application. Figure 2 This is a detailed flowchart of step S10 in the first embodiment of the system upgrade method of this application; Figure 3 This is a detailed flowchart of step S12 in the first embodiment of the system upgrade method of this application; Figure 4 This is a detailed flowchart of step S20 in the first embodiment of the system upgrade method of this application; Figure 5 This is a flowchart illustrating the system upgrade method of this application; Figure 6This is a schematic diagram of the device structure of the hardware operating environment involved in the system upgrade method in this application embodiment.
[0022] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0023] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0024] In related technologies, as system versions are continuously updated, terminal software versions generally also need to be updated accordingly to meet user needs and improve user experience. Traditional system upgrade methods include two types. One method involves an operator connecting the terminal to a computer (PC) via USB, installing a dedicated flashing tool (such as Fastboot), and manually entering complex command-line instructions to complete the system upgrade. This method requires a high level of technical skill from the operator, is cumbersome, and is prone to errors that could lead to flashing failure or even bricking the device. The other method involves configuring an OTA environment, connecting to the network, accessing an OTA server, downloading the upgrade package to the local machine, then decompressing it locally to generate a complete upgrade file, and finally rebooting into Recovery mode to complete the system upgrade. This method has the following drawbacks: Firstly, the upgrade package download process is highly dependent on the network environment; if network fluctuations cause download interruptions, the upgrade package is easily corrupted or the download fails. Secondly, after the upgrade package is downloaded locally, it needs to be decompressed, which also requires additional storage space. When the terminal's remaining storage space is insufficient, decompression is prone to failure, preventing the upgrade from completing.
[0025] This application provides a solution that pre-encapsulates upgrade data packets within a system upgrade application. Upon receiving a system upgrade request, the system upgrade application streams the pre-encapsulated upgrade data packets into a preset cache on the terminal and initiates an upgrade command. When the terminal receives the upgrade command, it directly invokes the upgrade data packets in the cache partition to perform the system upgrade. By encapsulating the upgrade data packets within a separate system upgrade application, users only need to install and run the application on the terminal to trigger the system upgrade, without relying on a PC or any external tools, and without manually entering any command-line instructions, thus reducing operational difficulty and avoiding system upgrade failures due to misoperation. Furthermore, since the upgrade data packets can be written to the preset cache partition directly through the system upgrade application, the entire upgrade process does not require an internet connection, preventing network fluctuations from affecting the upgrade process. Additionally, by using a streaming method to directly write the upgrade data packets to the terminal's preset cache partition, there is no need to allocate additional storage space on the terminal to store the upgrade package and its decompressed files, avoiding upgrade failures due to insufficient storage space. Therefore, this application uses system upgrade applications as a carrier to achieve convenient upgrades without PC, network connection, reliance on underlying OTA services, or storage space, thereby improving the convenience and reliability of upgrade operations.
[0026] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0027] Reference Figure 1 This application provides a system upgrade method, applied to a terminal with a system upgrade application installed, the system upgrade method comprising steps S10 to S30: Step S10: In response to the system upgrade request, the system upgrade application streams the upgrade data packet into a preset buffer in the terminal. The upgrade data packet is pre-encapsulated in the system upgrade application. Step S20: When an upgrade command initiated by the system upgrade application is detected, the upgrade data packet stored in the preset cache is invoked; Step S30: Perform a system upgrade operation based on the upgrade data packet.
[0028] In this application embodiment, it is applied to a terminal. By way of example and not limitation, the terminal may be, but is not limited to, tablet computers, desktop computers, laptop computers, handheld computers, laptops, in-vehicle devices, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), mobile phones, smartwatches, etc., and this application embodiment does not limit it.
[0029] Optionally, the terminal has a system upgrade application installed. The system upgrade application pre-packages an upgrade data package for upgrading the terminal's operating system. The upgrade data package is a collection of data used to update the terminal's operating system. The upgrade data package includes, but is not limited to, image files, upgrade scripts, etc. required for system upgrade. It should be noted that the upgrade data package is written into the application installation package (Android APK) of the system upgrade application by the server during the development stage, thereby realizing the encapsulation of the upgrade data package in the system upgrade application.
[0030] In one embodiment, during the research and development or release phase, the server encrypts the compiled upgrade data package using a preset encryption algorithm (such as update.zip or payload.bin). The preset encryption algorithm includes, but is not limited to, AES encryption, RSA encryption, SM4 encryption, etc. After encryption, the encrypted upgrade data package is divided into multiple split files with a preset data size. Subsequently, these split files are placed in the assets directory corresponding to the system upgrade application.
[0031] It's important to note that when using a system upgrade application as a vehicle for system upgrades, the application needs system-level permissions to write data to the terminal's preset cache and initiate upgrade commands. However, under the terminal's permission management mechanism, ordinary applications do not possess these system-level operation permissions; only applications carrying a system signature can be granted preset system permissions. This system signature corresponds one-to-one with the terminal's operating system's system certificate. Therefore, it is necessary to generate a corresponding system signature for the system upgrade application in advance, enabling the terminal to grant the corresponding preset system permissions to the application based on this signature.
[0032] In an optional implementation, prior to step S10, the method further includes: After installing the system upgrade application, obtain the system signature corresponding to the system upgrade application. The system signature is generated based on the system certificate of the terminal. Perform a signature verification operation on the system signature; After successful signature verification, the system upgrade application is granted preset system permissions, which include the first permission to write the upgrade data packet to the preset cache area and the second permission to initiate an upgrade command.
[0033] Specifically, the server uses the same system certificate as the terminal's operating system to perform system-level signing on the application installation package of the system upgrade application, generating a system signature corresponding to the system upgrade application. The system upgrade application is then generated based on the system signature and the application installation package. After system-level signing, when the system upgrade application installation package is installed on the terminal, the terminal performs a signature verification operation on the system upgrade application based on the system signature. Upon successful signature verification, the terminal grants the system upgrade application preset system permissions. These preset system permissions include a first permission to write data to a preset cache and a second permission to initiate upgrade commands. After granting these preset system permissions, the system upgrade application can perform streaming write operations of upgrade data packets and initiate upgrade commands based on these permissions.
[0034] Alternatively, the system upgrade application can be installed by the user downloading it locally via a browser or app store, or by transferring the application to the terminal requiring the upgrade via Wi-Fi or BitTorrent, and then completing the installation; or by installing the system upgrade application to a demonstration machine or other terminal via USB flash drive or internal network.
[0035] In one embodiment, a system upgrade request is used to instruct the terminal to obtain an upgrade data packet and perform a system upgrade operation based on the upgrade data packet.
[0036] The system upgrade request can be initiated by the user. Specifically, the user opens the system upgrade application, and the application displays an upgrade operation entry point on the application interface. The user then initiates the system upgrade request by clicking on the upgrade operation entry point. Alternatively, the system upgrade request can be triggered by the user opening the upgrade operation entry point on their terminal.
[0037] In another embodiment, the system upgrade request can be initiated automatically by the terminal. Specifically, the terminal automatically initiates a system upgrade request according to a preset period or when preset triggering conditions are met. Specifically, the terminal periodically checks whether the current system version is consistent with the latest system version released by the server; when a new system version is detected, a system upgrade request is triggered. When a new system version is detected, the terminal checks whether the current device environment meets preset upgrade conditions. The preset upgrade conditions include, but are not limited to, the terminal's current battery level being greater than or equal to a preset battery threshold (e.g., 50%), the available storage space in the terminal's preset cache being greater than or equal to the data size of the upgrade data packet to be upgraded, and whether the current time is within a target time period that will not interfere with the user's use of the terminal, such as 12:00 AM to 3:00 AM. When it is determined that the terminal meets the preset upgrade conditions, the terminal automatically triggers the system upgrade request, triggering the system upgrade application to respond to the system upgrade request and execute the subsequent upgrade process.
[0038] Optionally, upon receiving a system upgrade request, the terminal responds to the request, obtains the upgrade data package required for the current system upgrade process, and performs the system upgrade operation based on the upgrade data package. In traditional methods, the terminal typically connects to the internet and accesses an OTA server to download the required upgrade data package. This method requires internet access and ensures sufficient remaining storage space in the user data partition to write the upgrade data package and its corresponding decompressed file. Therefore, the traditional method not only consumes a large amount of storage space but also requires a stable network connection, making its implementation conditions demanding. Based on this, this application proposes a method that uses a system upgrade application to stream the upgrade data package into the terminal's preset cache area instead of the user data partition. This method eliminates the need to cache additional intermediate files and requires no internet connection. Specifically, after responding to the system upgrade request, the terminal obtains the upgrade data package required for the current system upgrade process by triggering a pre-installed system upgrade application to stream the upgrade data package into the preset cache area of the terminal. The terminal can then obtain the required upgrade data package from the upgrade data package in the preset cache area.
[0039] It should be noted that, in order to ensure the normal execution of the system upgrade operation, it is necessary to ensure that the remaining storage space in the preset cache exceeds the data size corresponding to the upgrade data package. Based on this, refer to Figure 2 Step S10 includes steps S11 to S12: Step S11: Obtain the remaining storage space corresponding to the preset cache area and the data volume corresponding to the upgrade data package; Step S12: When the amount of data is less than or equal to the remaining storage space, the upgrade data packet is streamed into the preset cache area in the terminal.
[0040] In one embodiment, the preset cache area is a cache partition, which is a high-speed storage area for temporary data storage. In this embodiment, upgrade data packets are streamed into the cache partition.
[0041] It should be noted that in the terminal, the cache partition refers to a dedicated system partition on the terminal's internal storage chip, which is independent and isolated from the user data area (data partition). This means that by writing the upgrade data package to the cache partition instead of the user data area, the storage space of the user data area is not occupied, reducing interference with the user's terminal use. Furthermore, since this application uses streaming to write the upgrade data package, no additional intermediate files are generated. Also, by temporarily storing the upgrade data package in a preset cache area, the upgrade data package in the preset cache area is promptly cleared after the system upgrade is completed, preventing the occupation of additional storage space on the terminal.
[0042] Optionally, the system upgrade application streams the upgrade data packet to the terminal's preset cache by obtaining the preset storage path corresponding to the upgrade data packet, and then streaming the upgrade data packet to the target cache area in the preset cache according to the preset storage path. The preset storage path indicates the area in the cache partition used to store files required for recovery mode. In this embodiment, the preset storage path is " / cache / recovery / " in the terminal.
[0043] Optionally, the system upgrade application further includes a third-party permission for detecting the remaining storage space corresponding to the preset cache area; the system upgrade application obtains the remaining storage space of the preset cache area. Simultaneously, the system upgrade application obtains the data volume of the upgrade data package pre-packaged within its own application installation package. The system upgrade application compares the obtained remaining storage space of the preset cache area with the data volume of the upgrade data package; when the comparison result shows that the data volume of the upgrade data package is less than or equal to the remaining storage space of the preset cache area, the storage space verification is deemed successful, and the system upgrade application continues to execute subsequent streaming write operations. It should be noted that when the comparison result shows that the remaining storage space of the preset cache area is less than the data volume of the upgrade data package, the storage space verification is deemed unsuccessful, meaning that the preset cache area cannot completely write the upgrade data package. In this case, the system upgrade application generates a prompt message indicating insufficient storage space, outputs the prompt message, and terminates the upgrade process; no subsequent write operations are executed at this time.
[0044] Furthermore, when it is detected that the remaining storage space exceeds the data volume of the upgrade data packet, the system upgrade application streams the upgrade data packet into the target cache area in the preset cache area, the target cache area being a cache area specifically for caching upgrade data packets.
[0045] In one optional implementation, to improve upgrade efficiency, when it is detected that the remaining storage space exceeds the data size of the upgrade data packet, the upgrade data packet is written to a preset buffer via a flow-through write method. (See also...) Figure 3Step S12 includes steps S121 to S122: Step S121: The system upgrade application sequentially reads the split files in the upgrade data package, and the upgrade data package is encapsulated in the system upgrade application in the form of split files; Step S122: The split file is streamed into the preset cache area, which is the cache partition in the terminal.
[0046] In one optional embodiment, the upgrade data package is encapsulated in the system upgrade application as a multi-volume file, and the multi-volume file is encrypted. The system upgrade application begins to read multiple multi-volume files of the upgrade data package sequentially from the assets directory; it should be noted that the system upgrade application reads and processes each multi-volume file sequentially. After reading each multi-volume file, the currently read multi-volume file is decrypted, and the decrypted multi-volume file is written to the preset buffer via a pipe or block device; after completing the writing of the current multi-volume file, the next encrypted multi-volume file is read, and the next encrypted multi-volume file is used as the currently read multi-volume file, returning to the step of decrypting the currently read multi-volume file; until all multi-volume files of the upgrade data package are written to the preset buffer. After all multi-volume files have been processed, the preset buffer has stored the complete upgrade data package. This upgrade data package is composed of all multi-volume files concatenated continuously in the reading order, and is completely consistent in data content with the upgrade data package pre-encapsulated in the system upgrade application, and is also completely consistent in data content with the upgrade data package in the server.
[0047] Understandably, the system upgrade application immediately writes each split file it reads to a preset cache, i.e., it writes the upgrade data package to the preset cache in a streaming manner, without having to read all split files, decrypt them, and then write them to the preset cache. This improves the efficiency of writing upgrade data packages. Simultaneously, during the streaming process, the system upgrade application only keeps the currently read split file in memory at a time for decryption. After decrypting the currently read split file, the application writes it to the preset cache and immediately releases it from memory. Only after releasing the currently read split file from memory does the application read the next split file. Therefore, throughout the entire streaming process, only one split file to be decrypted is always kept in memory, and the currently read split file is released directly from memory after being written to the preset cache, preventing the generation of additional intermediate temporary files and avoiding unnecessary intermediate files consuming the terminal's limited memory.
[0048] Optionally, after the system upgrade application completes the streaming write of the split files, it initiates an upgrade command, instructing the terminal to retrieve the upgrade data packet from the preset cache to perform the system upgrade operation. In one embodiment, before initiating the upgrade command, the system upgrade application performs an integrity check on the upgrade data packet written to the preset cache.
[0049] In one optional implementation, the integrity check can be performed by obtaining the actual storage space occupied when the upgrade data packet is written to the preset buffer, determining the actual amount of data written to the preset buffer based on the actual storage space, and comparing the actual amount of data with the amount of data corresponding to the upgrade data packet. If the actual amount of data is less than the amount of data corresponding to the upgrade data packet, it indicates that data loss occurred during the writing process, resulting in an incomplete upgrade data packet, and the integrity check is determined to fail. It should be noted that when the integrity check is determined to fail, the system upgrade application deletes the upgrade data packet already written to the preset buffer and terminates the current system upgrade process. Optionally, when the integrity check is determined to fail, the process returns to the step where the system upgrade application streams the upgrade data packet to the preset buffer in the terminal to rewrite the complete upgrade data packet to the preset buffer. When the integrity check is determined to pass, the system upgrade application inputs an upgrade command to instruct the terminal to perform a system upgrade operation.
[0050] In another optional implementation, the integrity check can be performed by obtaining the actual hash value corresponding to the upgrade data packet written to a preset cache, comparing the actual hash value with the preset hash value corresponding to the upgrade data packet, and determining that the integrity check passes when the actual hash value matches the preset hash value; otherwise, determining that the integrity check fails. Optionally, when the server encapsulates the upgrade data packet in the system upgrade application, it also encapsulates the preset hash value corresponding to the upgrade data packet together with the upgrade data packet in the system upgrade application for subsequent integrity checks.
[0051] Based on this, step S20 includes: The system upgrade application performs an integrity check on the upgrade data packet written to the preset cache area based on the data volume and / or preset hash value corresponding to the upgrade data packet; When the integrity verification passes, the step of calling the upgrade data packet stored in the preset cache based on the upgrade command is executed when the upgrade command initiated by the system upgrade application is detected.
[0052] Understandably, hash value comparison requires reading the entire upgrade data packet and performing hash calculations byte by byte. If integrity checks are performed directly on the upgrade data packet written to the preset buffer based on the hash value, all data written to the preset buffer must be read completely. However, the upgrade data packet written to the preset buffer may not be complete—for example, it may be only half the size of the original upgrade data packet due to a write interruption. The system upgrade application will still attempt to read all data from the upgrade data packet written to the preset buffer and perform hash calculations byte by byte. Since the upgrade packet written to the preset buffer is incomplete, the calculated actual hash value will not match the preset hash value, thus the integrity check will fail. This method is time-consuming, resulting in low upgrade efficiency.
[0053] Based on this, after the upgrade data packet is written to the preset buffer, the actual data volume is compared with the data volume of the upgrade data packet. When the actual data volume matches the data volume, it is determined that the upgrade data packet written to the preset buffer has not been lost. Then, the preset hash value and the actual hash value are obtained. When the actual hash value matches the preset hash value, it is determined that the upgrade data packet written to the preset buffer is complete, and the integrity check is thus confirmed to have passed.
[0054] In another embodiment, when the actual data volume is less than the data volume of the upgrade data packet, the integrity check is directly determined to fail. There is no need to perform the step of the system upgrade application performing integrity check on the upgrade data packet written in the preset cache area based on the preset hash value corresponding to the upgrade data packet. In this way, no more time is spent performing hash calculation on the hash value, thus improving the upgrade efficiency.
[0055] In another embodiment, when the actual data volume matches the data volume, a preset hash value and the actual hash value are obtained; when the actual hash value does not match the preset hash value, it is determined that the integrity verification has failed.
[0056] It should be noted that the embodiments of this application combine data volume comparison and hash value comparison to perform integrity verification on the upgrade data packet. First, a fast integrity verification is performed based on data volume comparison, and when the data volume comparison passes, a precise integrity verification is performed based on the hash value, thus balancing verification efficiency and verification accuracy.
[0057] Optionally, after the integrity verification passes, the system upgrade application sends an upgrade command to the terminal; in one embodiment, the steps of the system upgrade application sending the upgrade command include: Obtain the storage path of the upgrade data package, generate an upgrade instruction based on the storage path, and write the upgrade instruction into a preset instruction partition; Obtain the restart parameters, and call the system restart interface of the terminal based on the restart parameters to trigger the terminal to restart.
[0058] In one optional implementation, the system upgrade application obtains the storage path of the upgrade data package already written to a preset cache. This storage path indicates the storage location of the upgrade data package in the target cache within the preset cache. The system upgrade application generates an upgrade instruction based on the obtained storage path. This upgrade instruction includes the storage location and / or storage path of the upgrade data package, instructing the terminal to retrieve the upgrade data package from the storage location corresponding to the storage path when performing a system upgrade operation. For example, the upgrade instruction is “update_package= / cache / recovery / update.zip”, where “update_package” is the parameter name in the upgrade instruction, “ / cache / recovery / update.zip” is the parameter value, “ / cache / recovery / update.zip” is the storage path, and “update.zip” is the upgrade data package. This upgrade instruction informs the terminal that the upgrade data package is located in the / cache / recovery / directory, and the filename of the upgrade data package is update.zip. After receiving the upgrade command, the terminal obtains the upgrade instructions, locates the file named update.zip in the / cache / recovery / directory according to the storage path in the parameter value of the upgrade instructions, and uses this file as the upgrade package data to be called.
[0059] Furthermore, after generating the upgrade command, the system upgrade application writes the generated upgrade command to a preset command partition. This preset command partition is located in the terminal's preset cache area and is used to write the upgrade command, such as / cache / recovery / upgrade_command. Before the terminal executes the system upgrade operation, it accesses the preset command partition to read the upgrade command, and then retrieves the upgrade data package based on the storage path in the upgrade command.
[0060] Optionally, after the upgrade command is written, the system upgrade application calls the terminal's system restart interface to trigger a terminal restart. When calling the system restart interface, the system upgrade application passes in preset restart parameters corresponding to the system upgrade operation. These preset restart parameters are used to guide the terminal to enter Recovery mode after restarting. Specifically, in Recovery mode, the system upgrade operation is performed. When the terminal enters Recovery mode, the upgrade command is read from a preset command partition in a preset cache, the upgrade data packet is retrieved from the target cache based on the storage path in the upgrade command, and finally, the system upgrade operation is performed based on the upgrade data packet.
[0061] It should be noted that different reboot parameters are used to control the terminal to perform corresponding operations after rebooting, and different reboot parameters correspond to different operations. When the reboot parameter is the preset reboot parameter, the terminal is instructed to start Recovery mode after rebooting and read the upgrade data packet to perform the system upgrade operation. In this embodiment, the system reboot interface called by the system upgrade application is the "PowerManager.reboot" interface, and the preset reboot parameter passed in is "recovery-update".
[0062] Optionally, after the system upgrade application completes the call to the system restart interface based on preset restart parameters, it determines that the system upgrade application initiates an upgrade command.
[0063] Furthermore, after detecting a call to the system restart interface by a system upgrade application, the terminal refers to... Figure 4 Step S20 includes steps S21 to S22: Step S21: In response to the upgrade command, perform a reboot operation and enter Recovery mode; Step S22: Read the upgrade instruction based on the Recovery mode, and obtain the upgrade data packet in the preset cache according to the upgrade instruction.
[0064] In this embodiment, when the terminal detects a system upgrade application calling the system restart interface, it identifies this as an upgrade command initiated by the application. The terminal responds to the upgrade command and performs a restart operation. During the restart process, the terminal obtains the preset restart parameters passed when the system restart interface is called, and enters a specified mode based on these parameters. This specified mode is Recovery mode. It should be noted that when entering Recovery mode, the terminal accesses a preset cache to obtain upgrade instructions, parses these instructions, and obtains the storage path of the upgrade data packet.
[0065] Optionally, the terminal retrieves the upgrade data package stored in the target cache corresponding to the path from the preset cache according to the parsed storage path, and then performs a system upgrade operation based on the upgrade data package. Specifically, the terminal parses the upgrade script and image files in the upgrade data package, and writes each image file sequentially to the corresponding physical partition of the terminal's operating system according to the partition writing order and parameters defined in the upgrade script, so as to complete the update of the partition data of each physical partition in the operating system. After all image files are written, the terminal clears the upgrade data package and upgrade instructions in the preset cache to release the storage space of the preset cache, and finally performs a restart operation. After restarting, the terminal loads the updated operating system, and the terminal completes the system upgrade operation based on the upgrade data package.
[0066] In one implementation, for specific upgrade scenarios where terminals such as display machines or after-sales service machines need to be frequently flashed with specific versions of the operating system, the operator installs the system upgrade application into the terminal via USB flash drive or internal network. The system upgrade application writes the upgrade data package into the terminal and triggers the upgrade command. The terminal then retrieves the upgrade data package based on the upgrade command to complete the upgrade operation of the operating system of the display machine or after-sales service machine.
[0067] In another implementation, when a user needs to update the operating system, if the OTA environment cannot be configured due to OTA corruption on the terminal, and no internet connection is required, the user only needs to open the installed system upgrade application and manually trigger the system upgrade request. The system upgrade application can write the upgrade data package to the terminal's preset cache area in an offline environment, without needing to access the OTA server to download the upgrade data package, thus avoiding system update failure due to network fluctuations. It also eliminates the need to download the upgrade package to the local machine and then decompress it, which would occupy additional storage space, saving system storage space occupied during the system upgrade process and improving the convenience of system upgrades.
[0068] In one optional implementation, a system upgrade application is used as a carrier. After the system upgrade application is installed on the terminal, it is used to update the terminal's operating system, as described above. Figure 5 , Figure 5This document illustrates a flowchart illustrating the process of updating a terminal's operating system using a system upgrade application. After installing the system upgrade application, the terminal receives a system upgrade request. This request can be triggered by the user or automatically by the terminal when it detects that the current device environment meets preset upgrade conditions. In response to the system upgrade request, the size of the upgrade data package is obtained, and the remaining storage space in the preset cache is checked. If the remaining storage space is insufficient, the upgrade process ends. If the remaining storage space is sufficient, the system upgrade application streams the upgrade data package, pre-packaged within the application installation package, into the preset cache in the terminal. Specifically, the system upgrade application streams multiple split files packaged within the application installation package, reads and decrypts each split file, and continuously writes the decrypted split files into the preset cache until all split files are processed. This process does not require caching the complete intermediate files, i.e., the upgrade data package, in memory or storage space. After the upgrade data packet is written, the system upgrade application performs integrity checks on the data volume of the written upgrade data packet and data validity checks based on a preset hash value. Once it confirms that the upgrade data packet is written completely and has not been tampered with, the system upgrade application initiates an upgrade command. Specifically, it generates a Recovery upgrade instruction based on the storage path of the upgrade data packet and writes the Recovery upgrade instruction to a preset instruction partition. Subsequently, the system upgrade application calls the terminal's system reboot interface, passing preset reboot parameters during the call. These preset reboot parameters instruct the terminal to enter Recovery mode after rebooting. Upon receiving the upgrade command, the terminal performs a reboot operation and starts Recovery mode according to the preset reboot parameters. After Recovery mode is started, the terminal reads the upgrade instruction, retrieves the upgrade data packet from the preset cache according to the storage path in the upgrade instruction, and finally performs the system upgrade operation based on the upgrade data packet.
[0069] This application provides a system upgrade method using an independent system upgrade application as the carrier. By pre-encapsulating the upgrade data package within the application installation package of the system upgrade application, the terminal can perform system updates based on the system upgrade application after installing the application, without relying on a network connection or OTA server to download the upgrade data package. In response to a system upgrade request, before writing the upgrade data package, the system upgrade application first checks whether the remaining storage space in the preset cache is sufficient to write the upgrade data package. If sufficient storage space is available, the write operation is performed, avoiding upgrade failure due to insufficient storage space during the write process. During the write process, the system upgrade application adopts a streaming write method, sequentially reading the multi-volume files pre-encapsulated in the application installation package. Each multi-volume file is decrypted and immediately written to the preset cache, repeating this process until all multi-volume files are processed, without generating any intermediate temporary files. This improves the efficiency of upgrading data package writing and avoids additional occupation of the terminal's limited memory. After the upgrade data packet is written, the system upgrade application performs an integrity check on the written upgrade data packet. First, it compares the actual data volume with the data size to quickly determine if the written upgrade data packet is complete. Then, it compares the hash values to accurately determine if the upgrade packet data has been tampered with. Only after the data volume comparison passes is the hash value comparison performed. This approach improves the accuracy of the integrity check while avoiding costly hash calculations when the upgrade packet data is incomplete, balancing verification efficiency and accuracy. After the integrity check passes, the system upgrade application generates an upgrade command based on the storage path of the upgrade data packet and writes it to a preset command partition. It then calls the system restart interface and passes preset restart parameters to instruct the terminal to enter Recovery mode after restarting. The terminal responds to the upgrade command and performs a restart operation, then starts Recovery mode based on the preset restart parameters. After starting Recovery mode, the terminal retrieves the upgrade command from the preset command partition, obtains the upgrade data packet from the preset cache according to the storage path in the upgrade command, and performs the system upgrade operation based on the upgrade data packet. The system upgrade method proposed in this application requires no computer connection, no internet access, does not occupy user storage space, and does not rely on OTA underlying services, which significantly reduces the technical threshold and failure risk of system upgrade operations and improves the convenience and stability of system upgrades.
[0070] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the system upgrade method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0071] This application provides a system upgrade device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the system upgrade method in Embodiment 1 above.
[0072] The following is for reference. Figure 6 The diagram illustrates a structural schematic of a system upgrade device suitable for implementing embodiments of this application. The system upgrade device in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The system upgrade device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0073] like Figure 6 As shown, the system upgrade device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the system upgrade device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the system upgrade device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows a system upgrade device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented alternatively.
[0074] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0075] The system upgrade device provided in this application, employing the system upgrade method described in the above embodiments, can improve the convenience and stability of system upgrades. Compared with the prior art, the beneficial effects of the system upgrade device provided in this application are the same as those of the system upgrade method provided in the above embodiments, and other technical features of this system upgrade device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0076] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0077] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0078] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the system upgrade method described in the above embodiments.
[0079] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0080] The aforementioned computer-readable storage medium may be included in the system upgrade device; or it may exist independently and not be assembled into the system upgrade device.
[0081] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a system upgrade device, enable the system upgrade device to write computer program code for performing the operations of this application in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0082] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0083] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0084] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described system upgrade method, thereby improving the convenience and stability of system upgrades. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the system upgrade method provided in the above embodiments, and will not be repeated here.
[0085] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the system upgrade method described above.
[0086] The computer program product provided in this application can improve the convenience and stability of system upgrades. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the system upgrade method provided in the above embodiments, and will not be repeated here.
[0087] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A system upgrade method, characterized in that, The system upgrade method, applicable to terminals with system upgrade applications installed, includes the following steps: In response to a system upgrade request, the system upgrade application streams upgrade data packets into a preset buffer in the terminal, and the upgrade data packets are pre-encapsulated in the system upgrade application. When an upgrade command initiated by the system upgrade application is detected, the upgrade data packet stored in the preset cache is invoked; The system upgrade operation is performed based on the upgrade data package.
2. The system upgrade method as described in claim 1, characterized in that, Before the step of the system upgrade application streaming the upgrade data packet into a preset buffer in the terminal in response to the system upgrade request, the method further includes: After installing the system upgrade application, obtain the system signature corresponding to the system upgrade application. The system signature is generated based on the system certificate of the terminal. Perform a signature verification operation on the system signature; After successful signature verification, the system upgrade application is granted preset system permissions, which include the first permission to write the upgrade data packet to the preset cache area and the second permission to initiate an upgrade command.
3. The system upgrade method as described in claim 1, characterized in that, The step of the system upgrade application streaming upgrade data packets into a preset buffer in the terminal includes: Obtain the remaining storage space corresponding to the preset cache area and the data volume corresponding to the upgrade data package; When the amount of data is less than or equal to the remaining storage space, the upgrade data packet is streamed into a preset cache area in the terminal.
4. The system upgrade method as described in claim 3, characterized in that, The step of streaming the upgrade data packet into a preset buffer in the terminal when the data volume is less than or equal to the remaining storage space includes: The system upgrade application reads the multi-volume files in the upgrade data package sequentially, and the upgrade data package is encapsulated in the system upgrade application in the form of multi-volume files; The split file is streamed into the preset cache area, which is the cache partition in the terminal.
5. The system upgrade method as described in claim 1, characterized in that, The step of calling the upgrade data packet stored in the preset cache based on the upgrade command when the upgrade command initiated by the system upgrade application is detected includes: The system upgrade application performs an integrity check on the upgrade data packet written to the preset cache area based on the data volume and / or preset hash value corresponding to the upgrade data packet; When the integrity verification passes, the step of calling the upgrade data packet stored in the preset cache based on the upgrade command is executed when the upgrade command initiated by the system upgrade application is detected.
6. The system upgrade method as described in claim 1, characterized in that, The steps for the system upgrade application to initiate an upgrade command include: Obtain the storage path of the upgrade data package, generate an upgrade instruction based on the storage path, and write the upgrade instruction into a preset instruction partition; Obtain preset reboot parameters, and call the system reboot interface of the terminal based on the preset reboot parameters to trigger the terminal to reboot and enter Recovery mode.
7. The system upgrade method as described in claim 6, characterized in that, The step of invoking the upgrade data packet stored in the preset cache when an upgrade command initiated by the system upgrade application is detected includes: In response to the upgrade command, perform a reboot operation and enter Recovery mode; The upgrade command is read based on the Recovery mode, and the upgrade data packet in the preset cache is obtained according to the upgrade command.
8. The system upgrade method according to any one of claims 1-2, characterized in that, The upgrade data packet is encapsulated by the server within the system upgrade application, and the server generates a system signature based on the terminal's system certificate, and performs a signing operation on the system installation application based on the system signature.
9. A terminal, the terminal comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the system upgrade method as claimed in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the system upgrade method as described in any one of claims 1 to 8.