[go: up one dir, main page]

WO2022111664A1 - Patching method, related apparatus, and system - Google Patents

Patching method, related apparatus, and system Download PDF

Info

Publication number
WO2022111664A1
WO2022111664A1 PCT/CN2021/133755 CN2021133755W WO2022111664A1 WO 2022111664 A1 WO2022111664 A1 WO 2022111664A1 CN 2021133755 W CN2021133755 W CN 2021133755W WO 2022111664 A1 WO2022111664 A1 WO 2022111664A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
program
patch
file
version information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2021/133755
Other languages
French (fr)
Chinese (zh)
Inventor
任文杰
尹永宏
李英伟
朱祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of WO2022111664A1 publication Critical patent/WO2022111664A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/48Incremental compilation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/70Services for machine-to-machine communication [M2M] or machine type communication [MTC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup

Definitions

  • the present application relates to the field of computer technology, and in particular, to a patching method, related equipment and system.
  • a bug may appear in system programs or applications.
  • the solution to this problem in the prior art is usually that the cloud server issues a corresponding patch to the electronic device. After the electronic device obtains the patch, install the patch to make the patch take effect, thereby fixing the corresponding loopholes in the program.
  • the cloud server issues a patch to an electronic device
  • the first way is that the cloud server can issue the original interpretive code of the patch to the electronic device.
  • the electronic device After the electronic device receives the patch, it performs machine coding on the electronic device side, loads and runs the patch.
  • the machine code of the patch, the patch takes effect, and the program bug is fixed.
  • the cloud server may repeatedly issue patches to different electronic devices, which consumes network bandwidth, and the patches are machine-coded on the electronic device side, resulting in low patch repair efficiency.
  • the second way is that the cloud server can machine code the patch on the cloud server side according to the obtained information such as the version of the program that needs to fix the bug, and then send the machine code of the patch to the electronic device.
  • the electronic device directly runs the machine-coded patch file.
  • the patch repair efficiency is improved, but the machine-coded patch file is bound to a specific version.
  • the versions of the programs on different electronic devices may be different, so the cloud server will issue different patches according to the programs of different versions.
  • Using the second method will cause the cloud server to repeatedly machine code the patch for the same bug, which consumes a lot of network bandwidth when delivering the patch, affects the repair efficiency of the patch, and affects the user experience.
  • the purpose of the present application is to provide a patching method, related equipment and system, which can solve the problem that the cloud server repeatedly distributes patches for multiple times when different electronic devices need to repair the same program loophole, reducing network bandwidth.
  • the patch machine code suitable for different electronic devices can be quickly synthesized on the terminal side, which greatly improves the efficiency of patch repair and brings a better user experience to the user.
  • the present application provides a patching method, the method may include: a first electronic device may establish a first connection with a second electronic device, and then the first electronic device may obtain a first patch file, the first A patch file may be used for the first vulnerability in the first program, the first vulnerability existing in the first program of the second electronic device.
  • the electronic device may compile the first patch into the first machine code according to the first version information of the first program, and then the first electronic device may synthesize the first machine code and the first offset into the first machine code.
  • Second machine code, and the second machine code can be burned to generate a second patch file.
  • the first offset is determined according to the second version information
  • the second version information is the version information in the first program in the second electronic device
  • the second version information is the first electronic device through the first
  • the connection is obtained from the second electronic device
  • the second patch file can be used to repair the first vulnerability in the first program whose version information is the second version information.
  • the first electronic device may be a smart phone, a tablet computer, a notebook computer, a desktop computer or other types of electronic devices.
  • the first electronic device may have relatively strong computing processing capability and relatively sufficient internal storage space.
  • the first electronic device may be a mounting device of the patch pool, and the first electronic device may also be a device that compiles the patch into machine code.
  • BT Bluetooth
  • WLAN wireless local area network
  • the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1 standard) or Bluetooth low energy (bluetooth low energy, BLE).
  • the WLAN module can provide wireless fidelity direct (wireless fidelity direct, Wi-Fi direct), wireless fidelity local area networks (wireless fidelity local area networks, Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point) , Wi-Fi softAP) in one or more WLAN communication solutions.
  • wireless fidelity direct wireless fidelity direct, Wi-Fi direct
  • wireless fidelity local area networks wireless fidelity local area networks, Wi-Fi LAN
  • wireless fidelity software access point wireless fidelity software access point
  • Wi-Fi softAP wireless fidelity software access point
  • the second electronic device may be a smart phone, a tablet computer, a notebook computer and other electronic devices with strong computing processing capability and sufficient internal storage space, etc., and the second electronic device may also be a smart watch, Smart bracelets, smart speakers, smart headphones and other electronic devices with weak computing processing power or small internal storage space.
  • the second electronic device may have a bluetooth (BT) module, and/or a wireless local area networks (WLAN) module.
  • the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1 standard) or Bluetooth low energy (bluetooth low energy, BLE).
  • the WLAN module can provide wireless fidelity direct (wireless fidelity direct, Wi-Fi direct), wireless fidelity local area networks (wireless fidelity local area networks, Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point) , Wi-Fi softAP) in one or more WLAN communication solutions.
  • wireless fidelity direct wireless fidelity direct, Wi-Fi direct
  • wireless fidelity local area networks wireless fidelity local area networks, Wi-Fi LAN
  • wireless fidelity software access point wireless fidelity software access point
  • Wi-Fi softAP wireless fidelity software access point
  • Implementing the method of the first aspect can avoid the problem that the cloud server repeatedly distributes patches when different electronic devices need to fix the same program vulnerability, reduces the consumption of network bandwidth, and can be quickly synthesized and adapted on the terminal side
  • the patch machine code for different electronic devices greatly improves the efficiency of patch repair and brings users a better experience.
  • the first offset may be determined according to the correspondence between the second version information recorded in the first mapping table and the first offset.
  • the first electronic device may send the second patch file to the second electronic device.
  • the second patch file can be used together with the first program file in the second electronic device to be collectively referred to as the second program file.
  • the first program file is the executable file of the first program of the unfixed first vulnerability in the second electronic device
  • the second program file is the executable file of the first program of the second electronic device that has repaired the first vulnerability document.
  • the first electronic device when the second electronic device receives the interaction request for the first program file, the first electronic device may receive the interaction request for the second program file through the first connection, wherein , the first program file may be the executable file of the first program that does not repair the first vulnerability in the second electronic device, and the second program file may be the first program file and the second patch file of the first electronic device Synthesized, the second program file is the executable file of the first program that has repaired the first vulnerability, and the first program file on the second electronic device can be associated with the second program file on the first electronic device. program files.
  • the first electronic device may read the second program file, generate interactive results or executable instructions, and may send the interactive results or executable instructions to the second electronic device through the first connection.
  • the first electronic device may send broadcast information, where the broadcast information may include: the identification number of the first electronic device, the second electronic device The device identification number and the second version information to which the second patch file applies.
  • the first electronic device may determine that the second patch file is a patch file used by the second electronic device to repair the first vulnerability of the first program, and the response information may include: The identification number of the first electronic device, the identification number of the second electronic device, and the second version information of the first program in the second electronic device.
  • the present application provides another patching method, the method may include: the first electronic device may establish a first connection with the second electronic device.
  • the first electronic device can acquire a first patch file, and the first patch file can be used to repair a first vulnerability of the first program, where the first vulnerability exists in the first program of the second electronic device.
  • the first electronic device compiles the first patch into the first machine code according to the first version information of the first program.
  • the first electronic device synthesizes the first machine code and the first offset into a second machine code, and burns the second machine code to generate a second patch file.
  • the first offset may be determined according to second version information
  • the second version information may be version information of the first program in the second electronic device
  • the second version information may be the first electronic device through
  • the first connection is obtained from the second electronic device
  • the second patch file is used to repair the first vulnerability of the first program whose version information is the second version information.
  • Implementing the method of the second aspect can avoid the problem that the cloud server repeatedly issues patches many times when different electronic devices need to fix the same program vulnerability, reduces the consumption of network bandwidth, and can be quickly synthesized and adapted on the terminal side
  • the patch machine code for different electronic devices greatly improves the efficiency of patch repair and brings users a better experience.
  • the first offset may be determined according to the correspondence between the second version information recorded in the first mapping table and the first offset.
  • the second electronic device may receive the second patch file generated by the first electronic device.
  • the second electronic device synthesizes the first program file and the second patch file into a second program file, wherein the first program file is the executable of the first program in the second electronic device that does not fix the first vulnerability file, the second program file is the executable file of the first program in the second electronic device that has fixed the first vulnerability.
  • the second electronic device may forward the interaction request to the first electronic device through the first connection
  • the second program file wherein the first program file is the executable file of the first program in the second electronic device that does not fix the first vulnerability
  • the second program file can be the first electronic device.
  • the first program file and the second patch file are synthesized, the second program file is the executable file of the first program that has repaired the first vulnerability, and the first program file on the second electronic device can be associated with the second program file on the first electronic device.
  • the first electronic device can read the second program file, generate an interaction result or executable instruction, and can send the interaction result or executable instruction to the second electronic device through the first connection.
  • the second electronic device may run the first program in which the first vulnerability has been fixed.
  • the first electronic device may send broadcast information, and the broadcast information may include: the identification number of the first electronic device, the The identification number of the second electronic device, and the second version information to which the second patch file applies.
  • the second electronic device may send response information to the first electronic device, and the response information may include: the identification number of the first electronic device, the identification number of the second electronic device, the first electronic device The second version information of the first program in the two electronic devices.
  • the first electronic device may determine that the second patch file is a patch file used by the second electronic device to repair the first vulnerability of the first program.
  • the present application provides an electronic device, which may include: a communication device, a memory and a processor coupled to the memory, a plurality of application programs, and one or more programs.
  • the electronic device may implement any function of the electronic device in the first aspect and/or the second aspect, which will not be repeated here.
  • the present application provides a computer-readable medium in which instructions can be stored.
  • the electronic device can be made to perform any function of the first aspect and/or the second aspect, which will not be repeated here.
  • FIG. 1 is a schematic diagram of the architecture of a communication system provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
  • FIG. 3 is a software framework diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a patch machine coding provided by an embodiment of the present application.
  • FIG. 5 is a flowchart of a method for patching provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a scenario of a method for patching provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a scenario of another method for patching provided by an embodiment of the present application.
  • 9A is a schematic diagram of a user interface provided by an embodiment of the present application.
  • 9B is a schematic diagram of a user interface provided by an embodiment of the present application.
  • 10A is a schematic diagram of a user interface provided by an embodiment of the present application.
  • 10B is a schematic diagram of a user interface provided by an embodiment of the present application.
  • FIG. 10C is a schematic diagram of a user interface provided by an embodiment of the present application.
  • the embodiments of the present application provide a communication system, which may include multiple electronic devices, and a communication connection may be established between the multiple electronic devices by accessing the same local area network, and data interaction may be performed through the communication connection.
  • the first electronic device may be a smart phone, a tablet computer, a notebook computer, a desktop computer or other types of electronic devices, which is not limited in this application.
  • the first electronic device may have relatively strong computing processing capability and relatively sufficient internal storage space.
  • the first electronic device may be a mounting device of the patch pool, and the first electronic device may also be a device that compiles the patch into machine code.
  • the first electronic device can provide the compiled patch machine code for the second electronic device in the local area network.
  • the second electronic device may be a smart phone, a tablet computer, a notebook computer and other electronic devices with strong computing processing capability and sufficient internal storage space, etc.
  • the second electronic device may also be a smart watch, a smart bracelet, a smart Electronic devices such as speakers and smart earphones with weak computing processing capability or small internal storage space, etc., are not particularly limited in this application.
  • the second electronic device may receive a patch from the first electronic device through a local area network connection, or receive an instruction from the first electronic device, and execute a corresponding function to repair the vulnerability targeted by the patch.
  • the first electronic device and the second electronic device can carry Or other types of operating systems, which are also not limited in this application.
  • the embodiment of the present application also provides a method for applying patches, which solves the problem that the cloud server repeatedly distributes the same patch to different electronic devices.
  • the patching method can be applied to the communication system and the electronic device provided by the embodiments of the present application.
  • the first electronic device mounted in the patch pool can obtain the first patch issued by the cloud server.
  • the first patch can be used to repair the first vulnerability of the first program, wherein the first patch can be an interpretive patch code, and the interpretive patch code is a source program written in a high-level computer language (such as C language, Python, etc.).
  • the explanatory patch code is independent of electronic device and version information, so it can be run across devices.
  • the first electronic device may compile the interpretive patch code into the first machine code based on the first version information of the first program in the device.
  • the version information of the first program of other electronic devices may not be the same, so the patch machine codes will also be different.
  • the offset addresses corresponding to different program versions are different. Therefore, for the same interpretive patch code, for different electronic devices, the patched machine code may have a certain difference. The difference can be reflected in some absolute The offset of the address is different.
  • a first mapping table may be recorded in the patch pool, and a one-to-one correspondence between different versions of the first program and offsets may be recorded in the first mapping table.
  • the first electronic device can acquire the ID of the second electronic device in the same local area network and the second version information of the first program in the second electronic device.
  • the first electronic device can quickly synthesize the second machine code and generate a second patch file according to the second offset corresponding to the second version information obtained by querying in the first mapping table, and the second patch file can be used to repair the second version.
  • the second electronic device can obtain the second patch file or an instruction corresponding to the second patch file and run it, the patch takes effect, and the first loophole in the first program of the second electronic device is repaired.
  • the cloud server when different electronic devices need to repair the same program vulnerability, the cloud server only needs to issue a patch to the first electronic device in the local area network, and then the patch can be quickly synchronized to the same local area network. on other electronic devices. Therefore, the implementation of the technical solution of the present application can avoid the cloud server from repeatedly issuing patches for many times, reduce the consumption of network bandwidth, and can quickly synthesize the patch machine code suitable for different electronic devices on the terminal side, which greatly improves the efficiency of patch repair. Bring a better user experience to users.
  • a patch refers to a small program released to solve the problems exposed in the use of large software systems or applications.
  • a patch can be used to fix one or more software vulnerabilities, for example, a patch can fix one or more vulnerabilities including but not limited to applications, application frameworks, kernels, hardware drivers, etc. Patches can also be used to add new product features or functionality.
  • the patch pool may be one or more directories in which one or more patch files are stored.
  • the storage location of the patch pool in the terminal device may be the directory /data/hotpatch, etc., which is not limited in this application.
  • the patch pool can be mounted on a terminal device with sufficient internal storage space. If the patch pool is set to have a network attribute, the patch pool is visible to other electronic devices in the same local area network, and the storage location of the patch pool is invisible to electronic devices that are not in the local area network.
  • the directory where the patch pool is located can also be provided with a corresponding security protection mechanism. Except for some specific applications with write permissions, modification permissions and/or other related permissions, other electronic devices or other applications in the local area network have only limited access to this directory. read permission, but cannot write and/or modify the directory.
  • the related devices for patch generation and taking effect mainly involve servers and terminal devices.
  • the server may include a patch package tool, a patch package archive, a patch package release, and the like.
  • the patch package tool is a script running in the background of the server, which packages the patch files into a compressed file, and the overall layout of each file in the compressed file is unique to the patch package.
  • Patch package archiving is used to place the patch package in the specified archive address after the patch package tool generates the patch package, so that the subsequent server can obtain the patch package.
  • Patch package release is used by the server to deliver patch files to terminal devices.
  • the terminal device may include patch package download, patch engine, patch package upgrade, and patch partition. The patch package download is used to receive the patch package delivered by the server.
  • Patch package upgrade means that after the user searches for the patch package on the mobile phone and confirms that the patch package is downloaded uniformly, the patch engine downloads, verifies, and installs the patch package.
  • the patch engine encapsulates various types of business logic, including verification of patch files, enabling patches to take effect, and undoing abnormal patches.
  • the patch partition is a space address on the hard disk of the terminal device, and the binary patch image in the patch package can be burned into this partition.
  • Computer language refers to the language used for communication between humans and computers.
  • Computer language is a medium for transferring information between humans and computers.
  • the biggest characteristic of a computer system is that instructions are communicated to the machine through a language.
  • a set of numbers, characters and grammar rules for writing computer programs are needed. These characters and grammar rules form various instructions of the computer, that is, the computer language.
  • Computer languages are divided into high-level languages and low-level languages. High-level languages are programming that is closer to natural languages and mathematical formulas, such as C language, python language, java language, PHP language, etc.
  • High-level languages are basically separated from the hardware system of the machine and write programs in a way that is easier for people to understand. The program written is called the source program.
  • Machine language is a set of machine instructions that can be directly recognized and executed by a computer represented by binary code. That is, machine language is a system of instruction sets. This instruction set is called machine code, which is data that can be directly interpreted by the computer's CPU.
  • the body of assembly language is assembly instructions. The difference between assembly instructions and machine instructions lies in the representation of the instructions. Assembly instructions are the writing format of machine instructions that are easy to remember.
  • Machine coding refers to the process of compiling a high-level language into machine language. Since the computer cannot directly recognize the high-level language, it can only recognize the machine language. Therefore, the high-level language needs to go through the compiler to program the assembler, and then turn it into machine code through the assembler, and finally can be executed by the computer.
  • Mounting refers to attaching a file or an external device (usually a storage device) to an existing directory in the device. By accessing this directory, the external device or file is accessed, and at the same time, the external device or file is placed. Under the directory in the device, it is also possible to let the system on the device know how to manage the external device or file, and understand processes such as the readable and writable characteristics of the external device or file.
  • An image file refers to making a specific series of files into a single file according to a certain format to facilitate users to download and use, such as an operating system, a game, and so on. Its most important feature is that it can be recognized by specific software and can be directly burned to a disc.
  • the image file in the usual sense can be further expanded, and the image file can contain more information, such as system files, boot files, partition table information, etc., so that the image file can contain all the information of a partition or even a hard disk.
  • the type of patch file described below can be an image file.
  • the absolute address means that in data transmission and storage, the storage unit of the main memory is in units of bytes, and each storage unit has an address corresponding to it. Assuming that the capacity of the main memory is n, the memory has n storage units (taking n bytes of storage space), and its address numbers are: 0, 1, 2, ..., n-1. The address number of the main memory space is called the absolute address of the main memory.
  • the relative address refers to the address used when addressing relative to a certain reference value (usually 0 is used as the reference value).
  • Relative addresses are often used in the process of program writing and compilation. Since the program must be placed in the main memory before it can be executed, the instructions and data must be related to an absolute address in the main memory—into the main memory unit. However, in a multiprogramming system, the main memory will store multiple jobs, so programmers may not know exactly where their programs are placed in the main memory to run, that is, programmers often do not use absolute addresses to write programs. . Therefore, programmers often use relative addresses, that is, relative to some base address to write programs and arrange the location of instructions and data.
  • boot.art is a class object image file that can contain all classes listed in all framework/base/preloaded-classes files. These classes are loaded into memory once and can be used directly.
  • the communication system 10 may include cloud-side devices such as cloud server 101, and terminal-side devices such as mobile phone 102, router 103, tablet computer 104, notebook computer 105, smart TV 106, smart speaker 107, smart Headphones 108, smart watches 109, smart bracelets 110, etc.
  • the router 103 can form a wireless network and transmit wireless network signals, and the mobile phone 102, tablet computer 104, notebook computer 105, smart TV 106, smart speaker 107, smart earphone 108, smart watch 109, smart bracelet 110, etc.
  • the wireless network of the router 103 is thus in the same local area network.
  • the cloud server 101 can generate one or more sets of patch packages required by the electronic device.
  • the patch package generated by the cloud server 101 may be the original interpretive patch code written in a computer high-level language and independent of the device, or may be the patch code in the form of machine code.
  • the cloud server can deliver the generated patch package to the mobile phone 102 through far-field communication, and the generated patch package can be used to fix one or more vulnerabilities of the program, or can be used to add one or more product features or functions and functions. and/or functions, which are not limited in this application.
  • electronic devices can add a "voice assistant" function by installing a patch package, which can help users send messages and make calls without touching the electronic device, and can also help users communicate face-to-face with others in different languages.
  • patches can be of various types, such as Taking the system as an example, patches of corresponding types may exist at the application (application, APP) layer, application framework (application framework) layer, kernel (kernel) layer, or hardware driver (hardware driver) layer, etc., which are not limited in this application.
  • the mobile phone 102 may have strong computing processing capability and sufficient internal storage space, and the mobile phone 102 may be used as a patch pool to receive one or more patch packages from the cloud server side.
  • the patch pool can have a network attribute, that is, the storage location/directory where the patch pool is located is visible to all devices in the local area network.
  • the mobile phone 102 can synchronize the patch pool information to other devices in the local area network through patch package broadcast.
  • the cell phone 102 may have a bluetooth (BT) module and/or a wireless local area networks (WLAN) module.
  • BT bluetooth
  • WLAN wireless local area networks
  • the Bluetooth module can provide one or more Bluetooth communication solutions including classic Bluetooth (Bluetooth 2.1) or Bluetooth low energy (BLE), and the WLAN module can provide wireless fidelity direct , Wi-Fi direct), wireless fidelity local area networks (Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point, Wi-Fi softAP) one or more WLANs communication solutions.
  • the mobile phone 102 can establish a wireless communication connection with other electronic devices near the mobile phone 102 using one or more wireless communication technologies of Bluetooth or WLAN or other types, and then the patch can be shared with other electronic devices through the wireless communication connection.
  • the mobile phone 102 may receive a patch package actively pushed by the cloud server 101 through the network, and the patch package may be a patch in the form of interpretive codes.
  • the mobile phone 102 may When the patch is installed, the patch code is machine-coded on the device side based on the version information of the application that needs to be patched on the device.
  • the mobile phone 102 may also report the version information of the application to be patched to the cloud server 101 , and then the cloud server 101 performs machine coding according to the version information, and then sends the patch in the form of machine code to the mobile phone 102 .
  • a mapping table can be stored in the mobile phone 102, and the mapping table can record the corresponding relationship between the version information and the machine code offset.
  • the mobile phone 102 can generate different machine code patches according to different version information, and then other terminal devices in the local area network. The corresponding patches can be obtained and installed to take effect.
  • the tablet computer 104 and the notebook computer 105 may be terminal devices with strong computing processing capability and sufficient internal storage space, and may be equipped with wireless communication modules such as a Bluetooth module and a WLAN module.
  • wireless communication modules such as a Bluetooth module and a WLAN module.
  • Terminal devices such as the tablet computer 104 and the notebook computer 105 with strong computing processing capability and sufficient internal storage space can also be used as a patch pool, and can also be used as a terminal device for compiling a patch program into machine code.
  • the terminal device where the patch pool is located and the terminal device that compiles the patch program into machine code may be the same terminal device, or may not be the same terminal device.
  • the mobile phone 102 is used as the terminal device mounted in the patch pool, and the laptop 105 is used as the terminal device for compiling the patch machine code.
  • the laptop computer 105 obtains the patch in the patch pool. The laptop 105 then performs machine coding of the patch.
  • the smart TV 106, the smart speaker 107, the smart earphone 108, the smart watch 109, and the smart bracelet 110 may be terminal devices with weak computing processing capability or small internal storage space, and may have wireless wireless modules such as Bluetooth modules and WLAN modules. communication module.
  • wireless wireless modules such as Bluetooth modules and WLAN modules.
  • the patch files run by the terminal devices with weaker computing processing capability or smaller internal storage space may be mounted on the terminal device with stronger computing processing capability or larger internal storage space in the same local area network. In this case, when these terminal devices with weak computing processing power or small internal storage space are disconnected from the local area network, the patch will become invalid. The patch will take effect again when the LAN connection is reconnected.
  • the cloud server 101 can generate a patch package required by the electronic device in the local area network where the mobile phone 102 is located, and deliver the patch package to the mobile phone 102 .
  • the patch packages generated by the cloud server can be distributed in groups.
  • the grouping method can be grouped by functions, such as bug fixes, new product features, etc., or by patch types, such as application (application, APP) layer type patches, hardware driver (hardware driver) layer type patches etc., which are not limited in this application.
  • various terminal devices that share patches may be equipped with the same operating systems such as Hongmeng
  • the system under the connection of the router 103, forms a system ecology. Under the same operating system, the differences in the machine codes of patches corresponding to different version information are small, and the terminal device compiling the machine codes can quickly synthesize the corresponding patch machine codes according to the different version information.
  • the communication system 10 shown in this embodiment does not constitute a specific limitation to the embodiment of this application.
  • the communication system 10 may also include more or less devices than shown.
  • the communication system 10 may also include other electronic devices such as desktop computers, smart desk lamps, and smart refrigerators, which are not limited in this application.
  • FIG. 2 shows a schematic structural diagram of the electronic device 100 .
  • the electronic device 100 may be a mobile phone 102, a tablet computer 104, a notebook computer 105, a smart TV 106, a smart speaker 107, a smart earphone 108, a smart watch 109, a smart bracelet 110, etc. shown in the communication system 10, or it may be Other electronic devices, such as desktop computers, laptop computers, handheld computers, ultra-mobile personal computers (UMPCs), netbooks, and cellular phones, personal digital assistants (PDAs), augmented reality (augmented reality, AR) equipment, virtual reality (virtual reality, VR) equipment, artificial intelligence (artificial intelligence (AI) equipment, wearable equipment, vehicle-mounted equipment, smart home equipment and/or smart city equipment, embodiments of the present application
  • PDAs personal digital assistants
  • augmented reality augmented reality, AR
  • VR virtual reality
  • AI artificial intelligence
  • wearable equipment wearable equipment
  • vehicle-mounted equipment smart home equipment and/or smart city equipment
  • the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components.
  • the illustrated components may be implemented in hardware, software, or a combination of software and hardware.
  • the electronic device 100 may include a processor 111, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on.
  • SIM Subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the processor 111 may include one or more processing units, for example, the processor 111 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • baseband processor baseband processor
  • neural-network processing unit neural-network processing unit
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 111 for storing instructions and data.
  • the memory in the processor 111 is a cache memory.
  • the memory may hold instructions or data that have just been used or recycled by the processor 111 . If the processor 111 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 111 is reduced, thereby improving the efficiency of the system.
  • the processor 111 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 111 may contain multiple sets of I2C buses.
  • the processor 111 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces.
  • the processor 111 can couple the touch sensor 180K through the I2C interface, so that the processor 111 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • the processor 111 may contain multiple sets of I2S buses.
  • the processor 111 can be coupled with the audio module 170 through an I2S bus to implement communication between the processor 111 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is typically used to connect the processor 111 with the wireless communication module 160 .
  • the processor 111 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.
  • the MIPI interface can be used to connect the processor 111 with the display screen 194, the camera 193 and other peripheral devices.
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 111 and the camera 193 communicate through a CSI interface to implement the photographing function of the electronic device 100 .
  • the processor 111 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface can be used to connect the processor 111 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like.
  • the GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 111 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 111, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 111 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 111.
  • at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 111 .
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low frequency baseband signal is processed by the baseband processor and passed to the application processor.
  • the application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 .
  • the modem processor may be a stand-alone device.
  • the modulation and demodulation processor may be independent of the processor 111, and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellites Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared technology (IR).
  • WLAN wireless local area networks
  • BT Bluetooth
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication
  • IR infrared technology
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 111 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 111 , perform frequency modulation on it, amplify it, and then convert it into electromagnetic waves for radiation through the antenna 2 .
  • the electronic device 100 may discover a device in the same local area network through a wireless communication technology such as WLAN, and establish a wireless communication connection with the device.
  • the electronic device 100 can also discover devices in a certain area nearby through Bluetooth and establish a communication connection.
  • the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1) or Bluetooth low energy (Bluetooth low energy, BLE).
  • the WLAN module can provide a solution including one or more WLAN communications in Wi-Fi direct, Wi-Fi LAN or Wi-Fi softAP.
  • the electronic device 100 can access the Internet through a mobile network (such as 2G/3G/4G/5G and other networks), a wireless network (such as Wi-Fi), and a wired network (such as broadband), and communicate with other
  • a mobile network such as 2G/3G/4G/5G and other networks
  • a wireless network such as Wi-Fi
  • a wired network such as broadband
  • the WLAN wireless communication solution provided by the wireless communication module 160 can also enable the electronic device to communicate with a device (such as a server) in the network, and to communicate with the cloud device through the device (such as a server) in the network. In this way, electronic devices can discover and transmit data to devices in the network and cloud devices.
  • the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 111 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light).
  • LED diode AMOLED
  • flexible light-emitting diode flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on.
  • the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.
  • the electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
  • the ISP is used to process the data fed back by the camera 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin tone.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the object is projected through the lens to generate an optical image onto the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.
  • a digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG Moving Picture Experts Group
  • MPEG2 moving picture experts group
  • MPEG3 MPEG4
  • MPEG4 Moving Picture Experts Group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
  • RAM random access memories
  • NVM non-volatile memories
  • Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronization Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as fifth-generation DDR SDRAM is generally called DDR5 SDRAM), etc.;
  • SRAM static random-access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • fifth-generation DDR SDRAM is generally called DDR5 SDRAM
  • Non-volatile memory may include magnetic disk storage devices, flash memory.
  • Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle, and can include single-level memory cell (SLC), multi-level memory cell (multi-level memory cell, SLC) according to the level of storage cell potential.
  • cell, MLC multi-level memory cell
  • TLC triple-level cell
  • QLC quad-level cell
  • UFS universal flash storage
  • eMMC embedded multimedia memory card
  • the random access memory can be directly read and written by the processor 111, and can be used to store executable programs (such as machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.
  • the nonvolatile memory can also store executable programs and store data of user and application programs, etc., and can be loaded into the random access memory in advance for the processor 111 to directly read and write.
  • the external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device 100 .
  • the external non-volatile memory communicates with the processor 111 through the external memory interface 120 to realize the data storage function. For example, save music, video, etc. files in external non-volatile memory.
  • the electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 111 , or some functional modules of the audio module 170 may be provided in the processor 111 .
  • Speaker 170A also referred to as a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
  • the receiver 170B also referred to as "earpiece" is used to convert audio electrical signals into sound signals.
  • the voice can be answered by placing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
  • the earphone jack 170D is used to connect wired earphones.
  • the earphone interface 170D can be the USB interface 130, or can be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals.
  • the gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 .
  • the air pressure sensor 180C is used to measure air pressure.
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
  • Distance sensor 180F for measuring distance.
  • the electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the ambient light sensor 180L is used to sense ambient light brightness.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the temperature sensor 180J is used to detect the temperature.
  • Touch sensor 180K also called "touch device”.
  • the touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to touch operations may be provided through display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the location where the display screen 194 is located.
  • the bone conduction sensor 180M can acquire vibration signals.
  • the keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • Motor 191 can generate vibrating cues.
  • the motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • touch operations acting on different applications can correspond to different vibration feedback effects.
  • the motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 .
  • Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 .
  • the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 employs an eSIM, ie: an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiments of the present invention use a layered architecture Taking the system as an example, the software architecture of the electronic device 100 is exemplarily described.
  • FIG. 3 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.
  • the software structure of the electronic device 100 may include: an application layer (applications, APP), an application framework layer (application framework, FWK), an Android runtime ( runtime) and system libraries (libraries), kernel layer (kernel).
  • application layer applications, APP
  • application framework layer application framework, FWK
  • Android runtime runtime
  • system libraries libraries
  • kernel layer kernel layer
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.
  • Content providers are used to store and retrieve data and make these data accessible to applications.
  • the data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications.
  • a display interface can consist of one or more views.
  • the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide the communication function of the electronic device 100 .
  • the management of call status including connecting, hanging up, etc.).
  • the resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
  • the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction.
  • the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, prompting text information in the status bar, making a sound, the head-mounted display device vibrating, the indicator light flashing, etc.
  • Runtime includes core libraries and virtual machines. The runtime is responsible for scheduling and management of the Android system.
  • the core library consists of two parts: one is the function functions that the java language needs to call, and the other is the core library of Android.
  • the application layer and the application framework layer run in virtual machines.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.
  • a system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
  • surface manager surface manager
  • media library Media Libraries
  • 3D graphics processing library eg: OpenGL ES
  • 2D graphics engine eg: SGL
  • the Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least a display driver, a camera driver, an audio driver, a sensor driver, as well as WLAN Bluetooth capabilities and basic communication protocols.
  • a patch may be used to fix one or more software program vulnerabilities, or may be used to add one or more new product features or functionality.
  • the patch of the electronic device 100 can repair one or more program vulnerabilities such as the above-mentioned application layer, application framework layer, system library and kernel layer, and the patch can also be used to add the above-mentioned application layer and application framework.
  • One or more product features or functions, such as layer, system library and kernel layer, are not limited in this application.
  • a patch file may include: version information, verification information, positioning information, and new code to be written, and other segments.
  • the new code to be written can be a differential code or a replacement code.
  • the difference code means that the patch code is the difference code between the old program code that has not fixed the vulnerability and the new program code that has fixed the vulnerability.
  • the differential code can effectively compress the size of the patch file, reduce code duplication and save storage space.
  • the replacement code means that the patch code can directly replace the code at the bug. For example, when reading the function where the bug is located, you can jump to the patch code to read the patch code instead of reading the code at the bug. After the patch code is read , and then jump back to the original program code to continue reading other codes.
  • the version information may refer to a program version to which the current patch file is applicable, and the version information includes a version number, a version name, and a generation time.
  • the verification information can be a cyclic redundancy check (CRC) code, which is generally used to distinguish the identity information of the patch file and verify the correctness of the data in the patch file.
  • CRC cyclic redundancy check
  • the system can determine the patch through the version information and the verification information. Whether the file matches the system.
  • a bug may be recorded in the positioning information, that is, the address of the code to be modified, and a jump address of jumping to the corresponding newly written code may be recorded. Therefore, the location information of the bug code in the original program can be found through the data in the location information segment, and then the new patch code can be written.
  • the segment of the new code to be written contains the new function code.
  • the terminal device when a vulnerability is repaired to an original program, the terminal device will detect the running state of the original program in the system. When detecting that the original program is running, the terminal device further detects the patch file in the system. If it is detected that a patch file is set in the system, the patch file will be authenticated to determine whether the patch file matches the original program. Specifically, when verifying the patch file, the version information and verification information in the patch file can be read, and the patch file can be verified through the version information and verification information, that is, the verification data in the patch file, For example, the version number, generation time, and CRC check code are compared with the verification data in the original program to ensure that the patch file matches the original program in the system to avoid using the wrong patch file.
  • the verification is successful, it means that the patch file matches the original program on the terminal device; if the verification fails, it means that the patch file does not match the original program on the terminal device.
  • the terminal device will obtain the location information of the code to be modified and the new code to be written in the patch file, so as to write the new code for the patch at the bug to realize functions such as repairing the vulnerability.
  • FIG. 4 is a schematic diagram of machine coding of patch codes according to an embodiment of the present application.
  • the electronic device 100 may compile the original interpretive code into machine code that can be directly executed by the computer processor based on the version information of the device.
  • the patch may be composed of public code 401 and private code 402 , both of which are non-machine codes, ie, interpretive codes.
  • the common code 401 will be compiled into the machine code of the common module in the process of machine coding.
  • the interface or function used by the private code 402 is the code of the lower-level development kit.
  • the compiled machine code of the private code 402 is composed of a combination of absolute addresses and relative addresses.
  • the above-mentioned public code 401 and private code 402 are both original interpretive codes, that is to say, the above-mentioned public code 401 and private code 402 are non-machine codes, which can rely on some specific containers to shield differences, so cross-device can be achieved. run.
  • the electronic device 100 compiles the private code 402 into the machine code 403 of the private code, and compiles the public code 401 into the machine code 404 of the public code.
  • the machine code 403 of the private code is the machine code generated after the private code is compiled in the process of machine coding.
  • this part of the code can be commonly used on different electronic devices, and the private resources in each platform referenced in this part of the code can be shared.
  • the machine code 404 of the common code is the machine code generated after the common code is compiled in the process of machine coding.
  • the part of the code can be generated based on the code of the middle layer public interface of the electronic device.
  • the public code 401 can be combined with the public addresses of the public interfaces of different devices to generate a strong correlation with the electronic devices. machine code. For example, taking the electronic device as the mobile phone 400 as an example, the public code 401 combines the obtained offset address related to the mobile phone 400 to generate the machine code 404 of the public code related to the mobile phone 400, and save it in the boot.art file .
  • the machine code 403 of the private code and the machine code 404 of the public code are combined to form the patch machine code 405 .
  • the patch machine code 405 may be stored in a buffer pool of the electronic device.
  • the patch code in the patch pool can be machine-coded based on the device on which the patch pool is mounted. However, on different devices, the body code of the same patch code is the same, and the offset address of the same function may be different, so the corresponding machine codes of the patch code are different when machine coding is performed on different devices.
  • a mapping table can be stored in the patch pool to record these differences and mark the relevant devices corresponding to the differences. In this way, when the machine-coded patch code in the patch pool is migrated to the second device, a new patch machine code can be quickly synthesized in combination with the differences corresponding to the second device.
  • the synthesis method includes but is not limited to binary synthesis, disk block Synthesis or code relocation, etc.
  • the patch pool stores information about patch offset A 406 corresponding to the mobile phone 400 and patch offset B 407 corresponding to the watch 408 .
  • the patch offset A 406 may include: the patch machine code offset, the identifier of the mobile phone 400 corresponding to the offset in the local area network, and the matching information of the patch-related content.
  • the patch offset B 408 may include: the patch machine code offset, the identifier of the watch 408 corresponding to the offset in the local area network, and the matching information of the patch-related content. If the version information of the mobile phone 400 and the watch 408 to be patched is different, the offset address of the public interface may be different, and the patch offset A 406 and the patch offset B 407 are also different.
  • the patch machine code of the mobile phone 400 when the patch machine code of the mobile phone 400 is migrated to the watch 408, the patch machine code of the mobile phone 400 can be combined with the patch offset B of the watch 408 to quickly synthesize a new patch machine code, and the new patch machine code can be added to the watch 408. effective on.
  • the patch pool may store a mapping table, and the mapping table may record information such as the version number, the unique identification number of the electronic device, and the offset.
  • the mapping table may be as shown in Table 1 below:
  • the unique identification number of the electronic device recorded in this exemplary mapping table is a product serial number (serial number, SN) of the electronic device as an example.
  • the version number of the electronic device 869672321140250 is 10.0.1, and the offset corresponding to the electronic device is 1F69H.
  • the version number owned by the electronic device 869672321150369 is 10.0.2, and the offset corresponding to the electronic device is 0F60H.
  • the version number of the electronic device 869672321120568 is 10.0.3, and the offset corresponding to the electronic device is 0060H.
  • the H at the end of the offset may represent that the offset is a hexadecimal number.
  • the unique identification number of the electronic device recorded in the mapping table may be a fixed physical address (media access control, MAC) of the electronic device, or may be a unique number that distinguishes the electronic device from other electronic devices. This application does not limit this.
  • FIG. 4 merely illustrates the implementation of the machine-coded original explanatory patch code, and should not constitute a specific limitation to the present application.
  • Mobile phones can be used as devices to mount patch pools and machine-coded patches
  • tablets can be used as devices to obtain patches to fix bugs or upgrade product features.
  • Mobile phones and tablet computers are terminal devices with strong computing processing capabilities and sufficient internal storage space.
  • the mobile phone and the tablet computer are in the same local area network.
  • the mobile phone can machine code the patch on the mobile phone side according to the version information of the tablet computer, generate a patch file in the form of machine code, and then send it to the tablet computer.
  • the tablet computer reads the patch file, Patch takes effect.
  • the device on which the patch pool is mounted and the device on which the machine-coded patch is mounted may not be the same device.
  • the laptop is the device on which the patch pool is mounted.
  • the laptop can obtain each patch from the cloud server and store it in the patch pool.
  • the patch pool is visible to all devices connected to the same LAN.
  • the mobile phone, tablet computer and laptop are in the same local area network.
  • the mobile phone can obtain a patch in the patch pool, and machine code the patch on the mobile phone side according to the version information of the tablet computer to generate a patch file in the form of machine code. Then send it to the tablet computer, the tablet computer reads the patch file, and the patch takes effect.
  • FIG. 5 shows a flow of a patching method provided by an embodiment of the present application. Specifically, the following steps may be included:
  • the mobile phone and the tablet computer can be in the same local area network by accessing the same Wi-Fi access point provided by the same router, and the mobile phone and the tablet computer can establish a wireless communication connection between the two through the Wi-Fi access point. (may also be referred to as the first connection).
  • the local area network information such as the patch pool mounted on the mobile phone and the location of the patch pool may be visible to the tablet computer.
  • the mobile phone can obtain the first patch (also referred to as the first patch file) issued by the cloud server, and the first patch can be used to repair the first vulnerability of the first program.
  • the first patch also referred to as the first patch file
  • the patch pool may refer to one or more directories in which one or more patches are stored.
  • the directory can be set to be visible to other devices in the local area network, and for other devices not in the same local area network, the directory is accessible to other devices. its not visible.
  • the patch pool can be a directory on the mounted mobile device, such as /data/hotpatch/, and the properties of the directory can be set to be visible to other devices in the local area network. In this way, the storage location of the patch pool will be exposed in the throughout the local area network.
  • the first patch may include one or more patch files, and the code form of the first patch may be interpretive code or machine code, which is not limited in this application. If it is a patch file in the form of machine code, the cloud server needs to obtain the version information of the program in the device that needs to be patched before issuing the patch, and then perform machine coding in the cloud according to the version information, and then send it to the device side. No need to compile, you can run machine code directly.
  • the first patch may be actively pushed to the mobile phone after being generated by the cloud server, or may be issued according to the request of the mobile phone, which is not limited in this application.
  • the mobile phone compiles the code of the first patch into machine code A (also referred to as the first machine code).
  • the version information of the first program on different electronic devices may be different, and the version information may include information such as version name, version number, etc.
  • the version information of the first program in the mobile phone It can be called the first version information.
  • the version number of the first program of the mobile phone is version number A.
  • the mobile phone also stores a first mapping table, and the first mapping table may record the one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A.
  • the version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.
  • the mobile phone can obtain a certain version of the first program currently used by other electronic devices in the local area network, then the first mapping table can also record the information of the electronic device.
  • the ID of an electronic device can be its fixed physical address (media access control, MAC), or the product serial number (SN) of the electronic device, or other unique identifications that distinguish the electronic device from other electronic devices. No., this application does not limit it.
  • the mobile phone obtains information such as the ID of the tablet computer, the version number B of the first program in the tablet computer, and the like.
  • the tablet's ID is the unique identification number of the tablet.
  • the ID of the tablet computer may be a MAC number, an SN number, or other unique identification numbers of the tablet computer that are different from other electronic devices, which are not limited in this application.
  • the version information of the first program in the tablet computer may be referred to as the second version information.
  • the version number of the first program of the tablet computer is version number B, which is different from the version number A of the first program in the mobile phone.
  • the mobile phone queries the first mapping table, and the version number B corresponds to the offset B (which may also be referred to as the first offset).
  • the mobile phone synthesizes the offset B corresponding to the version number B and the machine code A into the machine code B (also called the second machine code), and generates the patch file B (also called the second patch file), and the patch file B It is a patch file that can be used to fix the first vulnerability whose first program is version B.
  • the manner in which the offset B and the machine code A are combined into the machine code B may include, but is not limited to, a binary synthesis manner, a disk block synthesis manner, and a code relocation manner.
  • the binary synthesis method refers to synthesizing multiple binary files into one, and the address offset of the data segment is specified, and the addresses between the data segments are filled with default values.
  • the disk block combination method refers to combining multiple physical hard blocks into one logical hard disk.
  • the code relocation method refers to the process of transforming the logical address space of the program into the actual physical address space in the memory. There are two methods of relocation, namely dynamic relocation and static relocation.
  • Static relocation is completed during the process of loading the program into memory, which means that before the program starts to run, all address-related items in the program have been relocated. Change again. Dynamic relocation is not done when the program is loaded into memory, but every time the central processing unit (CPU) accesses the memory, a dynamic address translation mechanism (hardware) automatically converts the relative address into an absolute address. Dynamic relocation requires the cooperation of software and hardware.
  • the patch file B may include one or more files.
  • the mobile phone sends a broadcast in the local area network
  • the broadcast message may include the device ID (such as the mobile phone ID) of the mounted patch pool, the device ID (such as the tablet computer ID) supported by the patch file B, and the device ID supported by the patch file B.
  • the first program version number (eg version number B) and so on.
  • the tablet computer responds to the broadcast of the mobile phone, and the response message may include the mobile phone ID, the tablet computer ID, the version number B, and the like.
  • the tablet computer obtains the patch file B generated by the mobile phone side.
  • the mobile phone After the tablet computer answers the broadcast of the mobile phone and the mobile phone verifies the identity of the tablet computer, the mobile phone can send the patch file B to the tablet computer side.
  • the code in the patch file may be a differential code, then load the patch file B, and the patch file B will be synthesized with the original first program code to generate a new first program code, which is repaired in the new first program code
  • the first flaw is the problem.
  • the code in the patch file may be replacement code, then when the tablet computer runs the machine code corresponding to the first vulnerability of the first program, it can jump to load the patch file B, the patch takes effect, and the first program The first bug in . After the patch file B is read, jump back to the original program.
  • the tablet computer can make the patch file B in the format of a loadable dynamic link library, and the patch file B contains the code information of the first vulnerability in the first program and the code information of repairing the first vulnerability, and then, through In the process of loading the patch file into the address space of the first program process, the loader finds the address of the first vulnerability, changes the entry instruction of the first vulnerability to writable, and at the same time changes the entry instruction of the first vulnerability to jump to the code in patch file B that fixes the first vulnerability.
  • the tablet computer runs the first program, it runs to the machine code corresponding to the first vulnerability in the first program, and can be redirected to the position of the new code in the patch file B that fixes the first vulnerability. After the patch code for repairing the first vulnerability is executed, it returns to the original first program to continue running.
  • FIG. 6 is a schematic diagram of a scene of the method for patching according to the first method embodiment.
  • the implementation scenario may include: a mobile phone 102 , a router 103 , and a tablet computer 104 .
  • the mobile phone 102 and the tablet computer 104 can be in the same local area network by accessing the same Wi-Fi access point provided by the router 103 .
  • the first program in the mobile phone 102 is the version number A
  • the first program in the tablet computer 104 is the version number B.
  • the mobile phone 102 is a mounting device of the patch pool.
  • the patch pool For the description of the patch pool, reference may be made to the description about the patch pool in the foregoing description, which will not be repeated here.
  • the mobile phone 102 can receive the first patch code for repairing the first vulnerability in the first program from the cloud server side. Based on the version information of the mobile phone 102 itself, such as device-related information such as version number A, the mobile phone 102 machine-codes the explanatory patch code of the first patch, compiles it into the patch machine code A, and stores it.
  • the mobile phone 102 may also store a first mapping table.
  • the first mapping table may record a one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A.
  • the version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.
  • the mobile phone can obtain information such as the ID of the tablet computer in the same local area network, the version number B of the first program in the tablet computer, and so on.
  • the mobile phone queries the first mapping table, and the version number B corresponds to the offset B.
  • the mobile phone synthesizes the offset B corresponding to the version number B and the patch machine code A to form the patch machine code B, and generates a patch file B.
  • the patch file B is a patch that can be used to fix the first vulnerability whose first program is version B. document.
  • the mobile phone can send a broadcast in the local area network, and the broadcast message can include the mobile phone ID of the patch pool mounted, the tablet ID supported by the patch file B, the first program version number B supported by the patch file B, and so on.
  • the mobile phone can send the patch file B to the tablet computer side.
  • the tablet computer loads the patch file B, the patch takes effect, and the first vulnerability in the first program is repaired.
  • the interaction between the mobile phone and the smart speaker is used as an example for description.
  • Mobile phones can be used as devices to mount patch pools and machine-coded patches
  • smart speakers can be used as devices that need to obtain patches to fix bugs or upgrade product features.
  • a mobile phone is a terminal device with strong computing processing capability and sufficient internal storage space.
  • a smart speaker is a terminal device with weak computing processing power and small internal storage space.
  • the mobile phone and the smart speaker are in the same local area network.
  • the mobile phone can machine code the patch on the mobile phone side according to the version information of the smart speaker, generate a patch file in the form of machine code and store it on the mobile phone side.
  • the smart speaker When the smart speaker receives an interactive request for a file related to the vulnerability repaired by the patch, it can be forwarded to the mobile phone, and the mobile phone will read the file that has been patched to fix the vulnerability, and the mobile phone will send the interactive result or execute the instruction to the smart speaker.
  • the patch takes effect.
  • the device on which the patch pool is mounted and the device on which the machine-coded patch is mounted may not be the same device.
  • the laptop is the device on which the patch pool is mounted.
  • the laptop can obtain each patch from the cloud server and store it in the patch pool.
  • the patch pool is visible to all devices connected to the same LAN.
  • the mobile phone, smart speaker and laptop are in the same local area network.
  • the mobile phone can obtain a patch in the patch pool, and machine code the patch on the mobile phone side according to the version information of the smart speaker to generate a patch file in the form of machine code.
  • the interaction between the mobile phone and the smart speaker is only for an exemplary illustration, and does not constitute any limitation to the embodiments of the present application.
  • the devices that receive patches can also be smart watches, smart bracelets, smart desk lamps, smart headphones and other electronic devices with weak computing processing power or small internal storage space.
  • FIG. 7 shows another method flow of patching provided by an embodiment of the present application. Specifically, the following steps may be included:
  • the mobile phone and the smart speaker can be in the same local area network by accessing the same Wi-Fi access point provided by the same router, and the mobile phone and the smart speaker can establish a wireless communication connection between the two through the Wi-Fi access point. (may also be referred to as the first connection).
  • the local area network information such as the patch pool mounted on the mobile phone and the location of the patch pool can be visible to the smart speaker.
  • the mobile phone can obtain the first patch (also referred to as the first patch file) issued by the cloud server, and the first patch can be used to repair the first vulnerability of the first program.
  • the first patch also referred to as the first patch file
  • the patch pool may refer to one or more directories in which one or more patches are stored.
  • the directory can be set to be visible to other devices in the local area network, and for other devices not in the same local area network, the directory is accessible to other devices. its not visible.
  • the patch pool can be a directory on the mounted mobile device, such as /data/hotpatch/, and the properties of the directory can be set to be visible to other devices in the local area network. In this way, the storage location of the patch pool will be exposed in the throughout the local area network.
  • the code form of the first patch may be interpretive code or machine code, which is not limited in this application. If it is a patch file in the form of machine code, the cloud server needs to obtain the version information of the program in the device that needs to be patched before issuing the patch, and then perform machine coding in the cloud according to the version information, and then send it to the device side. No need to compile, you can run machine code directly.
  • the first patch may be actively pushed to the mobile phone after being generated by the cloud server, or may be issued according to the request of the mobile phone, which is not limited in this application.
  • the mobile phone compiles the code of the first patch into machine code A (also referred to as the first machine code).
  • the version information of the first program on different electronic devices may be different, and the version information may include information such as version name, version number, etc.
  • the version information of the first program in the mobile phone It can be called the first version information.
  • the version number of the first program of the mobile phone is version number A.
  • the mobile phone also stores a first mapping table, and the first mapping table may record the one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A.
  • the version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.
  • the mobile phone can obtain a certain version of the first program currently used by other electronic devices in the local area network, then the first mapping table can also record the information of the electronic device.
  • the ID of the electronic device may be a MAC number, an SN number of the electronic device, or other unique identification numbers of the electronic device different from other electronic devices, which are not limited in this application.
  • the mobile phone obtains information such as the ID of the smart speaker, the version number C of the first program in the smart speaker, and the like.
  • the ID of the smart speaker is the unique identification number of the smart speaker.
  • the ID of the smart speaker may be a MAC number, an SN number, or other unique identification numbers of the smart speaker that are different from other electronic devices, which are not limited in this application.
  • the version information of the first program in the smart speaker may be referred to as the second version information.
  • the version number of the first program of the smart speaker is version number C, which is different from the version number A of the first program in the mobile phone.
  • the mobile phone queries the first mapping table, and the version number C corresponds to the offset C (which may also be referred to as the first offset).
  • the mobile phone synthesizes the offset C corresponding to the version number C and the machine code A into the machine code C (also called the second machine code), and generates the patch file C (also called the second patch file), the patch file C It is a patch file that can be used to fix the first vulnerability whose first program is version C.
  • the manner of synthesizing the machine code C with the offset C and the machine code A may include, but is not limited to, a binary synthesis manner, a disk block synthesis manner, and a code relocation manner.
  • a binary synthesis manner a binary synthesis manner
  • a disk block synthesis manner a code relocation manner.
  • the mobile phone sends a broadcast in the local area network
  • the broadcast message may include the device ID (such as the mobile phone ID) of the patch pool mounted, the device ID (such as the smart speaker ID) supported by the patch file C, and the device ID supported by the patch file C.
  • the first program version number eg version number C
  • the device ID such as the mobile phone ID
  • the device ID such as the smart speaker ID
  • the first program version number eg version number C
  • the smart speaker responds to the broadcast of the mobile phone, and the response message may include the mobile phone ID, the smart speaker ID, the version number C, and the like.
  • the mobile phone obtains a file L in the smart speaker, where the file L is a file corresponding to the first program.
  • the patch file C is stored or read on the side of the mobile phone, and the patch file C does not need to be stored on the side of the smart speaker.
  • the file L may include one or more files, and the file L stores the content of the first program.
  • the mobile phone generates a file M, where the file M may be a file synthesized by the file L and the patch file C, and the file M in the mobile phone is associated with the file L in the smart speaker.
  • the mobile phone can obtain the file L corresponding to the first program in the smart speaker, and combine the patch file C and the file L into a file M on the mobile phone side, where the file M is one or more first program files for which the first vulnerability has been fixed.
  • the file M can be stored on the mobile phone side.
  • File M may also include one or more files.
  • the file L in the smart speaker receives an interaction request.
  • the smart speaker forwards the interactive request for the file L to the file M in the mobile phone.
  • the mobile phone reads the file M, generates an interaction result or instruction, and sends the interaction result or instruction to the smart speaker.
  • the smart speaker executes the interactive result or instruction, the first patch takes effect, and the first loophole of the first program of the smart speaker is repaired.
  • the mobile phone can send relevant instructions or interactive results to the smart speaker through the communication connection. After receiving the instruction or interaction result, the smart speaker executes related functions to fix the first loophole in the first program.
  • the smart speaker is disconnected from the local area network.
  • the file M cached in the mobile phone for solving the first vulnerability can continue to be saved in the mobile phone, and will continue to take effect when the smart speaker is connected to the local area network next time; the file M also It can be deleted when the network is disconnected, and the mobile phone will regenerate the file M when the smart speaker is connected to the local area network next time.
  • the file L in the smart speaker receives an interaction request.
  • the vulnerability repair on the side of the smart speaker needs to rely on the patch file provided by the mobile phone in the local area network, so the smart speaker needs to be connected to the network to repair the vulnerability. If the smart speaker is disconnected from the local area network, the patch file to fix the vulnerability cannot be obtained, and the corresponding vulnerability cannot be fixed.
  • FIG. 8 is a schematic diagram of a scene of the method for patching according to the second method embodiment.
  • the implementation scenario may include: a mobile phone 102 , a router 103 , and a smart speaker 107 .
  • the mobile phone 102 and the smart speaker 107 can be in the same local area network by accessing the same Wi-Fi access point provided by the router 103 .
  • the first program in the mobile phone 102 is version A
  • the first program in the smart speaker 107 is version C.
  • the mobile phone 102 is a mounting device of the patch pool.
  • the patch pool For the description of the patch pool, reference may be made to the description about the patch pool in the foregoing description, which will not be repeated here.
  • the mobile phone 102 may receive the first patch code for fixing the first vulnerability in the first program from the cloud server side. Based on the version information of the mobile phone 102 itself, such as device-related information such as version number A, the mobile phone 102 machine-codes the explanatory patch code of the first patch, compiles it into the patch machine code A, and stores it.
  • the mobile phone 102 may also store a first mapping table.
  • the first mapping table may record a one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A.
  • the version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.
  • the mobile phone can obtain information such as the ID of the smart speaker in the same local area network and the version number C of the first program in the smart speaker.
  • the mobile phone queries the first mapping table, and the version number C corresponds to the offset C.
  • the mobile phone synthesizes the offset C corresponding to the version number C and the patch machine code A into the patch machine code C, and generates a patch file C, which is a patch that can be used to fix the first vulnerability whose first program is version C. document.
  • the mobile phone can send a broadcast in the local area network, and the broadcast message can include the mobile phone ID of the patch pool mounted, the smart speaker ID supported by the patch file C, the first program version number C supported by the patch file C and so on.
  • the mobile phone can obtain the file L corresponding to the first program in the smart speaker, and synthesize the file L and the patch file C into the file M on the mobile phone side, and the file M is The file of the first vulnerability has been fixed and stored on the mobile phone side.
  • the interactive request will be forwarded to the file M.
  • the smart speaker forwards the interactive request for the file L to the file M in the mobile phone.
  • the mobile phone reads the file M, generates interactive results or instructions, and sends the interactive results or instructions to the smart speaker.
  • the smart speaker executes the interactive result or instruction, the first patch takes effect, and the first loophole of the first program of the smart speaker is fixed.
  • the first patch fails and the first vulnerability cannot be fixed.
  • FIG. 9A shows an exemplary user interface 901 .
  • User interface 901 may include a status bar 902, a calendar indicator 903, other application icons 904, a page indicator 905, and a tray 906 with icons of frequently used applications.
  • Status bar 902 may include: one or more signal strength indicators for mobile communication signals (also known as cellular signals), one or more signal strength indicators for wireless fidelity (Wi-Fi) signals, battery status indicators, etc.
  • signal strength indicators for mobile communication signals also known as cellular signals
  • Wi-Fi wireless fidelity
  • battery status indicators etc.
  • Calendar indicator 903 may be used to indicate the current time, such as date, day of the week, hour and minute information, and the like.
  • Other application icons 904 may be, for example, a music icon, a calculator icon, a browser icon, a settings icon, and the like.
  • the page indicator 905 may be used to indicate the application in which page the user is currently viewing. Users can swipe left and right in the area of other application icons to browse application icons in other pages.
  • a tray 906 with icons of commonly used applications may display: a camera icon, an address book icon, a phone icon, an information icon, and the like.
  • the user interface 901 exemplarily shown in FIG. 9A may be the home screen.
  • the electronic device may also include a home screen key.
  • the home screen key can be a physical key or a virtual key.
  • the home screen button can be used to receive the user's instruction and return the currently displayed UI to the home interface, so that it is convenient for the user to view the home screen at any time.
  • the above instruction may be an operation instruction for the user to press the home screen key once, or an operation instruction for the user to press the home screen key twice in a short period of time, or the user presses the home screen key for a predetermined period of time. operation instructions.
  • the home screen key may also be integrated with a fingerprint reader, so that when the user presses the home screen key, fingerprint collection and identification are performed accordingly.
  • FIG. 9A only exemplarily shows the user interface on the electronic device 100 , and should not constitute a limitation to the embodiments of the present application.
  • 9A and 9B show an exemplary user interface of the electronic device 100 when the mobile phone 102 obtains the relevant authority of the electronic device 100 in the local area network.
  • the electronic device 100 can display in the user interface 901 Prompt box 907, the prompt box 907 can be used to prompt the user whether to give the mobile phone 102 the corresponding permission.
  • the prompt information displayed in the prompt box 907 may be the text "Do you allow the mobile phone 102 in the network to obtain your device information?".
  • the prompt information may also be voice output from the electronic device 100 or other types of prompt information, etc., which is not limited in this application.
  • the prompt box 907 can also display corresponding controls, so that the user can choose whether to give the mobile phone 102 corresponding permissions.
  • the electronic device 100 may execute the option corresponding to the control to allow the mobile phone 102 to obtain information related to the electronic device 100 only this time, and to always allow the mobile phone 102 to obtain information related to the electronic device 100. Or reject the option of the mobile phone 102 to obtain the relevant information of the electronic device 100 .
  • the prompt box 907 may display an "Allow” control, an "Always Allow” control and a “Deny” control, and after detecting a user's touch operation (such as a click) on the "Always Allow” control, the electronic device 100 may perform a In this state, the mobile phone 102 is always allowed to obtain the instruction of the relevant information of the electronic device 100 .
  • the electronic device 100 may display a prompt box 908 on the user interface 901, the prompt box 908 It can be used to prompt the user whether to allow the mobile phone 102 to update the patch to the electronic device 100 .
  • the information displayed in the prompt box may be the text "Does the mobile phone 102 in the network allow the mobile phone 102 to update the patch for you?".
  • the prompt information may also be voice output from the electronic device 100 or other types of prompt information, etc., which is not limited in this application.
  • the prompt box 908 may also display corresponding controls for the user to select whether to allow the mobile phone 102 to update the patch to the electronic device 100 or not.
  • the electronic device 100 may execute the option corresponding to the control to only allow the mobile phone 102 to send patches to the electronic device 100 this time, and to always allow the mobile phone 102 to send the patch to the electronic device 100 this time.
  • the prompt box 908 may display an "Allow” control, an "Always Allow” control, and a “Deny” control, and upon detecting a user's touch operation (eg, a click) on the "Always Allow” control, the electronic device 100 may perform a The state always allows the mobile phone 102 to update the patch to the electronic device 100 instruction.
  • FIG. 10A , FIG. 10B , and FIG. 10C show user interfaces related to the technical effects exhibited after implementing the technical solutions of the present application.
  • FIG. 10A exemplarily shows an implementation scenario.
  • the implementation scenario may include: a mobile phone 102 , a smart watch 109 and a tablet computer 104 .
  • the mobile phone 102 and the smart watch 109 and the tablet computer 104 can be in the same local area network by accessing the same wireless access point, and establish a communication connection with each other.
  • the user interface 1001 of the mobile phone 102 may be displayed when the mobile phone 102 finds that the required patch is generated by the cloud server.
  • the user interface 1001 may include a title bar 1004, a program version update main interface 1005, and the like.
  • Title bar 1004 may include a current page indicator, and return navigation controls.
  • the current page indicator can be used to indicate the current page, for example, the text information "system update" can be used to indicate that the current page is used to display system update related information. Not limited to text information, the current page indicator may also be an icon.
  • Returning a navigation control can be used to listen for actions (such as touches) through the control. In response to this operation, the electronic device can return to the previous interface from the current interface.
  • the program version update main interface 1005 may display one or more version update related information items, and the one or more version update related information items may include: an electronic device discovers a new patch prompt item, a patch package size information item, an update time information item, Update log information entries, etc.
  • each item of version update related information in the program version update main interface 1005 there are corresponding titles and text descriptions.
  • the corresponding title is “New Patch Found”
  • the corresponding title of the patch package size information entry is "Patch Package”
  • the text description is the found new version number "Size: 2.32MB”
  • the update time The title corresponding to the information entry is "Update Time”
  • the text description is "Date: September 20, 2020”
  • the title corresponding to the update log information entry is "Update Log”
  • the text description is "This update adds system security fixes. Patches, Fix System Vulnerabilities” etc.
  • the program version update main interface 1005 may also include an "update” operation control 1006 and a “cancel” operation control 1007, which can be used to monitor operations (such as touch operations) through the controls. In response to the operation acting on "update” or “cancel", the electronic device will update the patch, or cancel the update patch.
  • the program version update page may display other program version update related information, including but not limited to, for example, third-party applications.
  • information items related to version update may be added, or information items related to version update may be decreased, which is not limited in this application.
  • the user interface 1002 of the smart watch 109 and the user interface 1003 of the tablet 104 may include some or all of the same interface elements (eg, status bar, calendar indicator, application icon, page indicator, and trays for commonly used application icons, etc.), which will not be repeated here.
  • interface elements eg, status bar, calendar indicator, application icon, page indicator, and trays for commonly used application icons, etc.
  • the user interface 1008 of the mobile phone 102 exemplarily shown in FIG. 10B can be the user interface displayed on the mobile phone 102 when receiving and downloading the patch issued by the cloud server.
  • the user interface 1008 can be used to prompt the user to download the patch from the cloud server The progress of the server downloading patches. For example, an icon 1009 may be displayed that informs the user that the patch is being downloaded and that the download progress is 25%.
  • the user interface 1008 may also display the text message "Downloading Patch" to remind the user that the patch is being downloaded. Not limited to text information, the prompt information may also be voice output from the mobile phone 102 or other types of prompt information, etc., which is not limited in this application.
  • the user interface 1008 may also display a cancel control 1010 for listening to touch operations (eg, clicks) acting on the control. In response to the "cancel" operation, the mobile phone 102 can cancel the patch download from the cloud-side server.
  • FIG. 10C exemplarily shows the user interface 1011 of the cell phone 102 , the user interface 1012 of the smart watch 109 , and the user interface 1013 of the tablet computer 104 .
  • the above user interface may prompt the user that, in this implementation scenario, the first vulnerabilities of different versions of the first program in the mobile phone 102 , the smart watch 109 and the tablet computer 104 have all been repaired.
  • the user interface 1011 may display the text prompt information "The first vulnerability has been fixed", and display the version number information "Version 10.0" of the first program possessed by the mobile phone 102, and the user interface 1012 may display the text prompt information "The first program” A bug has been fixed”, and the version number information “Version 8.0” of the first program owned by the smart watch 109 is displayed, and the user interface 1013 can display the text prompt information “The first bug has been fixed”, and display the tablet computer 104 The version number information "version 9.0" of the owned first program.
  • the prompt information may also be voice output by the electronic device or other types of prompt information, etc., which is not limited in this application.
  • the mobile phone 102 downloads the first patch to fix the first vulnerability from the cloud server. Machine code. Then the mobile phone can generate a new patch machine code according to the obtained machine code offset corresponding to the version 8.0 of the smart watch 109 and the version 9.0 of the tablet computer 104 .
  • the specific method for the tablet computer 104 to obtain the patch in the mobile phone 102 please refer to the method embodiment 1, and for the specific method for the smart watch 109 to obtain the patch in the mobile phone 102, please refer to the second method embodiment, which will not be repeated here.
  • the tablet 104 and the smart watch 109 located in the same local area network as the mobile phone 102 do not need to download the same patch from the cloud server repeatedly, so in FIG.
  • the smart watch 109 and the tablet computer 104 with different program versions in the same local area network will automatically repair the same vulnerability targeted by the patch.
  • repeated downloading of the same patch can be avoided, bandwidth is saved, and patching efficiency is improved.
  • FIGS. 9A , 9B, 10A, 10B, and 10C are only examples of some user interfaces, and do not constitute any limitation to other embodiments of the present application.
  • the term “when” may be interpreted to mean “if” or “after” or “in response to determining" or “in response to detecting" depending on the context.
  • the phrases “on determining" or “if detecting (the stated condition or event)” can be interpreted to mean “if determining" or “in response to determining" or “on detecting (the stated condition or event)” or “in response to the detection of (the stated condition or event)”.
  • the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware or any combination thereof.
  • software it can be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated.
  • the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media.
  • the usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like.
  • the process can be completed by instructing the relevant hardware by a computer program, and the program can be stored in a computer-readable storage medium.
  • the program When the program is executed , which may include the processes of the foregoing method embodiments.
  • the aforementioned storage medium includes: ROM or random storage memory RAM, magnetic disk or optical disk and other mediums that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The present application provides a patching method, a related apparatus, and a system. The method may comprise: a first electronic apparatus where a patch pool is mounted may acquire a first patch issued by a cloud server; the first electronic apparatus may compile the first patch into a first machine code on the basis of first version information of the apparatus itself; the first electronic apparatus may acquire second version information of a first program in a second electronic apparatus in the same local area network; the first electronic apparatus may quickly synthesize, according to a second offset corresponding to the second version information, a second machine code, and generate a second patch file; and the second electronic apparatus may acquire and run the second patch file or an instruction corresponding to the second patch file, such that a patch takes effect, and a first vulnerability in the first program of the second electronic apparatus is repaired. The technical solution of the present application is implemented to prevent a cloud server from repeatedly issuing a patch, and reduce consumption of the network bandwidth, thereby greatly improving repair efficiency of patches, and providing better user experience.

Description

打补丁的方法、相关设备及系统Patching method, related equipment and system

本申请要求于2020年11月30日提交中国专利局、申请号为202011377442.X、申请名称为“打补丁的方法、相关设备及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on November 30, 2020 with the application number 202011377442.X and the application name "Patching Method, Related Equipment and System", the entire contents of which are incorporated by reference in this application.

技术领域technical field

本申请涉及计算机技术领域,尤其涉及打补丁的方法、相关设备及系统。The present application relates to the field of computer technology, and in particular, to a patching method, related equipment and system.

背景技术Background technique

在用户使用电子设备的过程中,系统程序或应用程序可能会出现漏洞(bug)。现有技术针对该问题的解决方式,通常是云服务器向电子设备下发相应的补丁。在电子设备获取到该补丁后,安装该补丁,使得补丁生效,从而修复程序中相应的漏洞。During a user's use of an electronic device, a bug (bug) may appear in system programs or applications. The solution to this problem in the prior art is usually that the cloud server issues a corresponding patch to the electronic device. After the electronic device obtains the patch, install the patch to make the patch take effect, thereby fixing the corresponding loopholes in the program.

云服务器向电子设备下发补丁时,第一种方式是,云服务器可以向电子设备下发补丁的原始解释性代码,电子设备接收到补丁后,在电子设备侧进行机器码化,加载运行该补丁的机器码,补丁生效,程序bug被修复。使用第一种方式,云服务器可能会重复向不同电子设备下发补丁,耗费网络带宽,并且在电子设备侧进行补丁机器码化,补丁修复效率低。When the cloud server issues a patch to an electronic device, the first way is that the cloud server can issue the original interpretive code of the patch to the electronic device. After the electronic device receives the patch, it performs machine coding on the electronic device side, loads and runs the patch. The machine code of the patch, the patch takes effect, and the program bug is fixed. Using the first method, the cloud server may repeatedly issue patches to different electronic devices, which consumes network bandwidth, and the patches are machine-coded on the electronic device side, resulting in low patch repair efficiency.

第二种方式是,云服务器可以根据获取到的需要修复bug的程序的版本等信息,在云服务器侧对补丁进行机器码化,然后将该补丁的机器码下发至电子设备中,电子设备可以直接加载运行该补丁的机器码,补丁生效,程序bug被修复。在第二种方式中,电子设备直接运行机器码化的补丁文件,相对第一种方式,补丁的修复效率得到提高,但是该机器码化的补丁文件会与特定版本绑定。但是不同的电子设备上程序的版本可能并不相同,所以云服务器会根据不同版本的程序对应下发不同的补丁。使用第二种方式,会导致云服务器针对同一个bug的补丁重复进行机器码化,在下发补丁时会耗费大量的网络带宽,影响补丁的修复效率,影响用户体验。The second way is that the cloud server can machine code the patch on the cloud server side according to the obtained information such as the version of the program that needs to fix the bug, and then send the machine code of the patch to the electronic device. You can directly load the machine code running the patch, the patch will take effect, and program bugs will be fixed. In the second method, the electronic device directly runs the machine-coded patch file. Compared with the first method, the patch repair efficiency is improved, but the machine-coded patch file is bound to a specific version. However, the versions of the programs on different electronic devices may be different, so the cloud server will issue different patches according to the programs of different versions. Using the second method will cause the cloud server to repeatedly machine code the patch for the same bug, which consumes a lot of network bandwidth when delivering the patch, affects the repair efficiency of the patch, and affects the user experience.

发明内容SUMMARY OF THE INVENTION

本申请的目的在于提供一种打补丁的方法、相关设备及系统,可以解决在不同的电子设备需要修复同一个程序漏洞的情况下,云服务器多次重复下发补丁的问题,减少了网络带宽的耗费,并且在终端侧可以快速合成适应于不同电子设备的补丁机器码,大大提升了补丁修复的效率,给用户带来更为良好的使用体验。The purpose of the present application is to provide a patching method, related equipment and system, which can solve the problem that the cloud server repeatedly distributes patches for multiple times when different electronic devices need to repair the same program loophole, reducing network bandwidth. In addition, the patch machine code suitable for different electronic devices can be quickly synthesized on the terminal side, which greatly improves the efficiency of patch repair and brings a better user experience to the user.

上述目标和其他目标将通过独立权利要求中的特征来达成。进一步的实现方式在从属权利要求、说明书和附图中体现。The above-mentioned objects and other objects are achieved by the features of the independent claims. Further implementations are embodied in the dependent claims, the description and the drawings.

第一方面,本申请提供了一种打补丁的方法,该方法可以包括:第一电子设备可以与第二电子设备建立第一连接,然后,第一电子设备可以获取第一补丁文件,该第一补丁文件可以用于第一程序中的第一漏洞,该第一漏洞存在于第二电子设备的第一程序中。该电子设备可以根据第一程序的第一版本信息,将该第一补丁编译为第一机器码,接下来,该第一电子设备可以将该第一机器码和第一偏移量合成为第二机器码,并且可以将该第二机器码烧录生成第二补丁文件。其中,该第一偏移量是根据第二版本信息所确定的,该第二版本信息是第 二电子设备中第一程序中的版本信息,该第二版本信息是第一电子设备通过第一连接从第二电子设备处获取到的,该第二补丁文件可以用于修复版本信息是第二版本信息的第一程序中的第一漏洞。In a first aspect, the present application provides a patching method, the method may include: a first electronic device may establish a first connection with a second electronic device, and then the first electronic device may obtain a first patch file, the first A patch file may be used for the first vulnerability in the first program, the first vulnerability existing in the first program of the second electronic device. The electronic device may compile the first patch into the first machine code according to the first version information of the first program, and then the first electronic device may synthesize the first machine code and the first offset into the first machine code. Second machine code, and the second machine code can be burned to generate a second patch file. Wherein, the first offset is determined according to the second version information, the second version information is the version information in the first program in the second electronic device, and the second version information is the first electronic device through the first The connection is obtained from the second electronic device, and the second patch file can be used to repair the first vulnerability in the first program whose version information is the second version information.

在本申请中,第一电子设备可以是智能手机、平板电脑、笔记本电脑、台式电脑或者其他类型的电子设备。该第一电子设备可以具备较强的计算处理能力及较充足的内部存储空间。第一电子设备可以是补丁池的挂载设备,第一电子设备还可以是将补丁编译为机器码的设备。并且也具有蓝牙(bluetooth,BT)模块、和/或无线局域网络(wireless local area networks,WLAN)模块。其中,蓝牙(BT)模块可以提供包括经典蓝牙(蓝牙2.1标准)或蓝牙低功耗(bluetooth low energy,BLE)中一项或多项蓝牙通信的解决方案。WLAN模块可以提供包括无线保真直连(wireless fidelity direct,Wi-Fi direct)、无线保真局域网(wireless fidelity local area networks,Wi-Fi LAN)或无线保真软件接入点(wireless fidelity software access point,Wi-Fi softAP)中一项或多项WLAN通信的解决方案。In this application, the first electronic device may be a smart phone, a tablet computer, a notebook computer, a desktop computer or other types of electronic devices. The first electronic device may have relatively strong computing processing capability and relatively sufficient internal storage space. The first electronic device may be a mounting device of the patch pool, and the first electronic device may also be a device that compiles the patch into machine code. And also has a Bluetooth (bluetooth, BT) module, and/or a wireless local area network (wireless local area networks, WLAN) module. Among them, the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1 standard) or Bluetooth low energy (bluetooth low energy, BLE). The WLAN module can provide wireless fidelity direct (wireless fidelity direct, Wi-Fi direct), wireless fidelity local area networks (wireless fidelity local area networks, Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point) , Wi-Fi softAP) in one or more WLAN communication solutions.

在本申请中,第二电子设备可以是智能手机、平板电脑、笔记本电脑等具备较强的计算处理能力及较充足的内部存储空间等类型的电子设备,第二电子设备还可以是智能手表、智能手环、智能音箱、智能耳机等具备较弱的计算处理能力或较小的内部存储空间等类型的电子设备。第二电子设备可以具有蓝牙(bluetooth,BT)模块、和/或无线局域网络(wireless local area networks,WLAN)模块。其中,蓝牙(BT)模块可以提供包括经典蓝牙(蓝牙2.1标准)或蓝牙低功耗(bluetooth low energy,BLE)中一项或多项蓝牙通信的解决方案。WLAN模块可以提供包括无线保真直连(wireless fidelity direct,Wi-Fi direct)、无线保真局域网(wireless fidelity local area networks,Wi-Fi LAN)或无线保真软件接入点(wireless fidelity software access point,Wi-Fi softAP)中一项或多项WLAN通信的解决方案。In this application, the second electronic device may be a smart phone, a tablet computer, a notebook computer and other electronic devices with strong computing processing capability and sufficient internal storage space, etc., and the second electronic device may also be a smart watch, Smart bracelets, smart speakers, smart headphones and other electronic devices with weak computing processing power or small internal storage space. The second electronic device may have a bluetooth (BT) module, and/or a wireless local area networks (WLAN) module. Among them, the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1 standard) or Bluetooth low energy (bluetooth low energy, BLE). The WLAN module can provide wireless fidelity direct (wireless fidelity direct, Wi-Fi direct), wireless fidelity local area networks (wireless fidelity local area networks, Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point) , Wi-Fi softAP) in one or more WLAN communication solutions.

实施第一方面的方法,可以避免在不同的电子设备需要修复同一个程序漏洞的情况下,云服务器多次重复下发补丁的问题,减少了网络带宽的耗费,并且在终端侧可以快速合成适应于不同电子设备的补丁机器码,大大提升了补丁修复的效率,给用户带来更为良好的使用体验。Implementing the method of the first aspect can avoid the problem that the cloud server repeatedly distributes patches when different electronic devices need to fix the same program vulnerability, reduces the consumption of network bandwidth, and can be quickly synthesized and adapted on the terminal side The patch machine code for different electronic devices greatly improves the efficiency of patch repair and brings users a better experience.

结合第一方面,在一些实施例中,该第一偏移量可以是根据第一映射表中记录的第二版本信息与该第一偏移量的对应关系所确定。With reference to the first aspect, in some embodiments, the first offset may be determined according to the correspondence between the second version information recorded in the first mapping table and the first offset.

结合第一方面,在一些实施例中,第一电子设备可以向第二电子设备发送第二补丁文件。该第二补丁文件可用于与第二电子设备中的第一程序文件合称为第二程序文件。该第一程序文件是第二电子设备中未修复的第一漏洞的第一程序的可执行文件,该第二程序文件是第二电子设备中已修复该第一漏洞的第一程序的可执行文件。In conjunction with the first aspect, in some embodiments, the first electronic device may send the second patch file to the second electronic device. The second patch file can be used together with the first program file in the second electronic device to be collectively referred to as the second program file. The first program file is the executable file of the first program of the unfixed first vulnerability in the second electronic device, and the second program file is the executable file of the first program of the second electronic device that has repaired the first vulnerability document.

结合第一方面,在一些实施例中,当第二电子设备收到的对于第一程序文件的交互请求时,第一电子设备可以通过第一连接接收到对于第二程序文件的交互请求,其中,该第一程序文件可以是第二电子设备中未修复第一漏洞的第一程序的可执行文件,该第二程序文件可以是第一电子设备将该第一程序文件与该第二补丁文件合成得到的,该第二程序文件是已修复该第一漏洞的该第一程序的可执行文件,第二电子设备上的该第一程序文件可以关联与该第一电子设备上的该第二程序文件。第一电子设备可以读取所述第二程序文件,生成交互结果或可执行指令,并可以通过所述第一连接向第二电子设备发送交互结果或可执行指令。With reference to the first aspect, in some embodiments, when the second electronic device receives the interaction request for the first program file, the first electronic device may receive the interaction request for the second program file through the first connection, wherein , the first program file may be the executable file of the first program that does not repair the first vulnerability in the second electronic device, and the second program file may be the first program file and the second patch file of the first electronic device Synthesized, the second program file is the executable file of the first program that has repaired the first vulnerability, and the first program file on the second electronic device can be associated with the second program file on the first electronic device. program files. The first electronic device may read the second program file, generate interactive results or executable instructions, and may send the interactive results or executable instructions to the second electronic device through the first connection.

结合第一方面,在一些实施例中,在第一电子设备生成第二补丁文件之后,第一电子设备可以发送广播信息,该广播信息可以包括:第一电子设备的身份标识号、第二电子设备的身份标识号、第二补丁文件所适用的第二版本信息。在接收到第二电子设备响应于该广播信 息的应答信息,第一电子设备可以确定第二补丁文件为第二电子设备用于修复第一程序的第一漏洞的补丁文件,应答信息可以包括:第一电子设备的身份标识号、第二电子设备的身份标识号、第二电子设备中第一程序的第二版本信息。With reference to the first aspect, in some embodiments, after the first electronic device generates the second patch file, the first electronic device may send broadcast information, where the broadcast information may include: the identification number of the first electronic device, the second electronic device The device identification number and the second version information to which the second patch file applies. After receiving the response information from the second electronic device in response to the broadcast information, the first electronic device may determine that the second patch file is a patch file used by the second electronic device to repair the first vulnerability of the first program, and the response information may include: The identification number of the first electronic device, the identification number of the second electronic device, and the second version information of the first program in the second electronic device.

第二方面,本申请提供了另一种打补丁的方法,该方法可以包括:第一电子设备可以与第二电子设备建立第一连接。该第一电子设备可以获取第一补丁文件,该第一补丁文件可以用于修复第一程序的第一漏洞,该第一漏洞存在于第二电子设备的第一程序中。然后,第一电子设备根据第一程序的第一版本信息,将该第一补丁编译为第一机器码。第一电子设备将该第一机器码与第一偏移量合成为第二机器码,并将该第二机器码烧录生成第二补丁文件。其中,该第一偏移量可以是根据第二版本信息所确定的,该第二版本信息可以是第二电子设备中第一程序的版本信息,该第二版本信息可以是第一电子设备通过第一连接从第二电子设备处获取到的,该第二补丁文件用于修复版本信息为第二版本信息的第一程序的第一漏洞。In a second aspect, the present application provides another patching method, the method may include: the first electronic device may establish a first connection with the second electronic device. The first electronic device can acquire a first patch file, and the first patch file can be used to repair a first vulnerability of the first program, where the first vulnerability exists in the first program of the second electronic device. Then, the first electronic device compiles the first patch into the first machine code according to the first version information of the first program. The first electronic device synthesizes the first machine code and the first offset into a second machine code, and burns the second machine code to generate a second patch file. Wherein, the first offset may be determined according to second version information, the second version information may be version information of the first program in the second electronic device, and the second version information may be the first electronic device through The first connection is obtained from the second electronic device, and the second patch file is used to repair the first vulnerability of the first program whose version information is the second version information.

实施第二方面的方法,可以避免在不同的电子设备需要修复同一个程序漏洞的情况下,云服务器多次重复下发补丁的问题,减少了网络带宽的耗费,并且在终端侧可以快速合成适应于不同电子设备的补丁机器码,大大提升了补丁修复的效率,给用户带来更为良好的使用体验。Implementing the method of the second aspect can avoid the problem that the cloud server repeatedly issues patches many times when different electronic devices need to fix the same program vulnerability, reduces the consumption of network bandwidth, and can be quickly synthesized and adapted on the terminal side The patch machine code for different electronic devices greatly improves the efficiency of patch repair and brings users a better experience.

结合第二方面,在一些实施例中,该第一偏移量可以是根据第一映射表中记录的第二版本信息与该第一偏移量的对应关系所确定。With reference to the second aspect, in some embodiments, the first offset may be determined according to the correspondence between the second version information recorded in the first mapping table and the first offset.

结合第二方面,在一些实施例中,第二电子设备可以接收第一电子设备所生成的第二补丁文件。第二电子设备将第一程序文件与该第二补丁文件合成为第二程序文件,其中,该第一程序文件是该第二电子设备中未修复该第一漏洞的该第一程序的可执行文件,该第二程序文件是该第二电子设备中已修复该第一漏洞的该第一程序的可执行文件。In conjunction with the second aspect, in some embodiments, the second electronic device may receive the second patch file generated by the first electronic device. The second electronic device synthesizes the first program file and the second patch file into a second program file, wherein the first program file is the executable of the first program in the second electronic device that does not fix the first vulnerability file, the second program file is the executable file of the first program in the second electronic device that has fixed the first vulnerability.

结合第二方面,在一些实施例中,在第二电子设备收到对于第一程序文件的交互请求后,该第二电子设备可以通过该第一连接将该交互请求转发给该第一电子设备的第二程序文件,其中,该第一程序文件是该第二电子设备中未修复该第一漏洞的该第一程序的可执行文件,该第二程序文件可以是该第一电子设备将该第一程序文件与该第二补丁文件合成得到的,该第二程序文件是已修复该第一漏洞的该第一程序的可执行文件,该第二电子设备上的该第一程序文件可以关联与该第一电子设备上的该第二程序文件。然后,该第一电子设备可以读取该第二程序文件,生成交互结果或可执行指令,并可以通过该第一连接向该第二电子设备发送该交互结果或可执行指令。响应于该交互结果或可执行指令,该第二电子设备可以运行该第一漏洞已被修复的该第一程序。In combination with the second aspect, in some embodiments, after the second electronic device receives the interaction request for the first program file, the second electronic device may forward the interaction request to the first electronic device through the first connection The second program file, wherein the first program file is the executable file of the first program in the second electronic device that does not fix the first vulnerability, and the second program file can be the first electronic device. The first program file and the second patch file are synthesized, the second program file is the executable file of the first program that has repaired the first vulnerability, and the first program file on the second electronic device can be associated with the second program file on the first electronic device. Then, the first electronic device can read the second program file, generate an interaction result or executable instruction, and can send the interaction result or executable instruction to the second electronic device through the first connection. In response to the interaction result or the executable instruction, the second electronic device may run the first program in which the first vulnerability has been fixed.

结合第二方面,在一些实施例中,在第一电子设备生成第二补丁文件之后,该第一电子设备可以发送广播信息,该广播信息可以包括:该第一电子设备的身份标识号、该第二电子设备的身份标识号、该第二补丁文件所适用的该第二版本信息。响应于该广播信息,该第二电子设备可以向该第一电子设备发送应答信息,该应答信息可以包括:该第一电子设备的身份标识号、该第二电子设备的身份标识号、该第二电子设备中该第一程序的该第二版本信息。该第一电子设备可以确定该第二补丁文件为该第二电子设备用于修复该第一程序的第一漏洞的补丁文件。With reference to the second aspect, in some embodiments, after the first electronic device generates the second patch file, the first electronic device may send broadcast information, and the broadcast information may include: the identification number of the first electronic device, the The identification number of the second electronic device, and the second version information to which the second patch file applies. In response to the broadcast information, the second electronic device may send response information to the first electronic device, and the response information may include: the identification number of the first electronic device, the identification number of the second electronic device, the first electronic device The second version information of the first program in the two electronic devices. The first electronic device may determine that the second patch file is a patch file used by the second electronic device to repair the first vulnerability of the first program.

第三方面,本申请提供了一种电子设备,该电子设备可以包括:通信装置、存储器以及耦合于该存储器的处理器,多个应用程序,以及一个或多个程序。在该处理器在执行一个或多个该程序时,该电子设备可以实现第一方面和/或第二方面中电子设备所具备的任一功能,这里不再赘述。In a third aspect, the present application provides an electronic device, which may include: a communication device, a memory and a processor coupled to the memory, a plurality of application programs, and one or more programs. When the processor executes one or more of the programs, the electronic device may implement any function of the electronic device in the first aspect and/or the second aspect, which will not be repeated here.

第四方面,本申请提供可一种计算机可读介质,该存储介质中可以存储有指令。当该指令在电子设备上运行时,可以使得电子设备执行第一方面和/或第二方面中的任一项功能,这里不再赘述。In a fourth aspect, the present application provides a computer-readable medium in which instructions can be stored. When the instruction is executed on the electronic device, the electronic device can be made to perform any function of the first aspect and/or the second aspect, which will not be repeated here.

实施本申请的技术方案,可以避免在不同的电子设备需要修复同一个程序漏洞的情况下,云服务器多次重复下发补丁的问题,减少了网络带宽的耗费,并且在终端侧可以快速合成适应于不同电子设备的补丁机器码,大大提升了补丁修复的效率,给用户带来更为良好的使用体验。Implementing the technical solution of the present application can avoid the problem that the cloud server repeatedly distributes patches when different electronic devices need to fix the same program loophole, reduces the consumption of network bandwidth, and can quickly synthesize and adapt to the terminal side The patch machine code for different electronic devices greatly improves the efficiency of patch repair and brings users a better experience.

附图说明Description of drawings

图1是本申请实施例所提供的一种通信系统的架构示意图;FIG. 1 is a schematic diagram of the architecture of a communication system provided by an embodiment of the present application;

图2是本申请实施例所提供的一种电子设备的硬件结构示意图;2 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application;

图3是本申请实施例提供的一种电子设备的软件框架图;3 is a software framework diagram of an electronic device provided by an embodiment of the present application;

图4是本申请实施例提供的一种补丁机器码化的示意图;4 is a schematic diagram of a patch machine coding provided by an embodiment of the present application;

图5是本申请实施例提供的一种打补丁的方法的流程图;5 is a flowchart of a method for patching provided by an embodiment of the present application;

图6是本申请实施例提供的一种打补丁的方法的场景示意图;6 is a schematic diagram of a scenario of a method for patching provided by an embodiment of the present application;

图7是本申请实施例提供的另一种打补丁的方法的流程图;7 is a flowchart of another method for patching provided by an embodiment of the present application;

图8是本申请实施例提供的另一种打补丁的方法的场景示意图;8 is a schematic diagram of a scenario of another method for patching provided by an embodiment of the present application;

图9A是本申请实施例提供的一种用户界面示意图;9A is a schematic diagram of a user interface provided by an embodiment of the present application;

图9B是本申请实施例提供的一种用户界面示意图;9B is a schematic diagram of a user interface provided by an embodiment of the present application;

图10A是本申请实施例提供的一种用户界面示意图;10A is a schematic diagram of a user interface provided by an embodiment of the present application;

图10B是本申请实施例提供的一种用户界面示意图;10B is a schematic diagram of a user interface provided by an embodiment of the present application;

图10C是本申请实施例提供的一种用户界面示意图。FIG. 10C is a schematic diagram of a user interface provided by an embodiment of the present application.

具体实施方式Detailed ways

本申请以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请得到说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括复数表达形式,除非其上下文中明确地有相反指示。还应当理解,本申请中使用的术语“和/或”是指并包含一个或多个所列出项目的任何或所有可能组合。在本申请实施例中,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations of the present application. As used in the specification and appended claims of this application, the singular expressions "a," "an," "the," "above," "the," and "the" are intended to also Plural expressions are included unless the context clearly dictates otherwise. It will also be understood that, as used in this application, the term "and/or" refers to and includes any and all possible combinations of one or more of the listed items. In the embodiments of the present application, the terms "first" and "second" are only used for description purposes, and cannot be understood as implying or implying relative importance or implying the number of indicated technical features. Therefore, the features defined with "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, the "multiple" The meaning is two or more.

本申请实施例提供了通信系统,该系统可以包括多个电子设备,多个电子设备之间可以通过接入同一个局域网建立通信连接并通过该通信连接进行数据交互。其中,第一电子设备可以是智能手机、平板电脑、笔记本电脑、台式电脑或者其他类型的电子设备,本申请对此不作任何限制。该第一电子设备可以具备较强的计算处理能力及较充足的内部存储空间。第一电子设备可以是补丁池的挂载设备,第一电子设备还可以是将补丁编译为机器码的设备。第一电子设备可以为局域网中第二电子设备提供编译好的补丁机器码。第二电子设备可以是智能手机、平板电脑、笔记本电脑等具备较强的计算处理能力及较充足的内部存储空间等类型的电子设备,第二电子设备还可以是智能手表、智能手环、智能音箱、智能耳机等具备较 弱的计算处理能力或较小的内部存储空间等类型的电子设备,本申请对此不作特殊限制。第二电子设备可以通过局域网连接从第一电子设备接收补丁,或者从第一电子设备接收指令,并执行相应功能,修复补丁所针对的漏洞。第一电子设备和第二电子设备可以搭载

Figure PCTCN2021133755-appb-000001
Figure PCTCN2021133755-appb-000002
或者其他类型的操作系统,本申请同样对此不作限制。 The embodiments of the present application provide a communication system, which may include multiple electronic devices, and a communication connection may be established between the multiple electronic devices by accessing the same local area network, and data interaction may be performed through the communication connection. Wherein, the first electronic device may be a smart phone, a tablet computer, a notebook computer, a desktop computer or other types of electronic devices, which is not limited in this application. The first electronic device may have relatively strong computing processing capability and relatively sufficient internal storage space. The first electronic device may be a mounting device of the patch pool, and the first electronic device may also be a device that compiles the patch into machine code. The first electronic device can provide the compiled patch machine code for the second electronic device in the local area network. The second electronic device may be a smart phone, a tablet computer, a notebook computer and other electronic devices with strong computing processing capability and sufficient internal storage space, etc. The second electronic device may also be a smart watch, a smart bracelet, a smart Electronic devices such as speakers and smart earphones with weak computing processing capability or small internal storage space, etc., are not particularly limited in this application. The second electronic device may receive a patch from the first electronic device through a local area network connection, or receive an instruction from the first electronic device, and execute a corresponding function to repair the vulnerability targeted by the patch. The first electronic device and the second electronic device can carry
Figure PCTCN2021133755-appb-000001
Figure PCTCN2021133755-appb-000002
Or other types of operating systems, which are also not limited in this application.

本申请实施例还提供了打补丁的方法,解决了云服务器对同一补丁重复多次下发至不同电子设备上的问题。该打补丁的方法可以应用于本申请实施例提供的通信系统及电子设备上。在本申请提供的打补丁的方法中,补丁池所挂载的第一电子设备可以获取到云服务器下发的第一补丁。第一补丁可以用于修复第一程序的第一漏洞,其中,第一补丁可以是解释性补丁代码,该解释性补丁代码是以计算机高级语言(如C语言、Python等)所编写的源程序,该解释性补丁代码与电子设备及版本信息无关,因此可以做到跨设备运行。第一电子设备可以基于本设备中第一程序的第一版本信息将该解释性补丁代码编译为第一机器码。在同一个局域网中,其他电子设备的第一程序的版本信息可能不尽相同,因此,补丁机器码也会有所不同。例如同一个函数接口,不同程序版本对应的偏移地址不同,因此对于同一个解释性补丁代码,针对不同的电子设备,其补丁的机器码可能具有一定的差异,该差异可以体现在某些绝对地址的偏移量不同中。补丁池中可以记录有第一映射表,该第一映射表中可以记录有第一程序的不同版本和偏移量之间的一一对应关系。The embodiment of the present application also provides a method for applying patches, which solves the problem that the cloud server repeatedly distributes the same patch to different electronic devices. The patching method can be applied to the communication system and the electronic device provided by the embodiments of the present application. In the patching method provided in this application, the first electronic device mounted in the patch pool can obtain the first patch issued by the cloud server. The first patch can be used to repair the first vulnerability of the first program, wherein the first patch can be an interpretive patch code, and the interpretive patch code is a source program written in a high-level computer language (such as C language, Python, etc.). , the explanatory patch code is independent of electronic device and version information, so it can be run across devices. The first electronic device may compile the interpretive patch code into the first machine code based on the first version information of the first program in the device. In the same local area network, the version information of the first program of other electronic devices may not be the same, so the patch machine codes will also be different. For example, for the same function interface, the offset addresses corresponding to different program versions are different. Therefore, for the same interpretive patch code, for different electronic devices, the patched machine code may have a certain difference. The difference can be reflected in some absolute The offset of the address is different. A first mapping table may be recorded in the patch pool, and a one-to-one correspondence between different versions of the first program and offsets may be recorded in the first mapping table.

第一电子设备可以获取到同一个局域网中第二电子设备的ID、第二电子设备中第一程序的第二版本信息。第一电子设备可以根据第一映射表中查询得到的第二版本信息对应的第二偏移量,快速合成第二机器码并生成第二补丁文件,第二补丁文件是可以用于修复第二电子设备中第一程序的第一漏洞的补丁文件。第二电子设备可以获取第二补丁文件或第二补丁文件对应的指令并运行,补丁生效,第二电子设备的第一程序中的第一漏洞被修复。The first electronic device can acquire the ID of the second electronic device in the same local area network and the second version information of the first program in the second electronic device. The first electronic device can quickly synthesize the second machine code and generate a second patch file according to the second offset corresponding to the second version information obtained by querying in the first mapping table, and the second patch file can be used to repair the second version. A patch file for the first vulnerability of the first program in the electronic device. The second electronic device can obtain the second patch file or an instruction corresponding to the second patch file and run it, the patch takes effect, and the first loophole in the first program of the second electronic device is repaired.

实施本申请实施例的技术方案,在不同的电子设备需要修复同一个程序漏洞的情况下,云服务器只需要下发一次补丁至局域网中第一电子设备上,然后该补丁可以快速同步到同一局域网中的其他电子设备上。因此,实施本申请技术方案可以避免云服务器重复多次下发补丁,减少了网络带宽的耗费,并且在终端侧可以快速合成适应于不同电子设备的补丁机器码,大大提升了补丁修复的效率,给用户带来更为良好的使用体验。Implementing the technical solutions of the embodiments of the present application, when different electronic devices need to repair the same program vulnerability, the cloud server only needs to issue a patch to the first electronic device in the local area network, and then the patch can be quickly synchronized to the same local area network. on other electronic devices. Therefore, the implementation of the technical solution of the present application can avoid the cloud server from repeatedly issuing patches for many times, reduce the consumption of network bandwidth, and can quickly synthesize the patch machine code suitable for different electronic devices on the terminal side, which greatly improves the efficiency of patch repair. Bring a better user experience to users.

下面,介绍一些与本申请相关的术语及概念。Below, some terms and concepts related to this application are introduced.

补丁(patch)是指针对于大型软件系统或应用程序在使用过程中暴露的问题而发布的解决问题的小程序。补丁可用于修复一个或多个软件漏洞,例如,补丁可以修复包括但不限于应用程序、应用框架、内核、硬件驱动等一项或多项漏洞。补丁也可以用于增加新的产品特性或功能。A patch refers to a small program released to solve the problems exposed in the use of large software systems or applications. A patch can be used to fix one or more software vulnerabilities, for example, a patch can fix one or more vulnerabilities including but not limited to applications, application frameworks, kernels, hardware drivers, etc. Patches can also be used to add new product features or functionality.

补丁池(patch pool)可以是存储有一个或多个补丁文件的一个或多个目录,比如该补丁池在终端设备中的存储位置可以是目录/data/hotpatch等,本申请对此不作限制。通常补丁池可以挂载在具备较充足内部存储空间的终端设备上。如果补丁池被设置了具有网络属性,则该补丁池对于同一局域网内的其他电子设备是可见的,而补丁池的存储位置对于非该局域网的电子设备来说不可见。该补丁池所在目录还可以设有相应的安全保护机制,除某些具有写权限、修改权限和/或其他相关权限的特定应用外,局域网内的其他电子设备或其他应用,对于该目录只有只读权限,而不能对该目录进行写入和/或修改等操作。The patch pool (patch pool) may be one or more directories in which one or more patch files are stored. For example, the storage location of the patch pool in the terminal device may be the directory /data/hotpatch, etc., which is not limited in this application. Usually, the patch pool can be mounted on a terminal device with sufficient internal storage space. If the patch pool is set to have a network attribute, the patch pool is visible to other electronic devices in the same local area network, and the storage location of the patch pool is invisible to electronic devices that are not in the local area network. The directory where the patch pool is located can also be provided with a corresponding security protection mechanism. Except for some specific applications with write permissions, modification permissions and/or other related permissions, other electronic devices or other applications in the local area network have only limited access to this directory. read permission, but cannot write and/or modify the directory.

补丁生成与生效的相关设备,主要涉及到服务器和终端设备。服务器可包括补丁拍包工具、补丁包归档、补丁包发布等。其中,补丁拍包工具为服务器后台运行的脚本,把补丁文 件打包到一个压缩文件中,这个压缩文件内部各个文件的整体布局为补丁包特有。补丁包归档用于在补丁拍包工具生成补丁包之后将补丁包放置到指定的归档地址,用于后续服务器获取补丁包。补丁包发布用于服务器将补丁文件下发给终端设备。终端设备可以包括补丁包下载、补丁引擎、补丁包升级及补丁分区等。其中,补丁包下载用于接收服务器下发的补丁包。补丁包升级指用户在手机上搜索到补丁包,并确认统一下载补丁包后,补丁引擎进行下载、校验、安装补丁包的操作。补丁引擎封装了各种类型的业务逻辑,包括补丁文件的校验,能使补丁生效、撤销异常补丁等功能。补丁分区为终端设备硬盘上的一块空间地址,补丁包中二进制补丁镜像可以被烧录到该分区中。The related devices for patch generation and taking effect mainly involve servers and terminal devices. The server may include a patch package tool, a patch package archive, a patch package release, and the like. Among them, the patch package tool is a script running in the background of the server, which packages the patch files into a compressed file, and the overall layout of each file in the compressed file is unique to the patch package. Patch package archiving is used to place the patch package in the specified archive address after the patch package tool generates the patch package, so that the subsequent server can obtain the patch package. Patch package release is used by the server to deliver patch files to terminal devices. The terminal device may include patch package download, patch engine, patch package upgrade, and patch partition. The patch package download is used to receive the patch package delivered by the server. Patch package upgrade means that after the user searches for the patch package on the mobile phone and confirms that the patch package is downloaded uniformly, the patch engine downloads, verifies, and installs the patch package. The patch engine encapsulates various types of business logic, including verification of patch files, enabling patches to take effect, and undoing abnormal patches. The patch partition is a space address on the hard disk of the terminal device, and the binary patch image in the patch package can be burned into this partition.

计算机语言(computer language)是指用于人与计算机之间通讯的语言。计算机语言是人与计算机之间传递信息的媒介。计算机系统最大特征是指令通过一种语言传达给机器。为了使电子计算机进行各种工作,就需要一套用以编写计算机程序的数字、字符和语法规则,由这些字符和语法规则组成计算机各种指令,即为计算机语言。计算机语言具有高级语言和低级语言之分。高级语言是比较接近自然语言和数学公式的编程,例如,C语言,python语言,java语言、PHP语言等。高级语言基本脱离了机器的硬件系统,用人们更容易理解的方式编写程序。编写的程序称之为源程序。低级语言分为机器语言和汇编语言,这两种语言都是面向机器的语言,和具体机器的指令系统密切相关。机器语言是用二进制代码表示的计算机能直接识别和执行的一种机器指令的集合。即,机器语言是一种指令集的体系,这种指令集称机器码,是电脑的CPU可以直接解读的数据。汇编语言的主体是汇编指令。汇编指令和机器指令的差别在于指令的表示方法上,汇编指令是机器指令便于记忆的书写格式。Computer language refers to the language used for communication between humans and computers. Computer language is a medium for transferring information between humans and computers. The biggest characteristic of a computer system is that instructions are communicated to the machine through a language. In order to make the electronic computer perform various tasks, a set of numbers, characters and grammar rules for writing computer programs are needed. These characters and grammar rules form various instructions of the computer, that is, the computer language. Computer languages are divided into high-level languages and low-level languages. High-level languages are programming that is closer to natural languages and mathematical formulas, such as C language, python language, java language, PHP language, etc. High-level languages are basically separated from the hardware system of the machine and write programs in a way that is easier for people to understand. The program written is called the source program. Low-level languages are divided into machine language and assembly language, both of which are machine-oriented languages and are closely related to the instruction system of a specific machine. Machine language is a set of machine instructions that can be directly recognized and executed by a computer represented by binary code. That is, machine language is a system of instruction sets. This instruction set is called machine code, which is data that can be directly interpreted by the computer's CPU. The body of assembly language is assembly instructions. The difference between assembly instructions and machine instructions lies in the representation of the instructions. Assembly instructions are the writing format of machine instructions that are easy to remember.

机器码化是指高级语言编译成机器语言的过程。由于计算机不能直接识别高级语言,它只能识别机器语言,因此,高级语言需要经过编译器编程汇编程序,然后通过汇编器变成机器代码,最后才能被计算机执行。Machine coding refers to the process of compiling a high-level language into machine language. Since the computer cannot directly recognize the high-level language, it can only recognize the machine language. Therefore, the high-level language needs to go through the compiler to program the assembler, and then turn it into machine code through the assembler, and finally can be executed by the computer.

挂载(mounting)是指将文件或外部设备(通常是存储设备)挂接到设备中已存在的目录上,通过访问这个目录,来访问该外部设备或文件,同时,将外部设备或文件放在设备中的目录下,也可以让设备上的系统知道该如何管理该外部设备或文件,了解该外部设备或文件的可读写特性之类的过程。Mounting refers to attaching a file or an external device (usually a storage device) to an existing directory in the device. By accessing this directory, the external device or file is accessed, and at the same time, the external device or file is placed. Under the directory in the device, it is also possible to let the system on the device know how to manage the external device or file, and understand processes such as the readable and writable characteristics of the external device or file.

镜像文件是指将特定的一系列文件按照一定的格式制作成单一的文件,以方便用户下载和使用,例如一个操作系统、游戏等。它最重要的特点是可以被特定的软件识别并可以直接刻录到光盘上。通常意义上的镜像文件可以再扩展一下,在镜像文件中可以包含更多的信息,比如系统文件、引导文件、分区表信息等,这样镜像文件就可以包含一个分区甚至是一块硬盘的所有信息。下文所述的补丁文件类型可以是镜像文件。An image file refers to making a specific series of files into a single file according to a certain format to facilitate users to download and use, such as an operating system, a game, and so on. Its most important feature is that it can be recognized by specific software and can be directly burned to a disc. The image file in the usual sense can be further expanded, and the image file can contain more information, such as system files, boot files, partition table information, etc., so that the image file can contain all the information of a partition or even a hard disk. The type of patch file described below can be an image file.

绝对地址是指,在数据传输和存储中,主存储器的存储单元以字节为单位,每个存储单元都有一个地址与其对应。假定主存储器的容量为n,则该存储器就有n个存储单元(取n个字节的存储空间),其地址编号为:0,1,2,……,n-1。把主存空间的地址编号称为主存储器的绝对地址。The absolute address means that in data transmission and storage, the storage unit of the main memory is in units of bytes, and each storage unit has an address corresponding to it. Assuming that the capacity of the main memory is n, the memory has n storage units (taking n bytes of storage space), and its address numbers are: 0, 1, 2, ..., n-1. The address number of the main memory space is called the absolute address of the main memory.

相对地址是指相对于某个基准量(通常用0作为基准量)编址时所使用的地址。相对地址常用于程序编写和编译过程中,由于程序要放入主存中才能执行,因此指令和数据都要与某个主存绝对地址发生关系——放入主存单元。但由于多道程序系统中,主存将存放多道作业,因此程序员可能不会准确知道自己的程序放在主存中的何处运行,也就是程序员往往不会使用绝对地址来编写程序。因此,程序员通常使用相对地址,即相对于某个基准地址来编写程序并安排指令和数据的位置。The relative address refers to the address used when addressing relative to a certain reference value (usually 0 is used as the reference value). Relative addresses are often used in the process of program writing and compilation. Since the program must be placed in the main memory before it can be executed, the instructions and data must be related to an absolute address in the main memory—into the main memory unit. However, in a multiprogramming system, the main memory will store multiple jobs, so programmers may not know exactly where their programs are placed in the main memory to run, that is, programmers often do not use absolute addresses to write programs. . Therefore, programmers often use relative addresses, that is, relative to some base address to write programs and arrange the location of instructions and data.

boot.art是一个类对象映像文件,可以包含所有framework/base/preloaded-classes文件列出的所有类。这些类会被一次性地载入到内存中,并可以被直接使用。boot.art is a class object image file that can contain all classes listed in all framework/base/preloaded-classes files. These classes are loaded into memory once and can be used directly.

首先,介绍本申请实施例提供的一种通信系统10。First, a communication system 10 provided by an embodiment of the present application is introduced.

如图1示例性所示,该通信系统10可以包括云侧设备如云服务器101,以及终端侧设备如手机102、路由器103、平板电脑104、笔记本电脑105、智能电视106、智能音箱107、智能耳机108、智能手表109、智能手环110等。其中,路由器103可以组建无线网络并发射无线网络信号,手机102、平板电脑104、笔记本电脑105、智能电视106、智能音箱107、智能耳机108、智能手表109、智能手环110等可以通过接入路由器103的无线网络,从而处于同一个局域网内。As exemplarily shown in FIG. 1, the communication system 10 may include cloud-side devices such as cloud server 101, and terminal-side devices such as mobile phone 102, router 103, tablet computer 104, notebook computer 105, smart TV 106, smart speaker 107, smart Headphones 108, smart watches 109, smart bracelets 110, etc. Among them, the router 103 can form a wireless network and transmit wireless network signals, and the mobile phone 102, tablet computer 104, notebook computer 105, smart TV 106, smart speaker 107, smart earphone 108, smart watch 109, smart bracelet 110, etc. The wireless network of the router 103 is thus in the same local area network.

云服务器101可以生成电子设备所需要的一组或多组补丁包。云服务器101所生成的补丁包可以是用计算机高级语言编写的、与设备无关的原始解释性补丁代码,也可以是机器码形式的补丁代码。云服务器可以通过远场通信将所生成的补丁包下发给手机102,其生成的补丁包可以用于修复程序的一个或多个漏洞,或者可以用于增加一个或多个产品特性或功和/或功能,本申请对此不作限制。例如,电子设备可以通过安装某个补丁包,增加“语音助手”功能,该功能可以帮助用户不触碰电子设备的情景下发送信息、接打电话,也可以帮助用户在与他人面对面进行不同语言间的交谈时,帮助用户实时将对方的语言翻译为用户所能理解的语言。而电子设备在安装该补丁包前,不具有上述“语音助手”一系列的相关功能。另外,补丁可以有多种类型,比如以

Figure PCTCN2021133755-appb-000003
系统为例,应用程序(application,APP)层、应用框架(application framework)层、内核(kernel)层或硬件驱动(hardware driver)层等都可能存在相应类型的补丁,本申请对此不作限制。 The cloud server 101 can generate one or more sets of patch packages required by the electronic device. The patch package generated by the cloud server 101 may be the original interpretive patch code written in a computer high-level language and independent of the device, or may be the patch code in the form of machine code. The cloud server can deliver the generated patch package to the mobile phone 102 through far-field communication, and the generated patch package can be used to fix one or more vulnerabilities of the program, or can be used to add one or more product features or functions and functions. and/or functions, which are not limited in this application. For example, electronic devices can add a "voice assistant" function by installing a patch package, which can help users send messages and make calls without touching the electronic device, and can also help users communicate face-to-face with others in different languages. When chatting between users, it helps users to translate the other party's language into a language that the user understands in real time. The electronic device does not have the above-mentioned "voice assistant" series of related functions before the patch package is installed. In addition, patches can be of various types, such as
Figure PCTCN2021133755-appb-000003
Taking the system as an example, patches of corresponding types may exist at the application (application, APP) layer, application framework (application framework) layer, kernel (kernel) layer, or hardware driver (hardware driver) layer, etc., which are not limited in this application.

在一些实施例中,手机102可以具备较强的计算处理能力及较充足的内部存储空间,手机102可以作为补丁池,接收来自云服务器侧的一个或多个补丁包。该补丁池可以具有网络属性,即该补丁池所在存储位置/目录对局域网中所有设备可见。手机102可以通过补丁包广播将补丁池的信息同步到局域网中的其他设备上。手机102可以具有蓝牙(bluetooth,BT)模块和/或无线局域网络(wireless local area networks,WLAN)模块。其中,蓝牙模块可以提供包括经典蓝牙(蓝牙2.1)或蓝牙低功耗(bluetooth low energy,BLE)中一项或多项蓝牙通信的解决方案,WLAN模块可以提供包括无线保真直连(wireless fidelity direct,Wi-Fi direct)、无线保真局域网(wireless fidelity local area networks,Wi-Fi LAN)或无线保真软件接入点(wireless fidelity software access point,Wi-Fi softAP)中一项或多项WLAN通信的解决方案。手机102可以使用蓝牙或WLAN或其他类型的一种或多种无线通信技术与手机102附近其他电子设备建立无线通信连接,然后可以通过该无线通信连接共享补丁至与其他电子设备上。In some embodiments, the mobile phone 102 may have strong computing processing capability and sufficient internal storage space, and the mobile phone 102 may be used as a patch pool to receive one or more patch packages from the cloud server side. The patch pool can have a network attribute, that is, the storage location/directory where the patch pool is located is visible to all devices in the local area network. The mobile phone 102 can synchronize the patch pool information to other devices in the local area network through patch package broadcast. The cell phone 102 may have a bluetooth (BT) module and/or a wireless local area networks (WLAN) module. Among them, the Bluetooth module can provide one or more Bluetooth communication solutions including classic Bluetooth (Bluetooth 2.1) or Bluetooth low energy (BLE), and the WLAN module can provide wireless fidelity direct , Wi-Fi direct), wireless fidelity local area networks (Wi-Fi LAN) or wireless fidelity software access point (wireless fidelity software access point, Wi-Fi softAP) one or more WLANs communication solutions. The mobile phone 102 can establish a wireless communication connection with other electronic devices near the mobile phone 102 using one or more wireless communication technologies of Bluetooth or WLAN or other types, and then the patch can be shared with other electronic devices through the wireless communication connection.

在一些实施例中,手机102可以接收云服务器101通过网络主动推送的补丁包,该补丁包可以是解释性代码形式的补丁,手机102可以在接收到由云服务器下发的补丁包后,在安装该补丁时,基于本设备上需要打补丁的应用程序的版本信息,在设备侧将补丁程序代码进行机器码化。手机102还可以向云服务器101上报需要打补丁的应用程序的版本信息,然后云服务器101根据版本信息进行机器码化,再将机器码形式的补丁发送给手机102。手机102中可以存储有一张映射表,该映射表可以记录有版本信息与机器码偏移量的对应关系,手机102可以根据不同的版本信息生成不同的机器码补丁,然后局域网内的其他终端设备可以获取到对应的补丁并安装生效。In some embodiments, the mobile phone 102 may receive a patch package actively pushed by the cloud server 101 through the network, and the patch package may be a patch in the form of interpretive codes. After receiving the patch package issued by the cloud server, the mobile phone 102 may When the patch is installed, the patch code is machine-coded on the device side based on the version information of the application that needs to be patched on the device. The mobile phone 102 may also report the version information of the application to be patched to the cloud server 101 , and then the cloud server 101 performs machine coding according to the version information, and then sends the patch in the form of machine code to the mobile phone 102 . A mapping table can be stored in the mobile phone 102, and the mapping table can record the corresponding relationship between the version information and the machine code offset. The mobile phone 102 can generate different machine code patches according to different version information, and then other terminal devices in the local area network. The corresponding patches can be obtained and installed to take effect.

平板电脑104、笔记本电脑105可以是具备较强的计算处理能力及较充足的内部存储空间的终端设备,并且可以具备蓝牙模块、WLAN模块等无线通信模块。其中,关于蓝牙模块和WLAN模块的描述,可以参考上述手机102中的蓝牙模块和WLAN模块,在此不再赘述。平板电脑104、笔记本电脑105等具备较强的计算处理能力及较充足的内部存储空间的终端设备也可以作为补丁池,还可以作为将补丁程序编译为机器码的终端设备。补丁池所在终端设备与将补丁程序编译为机器码的终端设备可以为同一个终端设备,也可以不是同一个终端设备。比如手机102作为补丁池所挂载的终端设备,笔记本电脑105作为编译补丁机器码的终端设备,在手机102获取到云服务器101下发的补丁程序后,笔记本电脑105获取补丁池中的补丁,然后笔记本电脑105执行补丁程序的机器码化。The tablet computer 104 and the notebook computer 105 may be terminal devices with strong computing processing capability and sufficient internal storage space, and may be equipped with wireless communication modules such as a Bluetooth module and a WLAN module. For the description of the Bluetooth module and the WLAN module, reference may be made to the Bluetooth module and the WLAN module in the mobile phone 102, which will not be repeated here. Terminal devices such as the tablet computer 104 and the notebook computer 105 with strong computing processing capability and sufficient internal storage space can also be used as a patch pool, and can also be used as a terminal device for compiling a patch program into machine code. The terminal device where the patch pool is located and the terminal device that compiles the patch program into machine code may be the same terminal device, or may not be the same terminal device. For example, the mobile phone 102 is used as the terminal device mounted in the patch pool, and the laptop 105 is used as the terminal device for compiling the patch machine code. After the mobile phone 102 obtains the patch program issued by the cloud server 101, the laptop computer 105 obtains the patch in the patch pool. The laptop 105 then performs machine coding of the patch.

智能电视106、智能音箱107、智能耳机108、智能手表109、智能手环110可以是具备较弱的计算处理能力或较小的内部存储空间的终端设备,并且可以具有蓝牙模块、WLAN模块等无线通信模块。其中,关于蓝牙模块和WLAN模块的描述,可以参考上述手机102中的蓝牙模块和WLAN模块,在此不再赘述。在一些实施例中,这些计算处理能力较弱或内部存储空间较小的终端设备所运行的补丁文件可以挂载在同一个局域网中计算处理能力较强或内部存储空间较大的终端设备上。这种情况下,当这些计算处理能力较弱或内部存储空间较小的终端设备断开局域网连接时,补丁就会随之失效。重新接入局域网连接时,补丁会再次生效。The smart TV 106, the smart speaker 107, the smart earphone 108, the smart watch 109, and the smart bracelet 110 may be terminal devices with weak computing processing capability or small internal storage space, and may have wireless wireless modules such as Bluetooth modules and WLAN modules. communication module. For the description of the Bluetooth module and the WLAN module, reference may be made to the Bluetooth module and the WLAN module in the mobile phone 102, which will not be repeated here. In some embodiments, the patch files run by the terminal devices with weaker computing processing capability or smaller internal storage space may be mounted on the terminal device with stronger computing processing capability or larger internal storage space in the same local area network. In this case, when these terminal devices with weak computing processing power or small internal storage space are disconnected from the local area network, the patch will become invalid. The patch will take effect again when the LAN connection is reconnected.

如图1所示,云服务器101可以生成手机102所处局域网内电子设备所需要的补丁包,并将补丁包下发给手机102。在一些实施例中,该云服务器生成的补丁包可以分组下发。分组方式可以是以功能进行分组,如漏洞修复、新增产品功能特性等,也可以是以补丁类型进行分组,如应用程序(application,APP)层类型补丁,硬件驱动(hardware driver)层类型补丁等,本申请对此不作限制。As shown in FIG. 1 , the cloud server 101 can generate a patch package required by the electronic device in the local area network where the mobile phone 102 is located, and deliver the patch package to the mobile phone 102 . In some embodiments, the patch packages generated by the cloud server can be distributed in groups. The grouping method can be grouped by functions, such as bug fixes, new product features, etc., or by patch types, such as application (application, APP) layer type patches, hardware driver (hardware driver) layer type patches etc., which are not limited in this application.

在一些实施例中,共享补丁的各个终端设备,如手机102、平板电脑104、笔记本电脑105、智能电视106、智能音箱107、智能耳机108、智能手表109、智能手环110等可以装有相同的操作系统,如鸿蒙

Figure PCTCN2021133755-appb-000004
系统,在路由器103的连接下,形成一个系统生态。在相同的操作系统下,不同版本信息对应的补丁程序的机器码差异较小,编译机器码的终端设备可以根据版本信息的不同快速合成对应的补丁机器码。 In some embodiments, various terminal devices that share patches, such as mobile phone 102, tablet computer 104, laptop computer 105, smart TV 106, smart speaker 107, smart earphone 108, smart watch 109, smart bracelet 110, etc., may be equipped with the same operating systems such as Hongmeng
Figure PCTCN2021133755-appb-000004
The system, under the connection of the router 103, forms a system ecology. Under the same operating system, the differences in the machine codes of patches corresponding to different version information are small, and the terminal device compiling the machine codes can quickly synthesize the corresponding patch machine codes according to the different version information.

可以理解的是,本实施例示出的通信系统10并不构成对本申请实施例的具体限定。在本申请另外一些实施例中,通信系统10还可以包括比图示更多或更少的设备。例如,通信系统10中还可以包括台式电脑、智能台灯、智能冰箱等其它电子设备,本申请对此不作任何限制。It can be understood that the communication system 10 shown in this embodiment does not constitute a specific limitation to the embodiment of this application. In other embodiments of the present application, the communication system 10 may also include more or less devices than shown. For example, the communication system 10 may also include other electronic devices such as desktop computers, smart desk lamps, and smart refrigerators, which are not limited in this application.

下面,介绍本申请实施例中提供的示例性电子设备100。Next, the exemplary electronic device 100 provided in the embodiments of the present application is introduced.

图2示出了电子设备100的结构示意图。FIG. 2 shows a schematic structural diagram of the electronic device 100 .

其中,电子设备100可以是通信系统10中示出的手机102、平板电脑104、笔记本电脑105、智能电视106、智能音箱107、智能耳机108、智能手表109、智能手环110等,也可以是其他电子设备,如桌面型计算机、膝上型计算机、手持计算机、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、可穿戴式设备、车载设备、智能家居设备和/或智慧城市设备,本申请实施例对该电子设备的具体类型不作特殊限制。可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中, 电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。The electronic device 100 may be a mobile phone 102, a tablet computer 104, a notebook computer 105, a smart TV 106, a smart speaker 107, a smart earphone 108, a smart watch 109, a smart bracelet 110, etc. shown in the communication system 10, or it may be Other electronic devices, such as desktop computers, laptop computers, handheld computers, ultra-mobile personal computers (UMPCs), netbooks, and cellular phones, personal digital assistants (PDAs), augmented reality (augmented reality, AR) equipment, virtual reality (virtual reality, VR) equipment, artificial intelligence (artificial intelligence (AI) equipment, wearable equipment, vehicle-mounted equipment, smart home equipment and/or smart city equipment, embodiments of the present application The specific type of the electronic device is not particularly limited. It can be understood that, the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

电子设备100可以包括处理器111,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include a processor 111, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.

处理器111可以包括一个或多个处理单元,例如:处理器111可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 111 may include one or more processing units, for example, the processor 111 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.

控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.

处理器111中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器111中的存储器为高速缓冲存储器。该存储器可以保存处理器111刚用过或循环使用的指令或数据。如果处理器111需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器111的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 111 for storing instructions and data. In some embodiments, the memory in the processor 111 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 111 . If the processor 111 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 111 is reduced, thereby improving the efficiency of the system.

在一些实施例中,处理器111可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 111 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.

I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器111可以包含多组I2C总线。处理器111可以通过不同的I2C总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器111可以通过I2C接口耦合触摸传感器180K,使处理器111与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 111 may contain multiple sets of I2C buses. The processor 111 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193 and the like through different I2C bus interfaces. For example, the processor 111 can couple the touch sensor 180K through the I2C interface, so that the processor 111 and the touch sensor 180K communicate with each other through the I2C bus interface, so as to realize the touch function of the electronic device 100 .

I2S接口可以用于音频通信。在一些实施例中,处理器111可以包含多组I2S总线。处理器111可以通过I2S总线与音频模块170耦合,实现处理器111与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 111 may contain multiple sets of I2S buses. The processor 111 can be coupled with the audio module 170 through an I2S bus to implement communication between the processor 111 and the audio module 170 . In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface, so as to realize the function of answering calls through a Bluetooth headset.

PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communications, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器111与无线通信模块160。例如:处理器111通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus used for asynchronous communication. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is typically used to connect the processor 111 with the wireless communication module 160 . For example, the processor 111 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, so as to realize the function of playing music through the Bluetooth headset.

MIPI接口可以被用于连接处理器111与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器111和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器111和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the processor 111 with the display screen 194, the camera 193 and other peripheral devices. MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc. In some embodiments, the processor 111 and the camera 193 communicate through a CSI interface to implement the photographing function of the electronic device 100 . The processor 111 communicates with the display screen 194 through the DSI interface to implement the display function of the electronic device 100 .

GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器111与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 111 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and the like. The GPIO interface can also be configured as I2C interface, I2S interface, UART interface, MIPI interface, etc.

USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices.

可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.

充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is used to receive charging input from the charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB interface 130 . In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .

电源管理模块141用于连接电池142,充电管理模块140与处理器111。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器111,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器111中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 111 . The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 111, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance). In some other embodiments, the power management module 141 may also be provided in the processor 111 . In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.

电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.

天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.

移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信 模块150的至少部分功能模块可以被设置于处理器111中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器111的至少部分模块被设置在同一个器件中。The mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 111. In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 111 .

调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器111,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Wherein, the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and passed to the application processor. The application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 . In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modulation and demodulation processor may be independent of the processor 111, and may be provided in the same device as the mobile communication module 150 or other functional modules.

无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器111。无线通信模块160还可以从处理器111接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellites Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared technology (IR). The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 111 . The wireless communication module 160 can also receive the signal to be sent from the processor 111 , perform frequency modulation on it, amplify it, and then convert it into electromagnetic waves for radiation through the antenna 2 .

在一些实施例中,电子设备100可以通过WLAN等无线通信技术发现处于同一局域网中的设备,并与该设备建立无线通信连接。电子设备100还可以通过蓝牙发现附近一定区域的设备并建立通信连接。其中,蓝牙(BT)模块可以提供包括经典蓝牙(蓝牙2.1)或蓝牙低功耗(Bluetooth low energy,BLE)中一项或多项蓝牙通信的解决方案。WLAN模块可以提供包括Wi-Fi direct、Wi-Fi LAN或Wi-Fi softAP中一项或多项WLAN通信的解决方案。In some embodiments, the electronic device 100 may discover a device in the same local area network through a wireless communication technology such as WLAN, and establish a wireless communication connection with the device. The electronic device 100 can also discover devices in a certain area nearby through Bluetooth and establish a communication connection. Among them, the Bluetooth (BT) module can provide a solution including one or more Bluetooth communications in classic Bluetooth (Bluetooth 2.1) or Bluetooth low energy (Bluetooth low energy, BLE). The WLAN module can provide a solution including one or more WLAN communications in Wi-Fi direct, Wi-Fi LAN or Wi-Fi softAP.

在一些实施例中,电子设备100可以通过移动网络(如2G/3G/4G/5G等网络)、无线网络(如Wi-Fi)、有线网络(如宽带)接入互联网,并通过网络与其他设备通信,无线通信模块160提供的WLAN无线通信的解决方案也可使得电子设备可以与网络中的设备(如服务器)通信,并可以通过网络中的该设备(如服务器)与云端设备通信。这样,电子设备便可以发现、传输数据至网络中的设备和云端设备。In some embodiments, the electronic device 100 can access the Internet through a mobile network (such as 2G/3G/4G/5G and other networks), a wireless network (such as Wi-Fi), and a wired network (such as broadband), and communicate with other For device communication, the WLAN wireless communication solution provided by the wireless communication module 160 can also enable the electronic device to communicate with a device (such as a server) in the network, and to communicate with the cloud device through the device (such as a server) in the network. In this way, electronic devices can discover and transmit data to devices in the network and cloud devices.

在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).

电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器111可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 111 may include one or more GPUs that execute program instructions to generate or alter display information.

显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light). emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on. In some embodiments, the electronic device 100 may include one or N display screens 194 , where N is a positive integer greater than one.

电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 may implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.

ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193 . For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin tone. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193 .

摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。Camera 193 is used to capture still images or video. The object is projected through the lens to generate an optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals. In some embodiments, the electronic device 100 may include 1 or N cameras 193 , where N is a positive integer greater than 1.

数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。A digital signal processor is used to process digital signals, in addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.

视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.

NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process the input information, and can continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.

内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).

随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5SDRAM)等;Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronization Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as fifth-generation DDR SDRAM is generally called DDR5 SDRAM), etc.;

非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。Non-volatile memory may include magnetic disk storage devices, flash memory.

快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universal flash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle, and can include single-level memory cell (SLC), multi-level memory cell (multi-level memory cell, SLC) according to the level of storage cell potential. cell, MLC), triple-level cell (TLC), quad-level cell (QLC), etc., according to the storage specification can include universal flash storage (English: universal flash storage, UFS) , embedded multimedia memory card (embedded multi media Card, eMMC) and so on.

随机存取存储器可以由处理器111直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。The random access memory can be directly read and written by the processor 111, and can be used to store executable programs (such as machine instructions) of an operating system or other running programs, and can also be used to store data of users and application programs.

非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器111直接进行读写。The nonvolatile memory can also store executable programs and store data of user and application programs, etc., and can be loaded into the random access memory in advance for the processor 111 to directly read and write.

外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备100的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器111通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。The external memory interface 120 can be used to connect an external non-volatile memory, so as to expand the storage capacity of the electronic device 100 . The external non-volatile memory communicates with the processor 111 through the external memory interface 120 to realize the data storage function. For example, save music, video, etc. files in external non-volatile memory.

电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playback, recording, etc.

音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器111中,或将音频模块170的部分功能模块设置于处理器111中。The audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 111 , or some functional modules of the audio module 170 may be provided in the processor 111 .

扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。Speaker 170A, also referred to as a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.

受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also referred to as "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be answered by placing the receiver 170B close to the human ear.

麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。The microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.

耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone jack 170D is used to connect wired earphones. The earphone interface 170D can be the USB interface 130, or can be a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.

压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。陀螺仪传感器180B可以用于确定电子设备100的运动姿态。气压传感器180C用于测量气压。磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。环境光传感器180L用于感知环境光亮度。指纹传感器180H用于采集指纹。温度传感器180J用于检测温度。触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。骨传导传感器180M可以获取振动信号。The pressure sensor 180A is used to sense pressure signals, and can convert the pressure signals into electrical signals. The gyro sensor 180B may be used to determine the motion attitude of the electronic device 100 . The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can detect the opening and closing of the flip holster using the magnetic sensor 180D. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. It can also be used to identify the posture of electronic devices, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc. Distance sensor 180F for measuring distance. The electronic device 100 can measure the distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing. Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes. The ambient light sensor 180L is used to sense ambient light brightness. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect the temperature. Touch sensor 180K, also called "touch device". The touch sensor 180K may be disposed on the display screen 194 , and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”. The touch sensor 180K is used to detect a touch operation on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to touch operations may be provided through display screen 194 . In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the location where the display screen 194 is located. The bone conduction sensor 180M can acquire vibration signals.

按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .

马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. The motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 . Different application scenarios (for example: time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.

SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 is used to connect a SIM card. The SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 . The electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication. In some embodiments, the electronic device 100 employs an eSIM, ie: an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .

电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的

Figure PCTCN2021133755-appb-000005
系统为例,示例性说明电子设备100的软件架构。 The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present invention use a layered architecture
Figure PCTCN2021133755-appb-000005
Taking the system as an example, the software architecture of the electronic device 100 is exemplarily described.

图3是本发明实施例的电子设备100的软件结构框图。FIG. 3 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.

如图3所示,该电子设备100的软件结构可以包括:应用程序层(applications,APP)、应用程序框架层(application framework,FWK)、安卓运行时(

Figure PCTCN2021133755-appb-000006
runtime)和系统库(libraries)、内核层(kernel)。 As shown in FIG. 3, the software structure of the electronic device 100 may include: an application layer (applications, APP), an application framework layer (application framework, FWK), an Android runtime (
Figure PCTCN2021133755-appb-000006
runtime) and system libraries (libraries), kernel layer (kernel).

应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.

如图3所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in Figure 3, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.

应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

如图3所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in Figure 3, the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.

窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。A window manager is used to manage window programs. The window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.

内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make these data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.

视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications. A display interface can consist of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.

电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide the communication function of the electronic device 100 . For example, the management of call status (including connecting, hanging up, etc.).

资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.

通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,头戴式显示设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, prompting text information in the status bar, making a sound, the head-mounted display device vibrating, the indicator light flashing, etc.

Figure PCTCN2021133755-appb-000007
Runtime包括核心库和虚拟机。
Figure PCTCN2021133755-appb-000008
runtime负责安卓系统的调度和管理。
Figure PCTCN2021133755-appb-000007
Runtime includes core libraries and virtual machines.
Figure PCTCN2021133755-appb-000008
The runtime is responsible for scheduling and management of the Android system.

核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one is the function functions that the java language needs to call, and the other is the core library of Android.

应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in virtual machines. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, safety and exception management, and garbage collection.

系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。A system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.

表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.

媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

2D图形引擎是2D绘图的绘图引擎。2D graphics engine is a drawing engine for 2D drawing.

内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动、以及WLAN蓝牙能力和基本通信协议。The kernel layer is the layer between hardware and software. The kernel layer contains at least a display driver, a camera driver, an audio driver, a sensor driver, as well as WLAN Bluetooth capabilities and basic communication protocols.

可以理解的是,补丁可用于修复一个或多个软件程序漏洞,或者可用于增加一个或多个新的产品特性或功能。例如,在

Figure PCTCN2021133755-appb-000009
操作系统中,电子设备100的补丁可以修复上述应用程序层、应用程序框架层、系统库和内核层等一项或多项程序漏洞,补丁还可以用于新增上述应用程序层、应用程序框架层、系统库和内核层等一项或多项产品特性或功能,本申请对此不作限制。 It is understood that a patch may be used to fix one or more software program vulnerabilities, or may be used to add one or more new product features or functionality. For example, in
Figure PCTCN2021133755-appb-000009
In the operating system, the patch of the electronic device 100 can repair one or more program vulnerabilities such as the above-mentioned application layer, application framework layer, system library and kernel layer, and the patch can also be used to add the above-mentioned application layer and application framework. One or more product features or functions, such as layer, system library and kernel layer, are not limited in this application.

在一些实现方式中,一个补丁文件中可以包括:版本信息、校验信息、定位信息及待写入的新代码等片段。待写入的新代码可以是差分代码,也可以是替换代码。差量代码表示的是补丁代码是未修复漏洞的旧程序代码与已修复漏洞的新程序代码的差量部分代码。差分代码可以有效压缩补丁文件的体积,减少代码的重复,节省存储空间。替换代码表示的是该补丁代码可以直接替换bug处代码,例如在读取bug处所在函数时,可以跳转到补丁代码处读取补丁代码替换读取bug处代码,在补丁代码读取完毕后,再跳转返回原程序代码继续读取其他代码。In some implementations, a patch file may include: version information, verification information, positioning information, and new code to be written, and other segments. The new code to be written can be a differential code or a replacement code. The difference code means that the patch code is the difference code between the old program code that has not fixed the vulnerability and the new program code that has fixed the vulnerability. The differential code can effectively compress the size of the patch file, reduce code duplication and save storage space. The replacement code means that the patch code can directly replace the code at the bug. For example, when reading the function where the bug is located, you can jump to the patch code to read the patch code instead of reading the code at the bug. After the patch code is read , and then jump back to the original program code to continue reading other codes.

版本信息可以是指当前补丁文件适用的程序版本,版本信息包括版本号、版本名称,生成时间等。校验信息可以是循环冗余校验(cyclic redundancy check,CRC)码,一般用于区分补丁文件身份的信息以及校验补丁文件中数据的正确性,系统可通过版本信息和校验信息确定补丁文件是否与系统相匹配。定位信息中可以记录有bug,即待修改代码的地址,以及记录有跳转到对应的新写入代码的跳转地址。因此,通过定位信息片段中的数据可查找到原程序中bug代码处的位置信息,进而写入新补丁代码。在待写入的新代码的片段中,包含了 新函数代码,这些新函数代码可在编程之后由编译器生成,在修复程序漏洞时,将该片段的数据写入原程序中,补丁生效,实现对漏洞的修复。The version information may refer to a program version to which the current patch file is applicable, and the version information includes a version number, a version name, and a generation time. The verification information can be a cyclic redundancy check (CRC) code, which is generally used to distinguish the identity information of the patch file and verify the correctness of the data in the patch file. The system can determine the patch through the version information and the verification information. Whether the file matches the system. A bug may be recorded in the positioning information, that is, the address of the code to be modified, and a jump address of jumping to the corresponding newly written code may be recorded. Therefore, the location information of the bug code in the original program can be found through the data in the location information segment, and then the new patch code can be written. The segment of the new code to be written contains the new function code. These new function codes can be generated by the compiler after programming. When the bug is fixed, the data of the segment is written into the original program, and the patch takes effect. Implement bug fixes.

在一些实施例中,在对一个原程序进行漏洞修复时,终端设备会检测系统中该原程序的运行状态。当检测到该原程序运行时,终端设备则进一步检测系统中的补丁文件。若检测到系统中设置有补丁文件,则会对该补丁文件进行身份验证,从而确定该补丁文件是否与该原程序相匹配。具体地,在对补丁文件进行验证时,可读取该补丁文件中的版本信息和校验信息,并通过版本信息和校验信息对该补丁文件进行验证,即将该补丁文件中的验证数据,如版本号、生成时间、CRC校验码,与原程序中的验证数据进行对比,确保该补丁文件与系统中的原程序相匹配,避免使用错误的补丁文件。若验证成功,则表示该补丁文件与终端设备上该原程序相匹配;若验证失败,则表示该补丁文件与终端设备上该原程序不匹配。在验证成功的情况下,终端设备会获取补丁文件中的待修改代码的定位信息以及待写入的新代码,从而在bug处写入补丁新代码,实现漏洞的修复等功能。In some embodiments, when a vulnerability is repaired to an original program, the terminal device will detect the running state of the original program in the system. When detecting that the original program is running, the terminal device further detects the patch file in the system. If it is detected that a patch file is set in the system, the patch file will be authenticated to determine whether the patch file matches the original program. Specifically, when verifying the patch file, the version information and verification information in the patch file can be read, and the patch file can be verified through the version information and verification information, that is, the verification data in the patch file, For example, the version number, generation time, and CRC check code are compared with the verification data in the original program to ensure that the patch file matches the original program in the system to avoid using the wrong patch file. If the verification is successful, it means that the patch file matches the original program on the terminal device; if the verification fails, it means that the patch file does not match the original program on the terminal device. In the case of successful verification, the terminal device will obtain the location information of the code to be modified and the new code to be written in the patch file, so as to write the new code for the patch at the bug to realize functions such as repairing the vulnerability.

图4为本申请实施例提供的补丁代码机器码化的示意图。FIG. 4 is a schematic diagram of machine coding of patch codes according to an embodiment of the present application.

电子设备100可以在接收到云服务器下发的原始解释性补丁代码后,基于本设备的版本信息,将该原始解释性代码编译为计算机处理器可以直接执行的机器码。After receiving the original interpretive patch code issued by the cloud server, the electronic device 100 may compile the original interpretive code into machine code that can be directly executed by the computer processor based on the version information of the device.

结合图4,补丁可以由公共代码401、私有代码402组成,公共代码401和私有代码402都是非机器代码,即解释性代码。其中,公共代码401在机器码化的过程中会被编译为公共模块的机器码。私有代码402使用的接口或函数为更为底层的开发套件的代码。该私有代码402编译后的机器码以绝对地址和相对地址相结合组成。上述公共代码401和私有代码402皆为原始解释性代码,也即是说,上述公共代码401和私有代码402为非机器代码,可以依赖于某些具体的容器屏蔽差异,因此可以做到跨设备运行。Referring to FIG. 4 , the patch may be composed of public code 401 and private code 402 , both of which are non-machine codes, ie, interpretive codes. The common code 401 will be compiled into the machine code of the common module in the process of machine coding. The interface or function used by the private code 402 is the code of the lower-level development kit. The compiled machine code of the private code 402 is composed of a combination of absolute addresses and relative addresses. The above-mentioned public code 401 and private code 402 are both original interpretive codes, that is to say, the above-mentioned public code 401 and private code 402 are non-machine codes, which can rely on some specific containers to shield differences, so cross-device can be achieved. run.

电子设备100在补丁非机器代码编译为机器码时,将私有代码402编译为私有代码的机器码403,将公共代码401编译为公共代码的机器码404。私有代码的机器码403是私有代码在机器码化的过程中被编译后生成的机器码。通常,该部分代码可以在不同的电子设备上通用,该部分代码中的所引用的各个平台中的私有资源是可共用的。公共代码的机器码404是公共代码在机器码化的过程中被编译后生成的机器码。该部分代码可以基于电子设备的中间层公共接口的代码生成。由于不同电子设备的资源、配置等不尽相同,因此不同设备的公共接口的公共地址也不尽相同,公共代码401可以根据不同设备的公共接口的公共地址等,结合生成和电子设备强相关的机器代码。例如,以该电子设备是手机400为例,公共代码401结合所获取到的手机400相关的偏移地址,生成与手机400强相关的公共代码的机器码404,并保存在boot.art文件中。When compiling the patched non-machine code into machine code, the electronic device 100 compiles the private code 402 into the machine code 403 of the private code, and compiles the public code 401 into the machine code 404 of the public code. The machine code 403 of the private code is the machine code generated after the private code is compiled in the process of machine coding. Generally, this part of the code can be commonly used on different electronic devices, and the private resources in each platform referenced in this part of the code can be shared. The machine code 404 of the common code is the machine code generated after the common code is compiled in the process of machine coding. The part of the code can be generated based on the code of the middle layer public interface of the electronic device. Since the resources and configurations of different electronic devices are not the same, the public addresses of the public interfaces of different devices are also different. The public code 401 can be combined with the public addresses of the public interfaces of different devices to generate a strong correlation with the electronic devices. machine code. For example, taking the electronic device as the mobile phone 400 as an example, the public code 401 combines the obtained offset address related to the mobile phone 400 to generate the machine code 404 of the public code related to the mobile phone 400, and save it in the boot.art file .

私有代码的机器码403和公共代码的机器码404结合,组成补丁机器码405。该补丁机器码405可以存储在电子设备的缓冲池中。The machine code 403 of the private code and the machine code 404 of the public code are combined to form the patch machine code 405 . The patch machine code 405 may be stored in a buffer pool of the electronic device.

补丁池中的补丁代码,可以基于挂载补丁池的设备进行机器码化。但是因为在不同设备上,同一个补丁代码的主体代码相同,同一个函数偏移地址可能不同,因此补丁代码在不同设备上进行机器码化时对应的机器码不同。补丁池中可以存储有一张映射表,记录这些差异以及标记差异对应的相关设备。这样,在补丁池中机器码化后的补丁代码被迁移到第二设备时,可以结合第二设备对应的差异快速合成新的补丁机器码,合成的方式包含但是不限于二进制合成方式,磁盘块合成方式或者代码重定位方式等。The patch code in the patch pool can be machine-coded based on the device on which the patch pool is mounted. However, on different devices, the body code of the same patch code is the same, and the offset address of the same function may be different, so the corresponding machine codes of the patch code are different when machine coding is performed on different devices. A mapping table can be stored in the patch pool to record these differences and mark the relevant devices corresponding to the differences. In this way, when the machine-coded patch code in the patch pool is migrated to the second device, a new patch machine code can be quickly synthesized in combination with the differences corresponding to the second device. The synthesis method includes but is not limited to binary synthesis, disk block Synthesis or code relocation, etc.

例如,补丁池中存储有手机400对应的补丁偏移量A 406和手表408对应的补丁偏移量B 407的相关信息。补丁偏移量A 406中可以包括:补丁机器码偏移量、该偏移量在局域网中 所对应的手机400的标识以及补丁相关内容的匹配信息。补丁偏移量B 408中可以包括:补丁机器码偏移量、该偏移量在局域网中所对应的手表408的标识以及补丁相关内容的匹配信息。如果手机400和手表408的需要打补丁程序的版本信息不同,那么可能公共接口的偏移地址也不相同,则补丁偏移量A 406与补丁偏移量B 407也不相同。但是,在手机400的补丁机器码被迁移到手表408上时,手机400的补丁机器码可以结合手表408的补丁偏移量B快速合成新的补丁机器码,新的补丁机器码可以在手表408上生效。For example, the patch pool stores information about patch offset A 406 corresponding to the mobile phone 400 and patch offset B 407 corresponding to the watch 408 . The patch offset A 406 may include: the patch machine code offset, the identifier of the mobile phone 400 corresponding to the offset in the local area network, and the matching information of the patch-related content. The patch offset B 408 may include: the patch machine code offset, the identifier of the watch 408 corresponding to the offset in the local area network, and the matching information of the patch-related content. If the version information of the mobile phone 400 and the watch 408 to be patched is different, the offset address of the public interface may be different, and the patch offset A 406 and the patch offset B 407 are also different. However, when the patch machine code of the mobile phone 400 is migrated to the watch 408, the patch machine code of the mobile phone 400 can be combined with the patch offset B of the watch 408 to quickly synthesize a new patch machine code, and the new patch machine code can be added to the watch 408. effective on.

示例性的,补丁池可以存储有一个映射表,该映射表中可以记录版本号、电子设备唯一识别号、偏移量等信息。其中,示例性的,映射表可以如下表1所示:Exemplarily, the patch pool may store a mapping table, and the mapping table may record information such as the version number, the unique identification number of the electronic device, and the offset. Wherein, exemplary, the mapping table may be as shown in Table 1 below:

表1Table 1

Figure PCTCN2021133755-appb-000010
Figure PCTCN2021133755-appb-000010

如表1所示,本示例性映射表中记录的电子设备唯一识别号以电子设备的产品序列号(serial number,SN)为例。电子设备869672321140250所拥有的版本号为10.0.1,该电子设备所对应的偏移量为1F69H。电子设备869672321150369所拥有的版本号为10.0.2,该电子设备所对应的偏移量为0F60H。电子设备869672321120568所拥有的版本号为10.0.3,该电子设备所对应的偏移量为0060H。其中,偏移量中末尾H可以代表该偏移量是十六进制数。As shown in Table 1, the unique identification number of the electronic device recorded in this exemplary mapping table is a product serial number (serial number, SN) of the electronic device as an example. The version number of the electronic device 869672321140250 is 10.0.1, and the offset corresponding to the electronic device is 1F69H. The version number owned by the electronic device 869672321150369 is 10.0.2, and the offset corresponding to the electronic device is 0F60H. The version number of the electronic device 869672321120568 is 10.0.3, and the offset corresponding to the electronic device is 0060H. The H at the end of the offset may represent that the offset is a hexadecimal number.

在另一些实施例中,映射表中记录的电子设备唯一识别号可以是电子设备固定的物理地址(media access control,MAC),也可以是该电子设备区别于其他电子设备的唯一编号。本申请对此不作限制。In other embodiments, the unique identification number of the electronic device recorded in the mapping table may be a fixed physical address (media access control, MAC) of the electronic device, or may be a unique number that distinguishes the electronic device from other electronic devices. This application does not limit this.

可以理解的是,上述示例表仅用于解释本申请,不应构成对本申请的限定。It can be understood that, the above example table is only used to explain the present application, and should not be construed to limit the present application.

可以理解的是,图4只是示例性说明机器码化原始解释性补丁代码的实现方式,不应对本申请构成具体限制。It can be understood that FIG. 4 merely illustrates the implementation of the machine-coded original explanatory patch code, and should not constitute a specific limitation to the present application.

下面,基于前述的通信系统10及电子设备100,详细说明本申请提供的打补丁的方法。Hereinafter, based on the aforementioned communication system 10 and electronic device 100, the patching method provided by the present application will be described in detail.

实施例一Example 1

在本实施例中,以手机和平板电脑之间的交互作为示例说明。手机可以作为挂载补丁池的设备及机器码化补丁的设备,平板电脑可以作为需要获取补丁修复程序漏洞或升级产品特性的设备。手机和平板电脑都是具备较强的计算处理能力及较充足的内部存储空间等的终端设备。手机和平板电脑处于同一个局域网中,手机可以根据平板电脑的版本信息在手机侧进行补丁的机器码化,生成机器码形式的补丁文件,然后发送给平板电脑,平板电脑读取该补丁文件,补丁生效。In this embodiment, the interaction between the mobile phone and the tablet computer is used as an example for description. Mobile phones can be used as devices to mount patch pools and machine-coded patches, and tablets can be used as devices to obtain patches to fix bugs or upgrade product features. Mobile phones and tablet computers are terminal devices with strong computing processing capabilities and sufficient internal storage space. The mobile phone and the tablet computer are in the same local area network. The mobile phone can machine code the patch on the mobile phone side according to the version information of the tablet computer, generate a patch file in the form of machine code, and then send it to the tablet computer. The tablet computer reads the patch file, Patch takes effect.

在一些实施例中,挂载补丁池的设备与机器码化补丁的设备可以不为同一个设备,比如笔记本电脑为挂载补丁池的设备,笔记本电脑可以从云服务器获取各个补丁,存储在补丁池中,该补丁池对接入同一个局域网中的设备都可见。手机、平板电脑和笔记本电脑处于同一个局域网中,手机可以获取到补丁池中的某个补丁,并根据平板电脑的版本信息在手机侧进行补丁的机器码化,生成机器码形式的补丁文件,然后发送给平板电脑,平板电脑读取该补丁文件,补丁生效。In some embodiments, the device on which the patch pool is mounted and the device on which the machine-coded patch is mounted may not be the same device. For example, the laptop is the device on which the patch pool is mounted. The laptop can obtain each patch from the cloud server and store it in the patch pool. The patch pool is visible to all devices connected to the same LAN. The mobile phone, tablet computer and laptop are in the same local area network. The mobile phone can obtain a patch in the patch pool, and machine code the patch on the mobile phone side according to the version information of the tablet computer to generate a patch file in the form of machine code. Then send it to the tablet computer, the tablet computer reads the patch file, and the patch takes effect.

可以理解的是,手机和平板电脑的交互仅是为了一种示例性说明,并不对本申请实施例构成任何限制。It can be understood that the interaction between the mobile phone and the tablet computer is only for an exemplary illustration, and does not constitute any limitation to the embodiments of the present application.

图5示出了本申请实施例提供的一种打补丁的方法流程。具体地,可以包括以下步骤:FIG. 5 shows a flow of a patching method provided by an embodiment of the present application. Specifically, the following steps may be included:

S101、手机和平板电脑接入同一局域网中。S101, the mobile phone and the tablet computer are connected to the same local area network.

具体的,手机和平板电脑可以通过接入同一路由器所提供的同一Wi-Fi接入点而处于同一局域网内,手机和平板电脑可以通过该Wi-Fi接入点建立两者间的无线通信连接(也可以称为第一连接)。在该局域网中,手机中所挂载的补丁池及补丁池所在的位置等信息对于平板电脑而言可以是可见的。Specifically, the mobile phone and the tablet computer can be in the same local area network by accessing the same Wi-Fi access point provided by the same router, and the mobile phone and the tablet computer can establish a wireless communication connection between the two through the Wi-Fi access point. (may also be referred to as the first connection). In the local area network, information such as the patch pool mounted on the mobile phone and the location of the patch pool may be visible to the tablet computer.

S102、手机作为挂载补丁池的设备,可以获取云服务器下发的第一补丁(也可以称为第一补丁文件),第一补丁可以用于修复第一程序的第一漏洞。S102. As a device for mounting the patch pool, the mobile phone can obtain the first patch (also referred to as the first patch file) issued by the cloud server, and the first patch can be used to repair the first vulnerability of the first program.

具体的,补丁池可以指的是存储有一个或多个补丁的一个或多个目录,该目录可以设置为在局域网中对其他设备可见,而对于不在同一局域网中的其他设备,该目录则对其不可见。具体地,补丁池在所挂载的手机设备上可以为某个目录,如/data/hotpatch/,将该目录的属性设置为对局域网中其他设备可见,这样,补丁池的存储位置会暴露在整个局域网中。Specifically, the patch pool may refer to one or more directories in which one or more patches are stored. The directory can be set to be visible to other devices in the local area network, and for other devices not in the same local area network, the directory is accessible to other devices. its not visible. Specifically, the patch pool can be a directory on the mounted mobile device, such as /data/hotpatch/, and the properties of the directory can be set to be visible to other devices in the local area network. In this way, the storage location of the patch pool will be exposed in the throughout the local area network.

第一补丁可以包括一个或多个补丁文件,该第一补丁的代码形式可以是解释性代码,也可以为机器码,本申请不作限制。如果是机器码形式的补丁文件,那云服务器需要在下发补丁前获取到需要打补丁的设备中程序的版本信息,然后根据版本信息在云端进行机器码化,再下发至设备侧,设备侧不需要进行编译,可以直接运行机器码。该第一补丁可以是云服务器生成后,主动推送至手机,也可以是根据手机的请求进行下发,本申请对此不作限制。The first patch may include one or more patch files, and the code form of the first patch may be interpretive code or machine code, which is not limited in this application. If it is a patch file in the form of machine code, the cloud server needs to obtain the version information of the program in the device that needs to be patched before issuing the patch, and then perform machine coding in the cloud according to the version information, and then send it to the device side. No need to compile, you can run machine code directly. The first patch may be actively pushed to the mobile phone after being generated by the cloud server, or may be issued according to the request of the mobile phone, which is not limited in this application.

S103、根据手机中第一程序的版本号A,手机将第一补丁的代码编译成机器码A(也可以称为第一机器码)。S103. According to the version number A of the first program in the mobile phone, the mobile phone compiles the code of the first patch into machine code A (also referred to as the first machine code).

具体的,在同一局域网中,不同的电子设备上第一程序的版本信息可能不尽相同,版本信息可以包括版本名称、版本号等信息,在本实施例中,手机中第一程序的版本信息可以称为第一版本信息。手机的第一程序的版本号为版本号A。手机还存储有第一映射表,该第一映射表中可以记录有第一程序的不同版本号和相对于机器码A的偏移量之间的一一对应关系。第一程序的版本信息不同,其同一个函数接口的偏移地址可能会不尽相同,因此不同版本的程序会对应不同的偏移量。Specifically, in the same local area network, the version information of the first program on different electronic devices may be different, and the version information may include information such as version name, version number, etc. In this embodiment, the version information of the first program in the mobile phone It can be called the first version information. The version number of the first program of the mobile phone is version number A. The mobile phone also stores a first mapping table, and the first mapping table may record the one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A. The version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.

当然,第一映射表中还可以记录有其他对应信息,比如说手机可以获取到局域网中其他电子设备目前使用的第一程序的某个版本,那么第一映射表中还可以记录该电子设备的唯一身份标识号(identity document,ID)与版本号的对应关系。电子设备的ID可以是其固定的物理地址(media access control,MAC),也可以是电子设备的产品序列号(serial number,SN),也可以是该电子设备区别于其它电子设备的其他唯一识别号,本申请对此不作限制。Of course, other corresponding information can also be recorded in the first mapping table. For example, the mobile phone can obtain a certain version of the first program currently used by other electronic devices in the local area network, then the first mapping table can also record the information of the electronic device. The correspondence between the unique identification number (identity document, ID) and the version number. The ID of an electronic device can be its fixed physical address (media access control, MAC), or the product serial number (SN) of the electronic device, or other unique identifications that distinguish the electronic device from other electronic devices. No., this application does not limit it.

S104、手机获取到平板电脑的ID、平板电脑中第一程序的版本号B等信息。S104, the mobile phone obtains information such as the ID of the tablet computer, the version number B of the first program in the tablet computer, and the like.

平板电脑的ID是平板电脑的唯一识别号。平板电脑的ID可以是MAC号,也可以是SN号,也可以是该平板电脑区别于其它电子设备的其他唯一识别号,本申请对此不作限制。The tablet's ID is the unique identification number of the tablet. The ID of the tablet computer may be a MAC number, an SN number, or other unique identification numbers of the tablet computer that are different from other electronic devices, which are not limited in this application.

本实施例中,平板电脑中第一程序的版本信息可以称为第二版本信息。平板电脑的第一程序的版本号为版本号B,区别于手机中第一程序的版本号A。In this embodiment, the version information of the first program in the tablet computer may be referred to as the second version information. The version number of the first program of the tablet computer is version number B, which is different from the version number A of the first program in the mobile phone.

S105、手机查询第一映射表,版本号B对应偏移量B(也可以称为第一偏移量)。手机将版本号B对应的偏移量B与机器码A合成为机器码B(也可以称为第二机器码),并生成补丁文件B(也可以称为第二补丁文件),补丁文件B是可以用于修复第一程序为版本号B的第一漏洞的补丁文件。S105, the mobile phone queries the first mapping table, and the version number B corresponds to the offset B (which may also be referred to as the first offset). The mobile phone synthesizes the offset B corresponding to the version number B and the machine code A into the machine code B (also called the second machine code), and generates the patch file B (also called the second patch file), and the patch file B It is a patch file that can be used to fix the first vulnerability whose first program is version B.

具体的,偏移量B与机器码A合成机器码B的方式可以包括但不限于二进制合成方式、磁盘块合成方式以及代码重定位方式。其中,二进制合成方式指的是将多个二进制文件合成一个,并且要指定数据段地址偏移量,在数据段之间的地址填充默认值。磁盘块合成方式指的是将多个物理硬块合成一个逻辑硬盘使用。代码重定位方式指的是把程序的逻辑地址空间变换成内存中的实际物理地址空间的过程,重定位有两种方法,分别是动态重定位和静态重定位。静态重定位即在程序装入内存的过程中完成,是指在程序开始运行前,程序中的各个地址有关的项均已完成重定位,地址变换通常是在装入时一次完成的,以后不再改变。动态重定位不是在程序装入内存时完成的,而是中央处理器(central processing unit,CPU)每次访问内存时,有动态地址变换机构(硬件)自动把相对地址变换成为绝对地址。动态重定位需要软件和硬件的相互配合。Specifically, the manner in which the offset B and the machine code A are combined into the machine code B may include, but is not limited to, a binary synthesis manner, a disk block synthesis manner, and a code relocation manner. Among them, the binary synthesis method refers to synthesizing multiple binary files into one, and the address offset of the data segment is specified, and the addresses between the data segments are filled with default values. The disk block combination method refers to combining multiple physical hard blocks into one logical hard disk. The code relocation method refers to the process of transforming the logical address space of the program into the actual physical address space in the memory. There are two methods of relocation, namely dynamic relocation and static relocation. Static relocation is completed during the process of loading the program into memory, which means that before the program starts to run, all address-related items in the program have been relocated. Change again. Dynamic relocation is not done when the program is loaded into memory, but every time the central processing unit (CPU) accesses the memory, a dynamic address translation mechanism (hardware) automatically converts the relative address into an absolute address. Dynamic relocation requires the cooperation of software and hardware.

可以理解的是,补丁文件B可以包括一个或多个文件。It can be understood that the patch file B may include one or more files.

S106、手机在局域网中发送广播,该广播的消息中可以包括挂载补丁池的设备ID(如手机ID)、补丁文件B所支持的设备ID(如平板电脑ID)、补丁文件B所支持的第一程序版本号(如版本号B)等等。S106, the mobile phone sends a broadcast in the local area network, and the broadcast message may include the device ID (such as the mobile phone ID) of the mounted patch pool, the device ID (such as the tablet computer ID) supported by the patch file B, and the device ID supported by the patch file B. The first program version number (eg version number B) and so on.

S107、平板电脑应答手机的广播,应答消息中可以包括手机ID、平板电脑ID、版本号B等等。S107, the tablet computer responds to the broadcast of the mobile phone, and the response message may include the mobile phone ID, the tablet computer ID, the version number B, and the like.

S108、平板电脑获取手机侧生成的补丁文件B。S108, the tablet computer obtains the patch file B generated by the mobile phone side.

在平板电脑应答手机的广播,手机验证平板电脑的身份之后,手机可以将补丁文件B发送至平板电脑侧。After the tablet computer answers the broadcast of the mobile phone and the mobile phone verifies the identity of the tablet computer, the mobile phone can send the patch file B to the tablet computer side.

S109、当运行第一程序时,平板电脑加载补丁文件B,第一补丁生效,第一程序中的第一漏洞被修复。S109. When running the first program, the tablet computer loads the patch file B, the first patch takes effect, and the first vulnerability in the first program is repaired.

在一些实施例中,补丁文件中的代码可以为差分代码,那么加载补丁文件B,补丁文件B会与原第一程序代码进行合成,生成新第一程序代码,新第一程序代码中修复了第一漏洞所在问题。In some embodiments, the code in the patch file may be a differential code, then load the patch file B, and the patch file B will be synthesized with the original first program code to generate a new first program code, which is repaired in the new first program code The first flaw is the problem.

在另一些实施例中,补丁文件中的代码可能为替换代码,那么当平板电脑运行第一程序的第一漏洞处所对应的机器码时,可以跳转加载补丁文件B,补丁生效,第一程序中的第一漏洞被修复。在补丁文件B读取完毕后,再跳转返回原程序。具体的,平板电脑可以将补丁文件B制作成可加载的动态链接库的格式,该补丁文件B包含有第一程序中第一漏洞的代码信息,以及修复第一漏洞的代码信息,然后,通过加载程序将补丁文件加载到第一程序进程的地址空间的过程中,找到第一漏洞的地址,并将第一漏洞的入口指令改为可写,同时将第一漏洞的入口指令改变为跳转到补丁文件B中的修复第一漏洞的代码。当平板电脑运行第一程序时,运行至第一程序中的第一漏洞处所对应的机器码处,可以被重新定向到补丁文件B中修复第一漏洞的新代码的位置。修复第一漏洞的补丁代码被执行完毕后,返回原第一程序继续运行。In other embodiments, the code in the patch file may be replacement code, then when the tablet computer runs the machine code corresponding to the first vulnerability of the first program, it can jump to load the patch file B, the patch takes effect, and the first program The first bug in . After the patch file B is read, jump back to the original program. Specifically, the tablet computer can make the patch file B in the format of a loadable dynamic link library, and the patch file B contains the code information of the first vulnerability in the first program and the code information of repairing the first vulnerability, and then, through In the process of loading the patch file into the address space of the first program process, the loader finds the address of the first vulnerability, changes the entry instruction of the first vulnerability to writable, and at the same time changes the entry instruction of the first vulnerability to jump to the code in patch file B that fixes the first vulnerability. When the tablet computer runs the first program, it runs to the machine code corresponding to the first vulnerability in the first program, and can be redirected to the position of the new code in the patch file B that fixes the first vulnerability. After the patch code for repairing the first vulnerability is executed, it returns to the original first program to continue running.

图6为方法实施例一所述的打补丁的方法的场景示意图。FIG. 6 is a schematic diagram of a scene of the method for patching according to the first method embodiment.

如图6示例性所示,该实施场景可以包括:手机102、路由器103以及平板电脑104。手机102和平板电脑104可以通过接入路由器103提供的同一个Wi-Fi接入点而处于同一局域网中。其中,手机102中的第一程序为版本号A,平板电脑104的第一程序为版本号B。As exemplarily shown in FIG. 6 , the implementation scenario may include: a mobile phone 102 , a router 103 , and a tablet computer 104 . The mobile phone 102 and the tablet computer 104 can be in the same local area network by accessing the same Wi-Fi access point provided by the router 103 . The first program in the mobile phone 102 is the version number A, and the first program in the tablet computer 104 is the version number B.

在图6所示的实施场景中,手机102为补丁池的挂载设备,关于补丁池的说明,可以参考前述中有关于补丁池的描述,在此不再赘述。In the implementation scenario shown in FIG. 6 , the mobile phone 102 is a mounting device of the patch pool. For the description of the patch pool, reference may be made to the description about the patch pool in the foregoing description, which will not be repeated here.

参考步骤101至步骤109所述的打补丁的方法,手机102可以从云服务器侧接收到关于 修复第一程序中第一漏洞的第一补丁代码。基于手机102自身的版本信息,如版本号A等设备相关信息,手机102将该第一补丁的解释性补丁代码机器码化,编译为补丁机器码A并存储。该手机102还可以存储有第一映射表。该第一映射表中可以记录有第一程序的不同版本号和相对于机器码A的偏移量之间的一一对应关系。第一程序的版本信息不同,其同一个函数接口的偏移地址可能会不尽相同,因此不同版本的程序会对应不同的偏移量。Referring to the patching method described in steps 101 to 109, the mobile phone 102 can receive the first patch code for repairing the first vulnerability in the first program from the cloud server side. Based on the version information of the mobile phone 102 itself, such as device-related information such as version number A, the mobile phone 102 machine-codes the explanatory patch code of the first patch, compiles it into the patch machine code A, and stores it. The mobile phone 102 may also store a first mapping table. The first mapping table may record a one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A. The version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.

手机可以获取到同一个局域网中平板电脑的ID、平板电脑中第一程序的版本号B等信息。手机查询第一映射表,版本号B对应偏移量B。手机将版本号B对应的偏移量B与补丁机器码A合成为补丁机器码B,并生成补丁文件B,补丁文件B是可以用于修复第一程序为版本号B的第一漏洞的补丁文件。The mobile phone can obtain information such as the ID of the tablet computer in the same local area network, the version number B of the first program in the tablet computer, and so on. The mobile phone queries the first mapping table, and the version number B corresponds to the offset B. The mobile phone synthesizes the offset B corresponding to the version number B and the patch machine code A to form the patch machine code B, and generates a patch file B. The patch file B is a patch that can be used to fix the first vulnerability whose first program is version B. document.

然后手机可以在局域网中发送广播,该广播的消息中可以包括挂载补丁池的手机ID、补丁文件B所支持的平板电脑ID、补丁文件B所支持的第一程序版本号B等等信息。在平板电脑应答手机的广播,手机验证平板电脑的身份之后,手机可以将补丁文件B发送至平板电脑侧。当运行第一程序时,平板电脑加载补丁文件B,补丁生效,第一程序中的第一漏洞被修复。Then the mobile phone can send a broadcast in the local area network, and the broadcast message can include the mobile phone ID of the patch pool mounted, the tablet ID supported by the patch file B, the first program version number B supported by the patch file B, and so on. After the tablet computer answers the broadcast of the mobile phone and the mobile phone verifies the identity of the tablet computer, the mobile phone can send the patch file B to the tablet computer side. When running the first program, the tablet computer loads the patch file B, the patch takes effect, and the first vulnerability in the first program is repaired.

更多细节可以参考步骤101至步骤109中的描述,在这里不再赘述。可以理解的是,图6中的实施场景仅仅是为了示例性说明本申请实施例,并不对本申请构成任何限制。For more details, reference may be made to the descriptions in steps 101 to 109, which will not be repeated here. It can be understood that, the implementation scenario in FIG. 6 is only used to illustrate the embodiments of the present application, and does not constitute any limitation to the present application.

实施例二Embodiment 2

在本实施例中,以手机和智能音箱之间的交互作为示例说明。手机可以作为挂载补丁池的设备及机器码化补丁的设备,智能音箱可以作为需要获取补丁修复程序漏洞或升级产品特性的设备。手机是具备较强的计算处理能力及较充足的内部存储空间等的终端设备。智能音箱为具备较弱的计算处理能力及较小的内部存储空间等的终端设备。手机和智能音箱处于同一个局域网中,手机可以根据智能音箱的版本信息在手机侧进行补丁的机器码化,生成机器码形式的补丁文件并存储在手机侧。当智能音箱收到与该补丁所需修复漏洞相关文件的交互请求时,可以转发至手机侧,由手机读取已被补丁修复漏洞的文件,并由手机发送交互结果或执行指令至智能音箱,补丁生效。In this embodiment, the interaction between the mobile phone and the smart speaker is used as an example for description. Mobile phones can be used as devices to mount patch pools and machine-coded patches, and smart speakers can be used as devices that need to obtain patches to fix bugs or upgrade product features. A mobile phone is a terminal device with strong computing processing capability and sufficient internal storage space. A smart speaker is a terminal device with weak computing processing power and small internal storage space. The mobile phone and the smart speaker are in the same local area network. The mobile phone can machine code the patch on the mobile phone side according to the version information of the smart speaker, generate a patch file in the form of machine code and store it on the mobile phone side. When the smart speaker receives an interactive request for a file related to the vulnerability repaired by the patch, it can be forwarded to the mobile phone, and the mobile phone will read the file that has been patched to fix the vulnerability, and the mobile phone will send the interactive result or execute the instruction to the smart speaker. The patch takes effect.

在一些实施例中,挂载补丁池的设备与机器码化补丁的设备可以不为同一个设备,比如笔记本电脑为挂载补丁池的设备,笔记本电脑可以从云服务器获取各个补丁,存储在补丁池中,该补丁池对接入同一个局域网中的设备都可见。手机、智能音箱和笔记本电脑处于同一个局域网中,手机可以获取到补丁池中的某个补丁,并根据智能音箱的版本信息在手机侧进行补丁的机器码化,生成机器码形式的补丁文件。In some embodiments, the device on which the patch pool is mounted and the device on which the machine-coded patch is mounted may not be the same device. For example, the laptop is the device on which the patch pool is mounted. The laptop can obtain each patch from the cloud server and store it in the patch pool. The patch pool is visible to all devices connected to the same LAN. The mobile phone, smart speaker and laptop are in the same local area network. The mobile phone can obtain a patch in the patch pool, and machine code the patch on the mobile phone side according to the version information of the smart speaker to generate a patch file in the form of machine code.

可以理解的是,手机和智能音箱的交互仅是为了一种示例性说明,并不对本申请实施例构成任何限制。除了智能音箱,接收补丁的设备还可以是智能手表、智能手环、智能台灯、智能耳机等具备较弱的计算处理能力或较小的内部存储空间等类型的电子设备。It can be understood that the interaction between the mobile phone and the smart speaker is only for an exemplary illustration, and does not constitute any limitation to the embodiments of the present application. In addition to smart speakers, the devices that receive patches can also be smart watches, smart bracelets, smart desk lamps, smart headphones and other electronic devices with weak computing processing power or small internal storage space.

图7示出了本申请实施例提供的另一种打补丁的方法流程。具体地,可以包括以下步骤:FIG. 7 shows another method flow of patching provided by an embodiment of the present application. Specifically, the following steps may be included:

S201、手机和智能音箱接入同一局域网中。S201, mobile phone and smart speaker are connected to the same local area network.

具体的,手机和智能音箱可以通过接入同一路由器所提供的同一Wi-Fi接入点而处于同一局域网内,手机和智能音箱可以通过该Wi-Fi接入点建立两者间的无线通信连接(也可以称为第一连接)。在该局域网中,手机中所挂载的补丁池及补丁池所在的位置等信息对于智能音箱而言可以是可见的。Specifically, the mobile phone and the smart speaker can be in the same local area network by accessing the same Wi-Fi access point provided by the same router, and the mobile phone and the smart speaker can establish a wireless communication connection between the two through the Wi-Fi access point. (may also be referred to as the first connection). In the local area network, information such as the patch pool mounted on the mobile phone and the location of the patch pool can be visible to the smart speaker.

S202、手机作为挂载补丁池的设备,可以获取云服务器下发的第一补丁(也可以称为第 一补丁文件),第一补丁可以用于修复第一程序的第一漏洞。S202. As the device for mounting the patch pool, the mobile phone can obtain the first patch (also referred to as the first patch file) issued by the cloud server, and the first patch can be used to repair the first vulnerability of the first program.

具体的,补丁池可以指的是存储有一个或多个补丁的一个或多个目录,该目录可以设置为在局域网中对其他设备可见,而对于不在同一局域网中的其他设备,该目录则对其不可见。具体地,补丁池在所挂载的手机设备上可以为某个目录,如/data/hotpatch/,将该目录的属性设置为对局域网中其他设备可见,这样,补丁池的存储位置会暴露在整个局域网中。Specifically, the patch pool may refer to one or more directories in which one or more patches are stored. The directory can be set to be visible to other devices in the local area network, and for other devices not in the same local area network, the directory is accessible to other devices. its not visible. Specifically, the patch pool can be a directory on the mounted mobile device, such as /data/hotpatch/, and the properties of the directory can be set to be visible to other devices in the local area network. In this way, the storage location of the patch pool will be exposed in the throughout the local area network.

该第一补丁的代码形式可以是解释性代码,也可以为机器码,本申请不作限制。如果是机器码形式的补丁文件,那云服务器需要在下发补丁前获取到需要打补丁的设备中程序的版本信息,然后根据版本信息在云端进行机器码化,再下发至设备侧,设备侧不需要进行编译,可以直接运行机器码。该第一补丁可以是云服务器生成后,主动推送至手机,也可以是根据手机的请求进行下发,本申请对此不作限制。The code form of the first patch may be interpretive code or machine code, which is not limited in this application. If it is a patch file in the form of machine code, the cloud server needs to obtain the version information of the program in the device that needs to be patched before issuing the patch, and then perform machine coding in the cloud according to the version information, and then send it to the device side. No need to compile, you can run machine code directly. The first patch may be actively pushed to the mobile phone after being generated by the cloud server, or may be issued according to the request of the mobile phone, which is not limited in this application.

S203、根据手机中第一程序的版本号A,手机将第一补丁的代码编译成机器码A(也可以称为第一机器码)。S203. According to the version number A of the first program in the mobile phone, the mobile phone compiles the code of the first patch into machine code A (also referred to as the first machine code).

具体的,在同一局域网中,不同的电子设备上第一程序的版本信息可能不尽相同,版本信息可以包括版本名称、版本号等信息,在本实施例中,手机中第一程序的版本信息可以称为第一版本信息。手机的第一程序的版本号为版本号A。手机还存储有第一映射表,该第一映射表中可以记录有第一程序的不同版本号和相对于机器码A的偏移量之间的一一对应关系。第一程序的版本信息不同,其同一个函数接口的偏移地址可能会不尽相同,因此不同版本的程序会对应不同的偏移量。Specifically, in the same local area network, the version information of the first program on different electronic devices may be different, and the version information may include information such as version name, version number, etc. In this embodiment, the version information of the first program in the mobile phone It can be called the first version information. The version number of the first program of the mobile phone is version number A. The mobile phone also stores a first mapping table, and the first mapping table may record the one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A. The version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.

当然,第一映射表中还可以记录有其他对应信息,比如说手机可以获取到局域网中其他电子设备目前使用的第一程序的某个版本,那么第一映射表中还可以记录该电子设备的ID与版本号的对应关系。电子设备的ID可以是MAC号,也可以是电子设备的SN号,也可以是该电子设备区别于其它电子设备的其他唯一识别号,本申请对此不作限制。Of course, other corresponding information can also be recorded in the first mapping table. For example, the mobile phone can obtain a certain version of the first program currently used by other electronic devices in the local area network, then the first mapping table can also record the information of the electronic device. The correspondence between ID and version number. The ID of the electronic device may be a MAC number, an SN number of the electronic device, or other unique identification numbers of the electronic device different from other electronic devices, which are not limited in this application.

S204、手机获取到智能音箱的ID、智能音箱中第一程序的版本号C等信息。S204, the mobile phone obtains information such as the ID of the smart speaker, the version number C of the first program in the smart speaker, and the like.

智能音箱的ID是智能音箱的唯一识别号。智能音箱的ID可以是MAC号,也可以是SN号,也可以是该智能音箱区别于其它电子设备的其他唯一识别号,本申请对此不作限制。The ID of the smart speaker is the unique identification number of the smart speaker. The ID of the smart speaker may be a MAC number, an SN number, or other unique identification numbers of the smart speaker that are different from other electronic devices, which are not limited in this application.

本实施例中,智能音箱中第一程序的版本信息可以称为第二版本信息。智能音箱的第一程序的版本号为版本号C,区别于手机中第一程序的版本号A。In this embodiment, the version information of the first program in the smart speaker may be referred to as the second version information. The version number of the first program of the smart speaker is version number C, which is different from the version number A of the first program in the mobile phone.

S205、手机查询第一映射表,版本号C对应偏移量C(也可以称为第一偏移量)。手机将版本号C对应的偏移量C与机器码A合成为机器码C(也可以称为第二机器码),并生成补丁文件C(也可以称为第二补丁文件),补丁文件C是可以用于修复第一程序为版本号C的第一漏洞的补丁文件。S205 , the mobile phone queries the first mapping table, and the version number C corresponds to the offset C (which may also be referred to as the first offset). The mobile phone synthesizes the offset C corresponding to the version number C and the machine code A into the machine code C (also called the second machine code), and generates the patch file C (also called the second patch file), the patch file C It is a patch file that can be used to fix the first vulnerability whose first program is version C.

具体的,偏移量C与机器码A合成机器码C的方式可以包括但不限于二进制合成方式,磁盘块合成方式以及代码重定位方式。关于三种重定位方式的描述,可以参照前述S105步骤中的说明,在此不再赘述。Specifically, the manner of synthesizing the machine code C with the offset C and the machine code A may include, but is not limited to, a binary synthesis manner, a disk block synthesis manner, and a code relocation manner. For the description of the three relocation modes, reference may be made to the description in the foregoing step S105, and details are not repeated here.

S206、手机在局域网中发送广播,该广播的消息中可以包括挂载补丁池的设备ID(如手机ID)、补丁文件C所支持的设备ID(如智能音箱ID)、补丁文件C所支持的第一程序版本号(如版本号C)等等。S206, the mobile phone sends a broadcast in the local area network, and the broadcast message may include the device ID (such as the mobile phone ID) of the patch pool mounted, the device ID (such as the smart speaker ID) supported by the patch file C, and the device ID supported by the patch file C. The first program version number (eg version number C) and so on.

S207、智能音箱应答手机的广播,应答消息中可以包括手机ID、智能音箱ID、版本号C等等。S207, the smart speaker responds to the broadcast of the mobile phone, and the response message may include the mobile phone ID, the smart speaker ID, the version number C, and the like.

S208、手机获取智能音箱中文件L,文件L是第一程序对应的文件。S208, the mobile phone obtains a file L in the smart speaker, where the file L is a file corresponding to the first program.

由于智能音箱的计算处理能力较差或者内部存储空间较小,所以在本实施例中,补丁文 件C在手机侧存储或读取,补丁文件C不需要存储在智能音箱侧。文件L可以包括一个或多个文件,文件L存储有第一程序的内容。Since the computing processing capability of the smart speaker is poor or the internal storage space is small, in this embodiment, the patch file C is stored or read on the side of the mobile phone, and the patch file C does not need to be stored on the side of the smart speaker. The file L may include one or more files, and the file L stores the content of the first program.

S209、手机生成文件M,文件M可以是文件L与补丁文件C所合成的文件,该手机中的文件M与智能音箱中的文件L进行关联。S209. The mobile phone generates a file M, where the file M may be a file synthesized by the file L and the patch file C, and the file M in the mobile phone is associated with the file L in the smart speaker.

手机可以获取智能音箱中第一程序对应的文件L,并在手机侧将补丁文件C与文件L合成为文件M,该文件M是已经修复第一漏洞的一个或多个的第一程序文件。该文件M可以存储在手机侧。文件M也可以包括一个或多个文件。The mobile phone can obtain the file L corresponding to the first program in the smart speaker, and combine the patch file C and the file L into a file M on the mobile phone side, where the file M is one or more first program files for which the first vulnerability has been fixed. The file M can be stored on the mobile phone side. File M may also include one or more files.

在智能音箱侧,可以设置将智能音箱中的文件L与局域网中的文件M进行路径关联,当文件L收到交互请求时,该交互请求会被转发至文件M。On the smart speaker side, you can set the path association between the file L in the smart speaker and the file M in the local area network. When the file L receives an interactive request, the interactive request will be forwarded to the file M.

S210、智能音箱中的文件L收到交互请求。S210. The file L in the smart speaker receives an interaction request.

S211、智能音箱将该对于文件L的交互请求转发至手机中的文件M。S211 , the smart speaker forwards the interactive request for the file L to the file M in the mobile phone.

S212、手机读取文件M,生成交互结果或指令,并将交互结果或指令发送至智能音箱。S212, the mobile phone reads the file M, generates an interaction result or instruction, and sends the interaction result or instruction to the smart speaker.

S213,智能音箱执行交互结果或指令,第一补丁生效,智能音箱的第一程序的第一漏洞被修复。S213, the smart speaker executes the interactive result or instruction, the first patch takes effect, and the first loophole of the first program of the smart speaker is repaired.

具体的,手机可以通过通信连接发送相关指令或交互结果至智能音箱。智能音箱接收到该指令或交互结果后,执行相关的功能,修复第一程序中的第一漏洞。Specifically, the mobile phone can send relevant instructions or interactive results to the smart speaker through the communication connection. After receiving the instruction or interaction result, the smart speaker executes related functions to fix the first loophole in the first program.

S214、智能音箱断开与局域网的连接。S214. The smart speaker is disconnected from the local area network.

在智能音箱断开与手机的通信连接时,手机中所缓存的用于解决第一漏洞的文件M可以继续被保存在手机中,待下次智能音箱接入局域网时继续生效使用;文件M也可以随着断网被删除,待下次智能音箱接入局域网时手机再重新生成文件M。When the smart speaker is disconnected from the communication connection with the mobile phone, the file M cached in the mobile phone for solving the first vulnerability can continue to be saved in the mobile phone, and will continue to take effect when the smart speaker is connected to the local area network next time; the file M also It can be deleted when the network is disconnected, and the mobile phone will regenerate the file M when the smart speaker is connected to the local area network next time.

S215、智能音箱中的文件L收到交互请求。S215. The file L in the smart speaker receives an interaction request.

S216、由于已断开与局域网的连接,智能音箱无法读取局域网中修复第一漏洞的文件M,因此文件L被读取,智能音箱中第一程序中的第一漏洞未被修复。S216. Since the connection with the local area network has been disconnected, the smart speaker cannot read the file M in the local area network that fixes the first vulnerability, so the file L is read, and the first vulnerability in the first program in the smart speaker is not repaired.

本实施例中,智能音箱侧的漏洞修复需要依赖局域网中手机提供的补丁文件,因此智能音箱需要在联网状态下才可以将漏洞修复。如果智能音箱断开与局域网的连接,就获取不到修复漏洞的补丁文件,对应漏洞问题无法得到修复。In this embodiment, the vulnerability repair on the side of the smart speaker needs to rely on the patch file provided by the mobile phone in the local area network, so the smart speaker needs to be connected to the network to repair the vulnerability. If the smart speaker is disconnected from the local area network, the patch file to fix the vulnerability cannot be obtained, and the corresponding vulnerability cannot be fixed.

图8为方法实施例二所述的打补丁的方法的场景示意图。FIG. 8 is a schematic diagram of a scene of the method for patching according to the second method embodiment.

如图8示例性所示,该实施场景可以包括:手机102、路由器103以及智能音箱107。手机102和智能音箱107可以通过接入路由器103提供的同一个Wi-Fi接入点而处于同一局域网中。其中,手机102中的第一程序为版本号A,智能音箱107的第一程序为版本号C。As exemplarily shown in FIG. 8 , the implementation scenario may include: a mobile phone 102 , a router 103 , and a smart speaker 107 . The mobile phone 102 and the smart speaker 107 can be in the same local area network by accessing the same Wi-Fi access point provided by the router 103 . The first program in the mobile phone 102 is version A, and the first program in the smart speaker 107 is version C.

在图8所示的实施场景中,手机102为补丁池的挂载设备,关于补丁池的说明,可以参考前述中有关于补丁池的描述,在此不再赘述。In the implementation scenario shown in FIG. 8 , the mobile phone 102 is a mounting device of the patch pool. For the description of the patch pool, reference may be made to the description about the patch pool in the foregoing description, which will not be repeated here.

参考步骤201至步骤216所述的打补丁的方法,手机102可以从云服务器侧接收到关于修复第一程序中第一漏洞的第一补丁代码。基于手机102自身的版本信息,如版本号A等设备相关信息,手机102将该第一补丁的解释性补丁代码机器码化,编译为补丁机器码A并存储。该手机102还可以存储有第一映射表。该第一映射表中可以记录有第一程序的不同版本号和相对于机器码A的偏移量之间的一一对应关系。第一程序的版本信息不同,其同一个函数接口的偏移地址可能会不尽相同,因此不同版本的程序会对应不同的偏移量。Referring to the patching method described in steps 201 to 216, the mobile phone 102 may receive the first patch code for fixing the first vulnerability in the first program from the cloud server side. Based on the version information of the mobile phone 102 itself, such as device-related information such as version number A, the mobile phone 102 machine-codes the explanatory patch code of the first patch, compiles it into the patch machine code A, and stores it. The mobile phone 102 may also store a first mapping table. The first mapping table may record a one-to-one correspondence between different version numbers of the first program and the offsets relative to the machine code A. The version information of the first program is different, and the offset address of the same function interface may be different, so different versions of the program will correspond to different offsets.

手机可以获取到同一个局域网中智能音箱的ID、智能音箱中第一程序的版本号C等信息。手机查询第一映射表,版本号C对应偏移量C。手机将版本号C对应的偏移量C与补丁机器码A合成为补丁机器码C,并生成补丁文件C,补丁文件C是可以用于修复第一程序为版本 号C的第一漏洞的补丁文件。The mobile phone can obtain information such as the ID of the smart speaker in the same local area network and the version number C of the first program in the smart speaker. The mobile phone queries the first mapping table, and the version number C corresponds to the offset C. The mobile phone synthesizes the offset C corresponding to the version number C and the patch machine code A into the patch machine code C, and generates a patch file C, which is a patch that can be used to fix the first vulnerability whose first program is version C. document.

然后手机可以在局域网中发送广播,该广播的消息中可以包括挂载补丁池的手机ID、补丁文件C所支持的智能音箱ID、补丁文件C所支持的第一程序版本号C等等信息。在智能音箱应答手机的广播,手机验证智能音箱的身份之后,手机可以获取智能音箱中第一程序对应的文件L,并且在手机侧将文件L与补丁文件C合成为文件M,该文件M是已经修复第一漏洞的文件,并存储在手机侧。在智能音箱侧,可以设置将智能音箱中的文件L与局域网中的文件M进行路径关联,当文件L收到交互请求时,该交互请求会被转发至文件M。Then the mobile phone can send a broadcast in the local area network, and the broadcast message can include the mobile phone ID of the patch pool mounted, the smart speaker ID supported by the patch file C, the first program version number C supported by the patch file C and so on. After the smart speaker responds to the broadcast of the mobile phone and the mobile phone verifies the identity of the smart speaker, the mobile phone can obtain the file L corresponding to the first program in the smart speaker, and synthesize the file L and the patch file C into the file M on the mobile phone side, and the file M is The file of the first vulnerability has been fixed and stored on the mobile phone side. On the smart speaker side, you can set the path association between the file L in the smart speaker and the file M in the local area network. When the file L receives an interactive request, the interactive request will be forwarded to the file M.

当智能音箱中的文件L收到交互请求时,智能音箱将该对于文件L的交互请求转发至手机中的文件M。手机读取文件M,生成交互结果或指令,并将交互结果或指令发送至智能音箱。智能音箱执行交互结果或指令,第一补丁生效,智能音箱的第一程序的第一漏洞被修复。当智能音箱断开与局域网的连接时,第一补丁失效,第一漏洞无法得到修复。When the file L in the smart speaker receives the interactive request, the smart speaker forwards the interactive request for the file L to the file M in the mobile phone. The mobile phone reads the file M, generates interactive results or instructions, and sends the interactive results or instructions to the smart speaker. The smart speaker executes the interactive result or instruction, the first patch takes effect, and the first loophole of the first program of the smart speaker is fixed. When the smart speaker is disconnected from the local area network, the first patch fails and the first vulnerability cannot be fixed.

更多细节可以参考步骤101至步骤109中的描述,在这里不再赘述。可以理解的是,图8中的实施场景仅仅是为了示例性说明本申请实施例,并不对本申请构成任何限制。For more details, reference may be made to the descriptions in steps 101 to 109, which will not be repeated here. It can be understood that, the implementation scenario in FIG. 8 is only for illustrating the embodiments of the present application, and does not constitute any limitation to the present application.

下面介绍电子设备100上的用于应用程序菜单的示例性用户界面。An exemplary user interface for the application menu on the electronic device 100 is described below.

图9A示出了一种示例性用户界面901。FIG. 9A shows an exemplary user interface 901 .

用户界面901可以包括:状态栏902、日历指示符903、其他应用程序图标904、页面指示符905以及具有常用应用程序图标的托盘906。User interface 901 may include a status bar 902, a calendar indicator 903, other application icons 904, a page indicator 905, and a tray 906 with icons of frequently used applications.

状态栏902可以包括:移动通信信号(又可以称为蜂窝信号)的一个或多个信号强度指示符、无线高保真(wireless fidelity,Wi-Fi)信号的一个或多个信号强度指示符、电池状态指示符等。Status bar 902 may include: one or more signal strength indicators for mobile communication signals (also known as cellular signals), one or more signal strength indicators for wireless fidelity (Wi-Fi) signals, battery status indicators, etc.

日历指示符903可以用于指示当前时间,例如日期、星期几、时分信息等。Calendar indicator 903 may be used to indicate the current time, such as date, day of the week, hour and minute information, and the like.

其他应用程序图标904可以例如:音乐图标、计算器图标、浏览器图标、设置图标等。Other application icons 904 may be, for example, a music icon, a calculator icon, a browser icon, a settings icon, and the like.

页面指示符905可以用于指示用户当前浏览的哪一个页面中的应用程序。用户可以左右滑动其他应用程序图标的区域,来浏览其他页面中的应用程序图标。The page indicator 905 may be used to indicate the application in which page the user is currently viewing. Users can swipe left and right in the area of other application icons to browse application icons in other pages.

具有常用应用程序图标的托盘906可以展示:相机图标、通讯录图标、电话图标、信息图标等。A tray 906 with icons of commonly used applications may display: a camera icon, an address book icon, a phone icon, an information icon, and the like.

在一些实施例中,图9A示例性所示的用户界面901可以为主界面(home screen)。In some embodiments, the user interface 901 exemplarily shown in FIG. 9A may be the home screen.

在其他一些实施例中,电子设备还可以包括主屏幕键。该主屏幕键可以是实体按键,也可以是虚拟按键。该主屏幕按键可以用于接收用户的指令,将当前显示的UI返回到主界面,这样可以方便用户随时查看主屏幕。上述指令具体可以是用户单次按下主屏幕键的操作指令,也可以是用户在短时间内连续两次按下主屏幕键的操作指令,还可以是用户在预定时间内长按主屏幕键的操作指令。在本申请其他一些实施例中,主屏幕键还可以集成指纹识别器,以便用户在按下主屏幕键的时候,随之进行指纹采集和识别。In some other embodiments, the electronic device may also include a home screen key. The home screen key can be a physical key or a virtual key. The home screen button can be used to receive the user's instruction and return the currently displayed UI to the home interface, so that it is convenient for the user to view the home screen at any time. The above instruction may be an operation instruction for the user to press the home screen key once, or an operation instruction for the user to press the home screen key twice in a short period of time, or the user presses the home screen key for a predetermined period of time. operation instructions. In some other embodiments of the present application, the home screen key may also be integrated with a fingerprint reader, so that when the user presses the home screen key, fingerprint collection and identification are performed accordingly.

可以理解的是,图9A仅仅示例性示出了电子设备100上的用户界面,不应构成对本申请实施例的限定。It can be understood that, FIG. 9A only exemplarily shows the user interface on the electronic device 100 , and should not constitute a limitation to the embodiments of the present application.

下面分别描述本申请涉及的应用场景以及电子设备100上实现的用户界面的一些实施例。The application scenarios involved in the present application and some embodiments of the user interface implemented on the electronic device 100 are described below.

图9A、图9B示出了手机102获取本局域网内电子设备100的相关权限时,电子设备100 示例性示出的用户界面。9A and 9B show an exemplary user interface of the electronic device 100 when the mobile phone 102 obtains the relevant authority of the electronic device 100 in the local area network.

如图9A所示,当同一局域网内的手机102需要获取电子设备100的相关信息(例如第一程序的版本号、电子设备100的ID等)时,电子设备100可以在用户界面901中显示出提示框907,该提示框907可以用于提示用户是否给予手机102相应的权限。例如,该提示框907显示的提示信息可以是文本“是否允许网络中手机102获取您的设备信息?”。不限于文本信息,该提示信息还可以是电子设备100输出的语音或其他类型的提示信息等,本申请对此不作限制。该提示框907还可以显示相应的控件,以便用户选择是否给予手机102相应的权限。响应于用户在控件上的触摸操作(例如点击),电子设备100可以执行该控件对应的仅本次允许手机102获取电子设备100相关信息的选项、始终允许手机102获取电子设备100相关信息的选项或者拒绝手机102获取电子设备100相关信息的选项。例如,该提示框907可以显示“允许”控件、“始终允许”控件和“拒绝”控件,检测到用户作用在“始终允许”控件上的触摸操作(例如点击),电子设备100可以执行在联网状态下始终允许手机102获取电子设备100相关信息的指令。As shown in FIG. 9A , when the mobile phone 102 in the same local area network needs to obtain the relevant information of the electronic device 100 (for example, the version number of the first program, the ID of the electronic device 100 , etc.), the electronic device 100 can display in the user interface 901 Prompt box 907, the prompt box 907 can be used to prompt the user whether to give the mobile phone 102 the corresponding permission. For example, the prompt information displayed in the prompt box 907 may be the text "Do you allow the mobile phone 102 in the network to obtain your device information?". Not limited to text information, the prompt information may also be voice output from the electronic device 100 or other types of prompt information, etc., which is not limited in this application. The prompt box 907 can also display corresponding controls, so that the user can choose whether to give the mobile phone 102 corresponding permissions. In response to a user's touch operation (such as a click) on the control, the electronic device 100 may execute the option corresponding to the control to allow the mobile phone 102 to obtain information related to the electronic device 100 only this time, and to always allow the mobile phone 102 to obtain information related to the electronic device 100. Or reject the option of the mobile phone 102 to obtain the relevant information of the electronic device 100 . For example, the prompt box 907 may display an "Allow" control, an "Always Allow" control and a "Deny" control, and after detecting a user's touch operation (such as a click) on the "Always Allow" control, the electronic device 100 may perform a In this state, the mobile phone 102 is always allowed to obtain the instruction of the relevant information of the electronic device 100 .

如图9B所示,当同一局域网内的手机102向电子设备100发送修复电子设备100上第一漏洞的补丁文件时,电子设备100可以在用户界面901上显示出提示框908,该提示框908可以用于提示用户是否允许手机102向电子设备100更新补丁。例如,该提示框显示的信息可以是文本“是否允许网络中手机102为您更新补丁?”。不限于文本信息,该提示信息还可以是电子设备100输出的语音或其他类型的提示信息等,本申请对此不作限制。该提示框908还可以显示相应的控件,以便用户选择是否允许手机102向电子设备100更新补丁。响应于用户在控件上的触摸操作(例如点击),电子设备100可以执行该控件对应的仅本次允许手机102本次向电子设备100发送补丁的选项、始终允许手机102本次向电子设备100发送补丁的选项或者拒绝手机102向电子设备100发送补丁的选项。例如,该提示框908可以显示“允许”控件、“始终允许”控件和“拒绝”控件,检测到用户作用在“始终允许”控件上的触摸操作(例如点击),电子设备100可以执行在联网状态下始终允许手机102向电子设备100更新补丁的指令。As shown in FIG. 9B , when the mobile phone 102 in the same local area network sends the patch file for repairing the first vulnerability on the electronic device 100 to the electronic device 100, the electronic device 100 may display a prompt box 908 on the user interface 901, the prompt box 908 It can be used to prompt the user whether to allow the mobile phone 102 to update the patch to the electronic device 100 . For example, the information displayed in the prompt box may be the text "Does the mobile phone 102 in the network allow the mobile phone 102 to update the patch for you?". Not limited to text information, the prompt information may also be voice output from the electronic device 100 or other types of prompt information, etc., which is not limited in this application. The prompt box 908 may also display corresponding controls for the user to select whether to allow the mobile phone 102 to update the patch to the electronic device 100 or not. In response to a user's touch operation (for example, a click) on the control, the electronic device 100 may execute the option corresponding to the control to only allow the mobile phone 102 to send patches to the electronic device 100 this time, and to always allow the mobile phone 102 to send the patch to the electronic device 100 this time. The option to send the patch or to deny the phone 102 the option to send the patch to the electronic device 100 . For example, the prompt box 908 may display an "Allow" control, an "Always Allow" control, and a "Deny" control, and upon detecting a user's touch operation (eg, a click) on the "Always Allow" control, the electronic device 100 may perform a The state always allows the mobile phone 102 to update the patch to the electronic device 100 instruction.

图10A、图10B、图10C示出了与实施本申请技术方案后所展现出的技术效果相关的用户界面。FIG. 10A , FIG. 10B , and FIG. 10C show user interfaces related to the technical effects exhibited after implementing the technical solutions of the present application.

图10A示例性示出了一种实施场景。该实施场景可以包括:手机102、智能手表109以及平板电脑104。手机102可以与智能手表109、平板电脑104通过接入同一个无线接入点而处于同一个局域网中,互相建立通信连接。FIG. 10A exemplarily shows an implementation scenario. The implementation scenario may include: a mobile phone 102 , a smart watch 109 and a tablet computer 104 . The mobile phone 102 and the smart watch 109 and the tablet computer 104 can be in the same local area network by accessing the same wireless access point, and establish a communication connection with each other.

手机102的用户界面1001可以为手机102发现云侧服务器生成有所需补丁时所显示。用户界面1001可以包括标题栏1004、程序版本更新主界面1005等。The user interface 1001 of the mobile phone 102 may be displayed when the mobile phone 102 finds that the required patch is generated by the cloud server. The user interface 1001 may include a title bar 1004, a program version update main interface 1005, and the like.

标题栏1004可以包括当前页面指示符,和返回导航控件。当前页面指示符可用于指示当前页面,例如文本信息“系统更新”可用于指示当前页面用于展示系统更新相关信息。不限于文本信息,当前页面指示符还可以是图标。返回导航控件可用于监听通过该控件的操作(如触摸操作)。响应于该操作,电子设备可由当前界面返回到上一级界面。Title bar 1004 may include a current page indicator, and return navigation controls. The current page indicator can be used to indicate the current page, for example, the text information "system update" can be used to indicate that the current page is used to display system update related information. Not limited to text information, the current page indicator may also be an icon. Returning a navigation control can be used to listen for actions (such as touches) through the control. In response to this operation, the electronic device can return to the previous interface from the current interface.

程序版本更新主界面1005可以展示一个或多个版本更新相关信息条目,该一个或多个版本更新相关信息条目可以包括:电子设备发现新补丁提示条目、补丁包大小信息条目、更新时间信息条目、更新日志信息条目等。The program version update main interface 1005 may display one or more version update related information items, and the one or more version update related information items may include: an electronic device discovers a new patch prompt item, a patch package size information item, an update time information item, Update log information entries, etc.

在程序版本更新主界面1005的每个版本更新相关信息的条目上,对应有相应的标题和文字说明。例如,电子设备发现新补丁提示条目对应的标题为“发现新补丁”,补丁包大小信息 条目对应的标题为“补丁包”,文字说明为发现的新版本号“大小:2.32MB”,更新时间信息条目对应的标题为“更新时间”,文字说明为“日期:2020年9月20日”,更新日志信息条目对应的标题为“更新日志”,文字说明为“本次更新增加了系统安全修复补丁,修复系统漏洞”等。On each item of version update related information in the program version update main interface 1005, there are corresponding titles and text descriptions. For example, when the electronic device finds a new patch, the corresponding title is "New Patch Found", the corresponding title of the patch package size information entry is "Patch Package", the text description is the found new version number "Size: 2.32MB", and the update time The title corresponding to the information entry is "Update Time", the text description is "Date: September 20, 2020", the title corresponding to the update log information entry is "Update Log", and the text description is "This update adds system security fixes. Patches, Fix System Vulnerabilities" etc.

程序版本更新主界面1005也可以包括“更新”操作控件1006、“取消”操作控件1007,可用于监听通过该控件的操作(如触摸操作)。响应于作用于“更新”或“取消”的操作,电子设备将进行更新补丁,或,取消更新补丁。The program version update main interface 1005 may also include an "update" operation control 1006 and a "cancel" operation control 1007, which can be used to monitor operations (such as touch operations) through the controls. In response to the operation acting on "update" or "cancel", the electronic device will update the patch, or cancel the update patch.

在其他一些实施例中,程序版本更新页面可以展示其他程序版本更新的相关信息,包括但不限于例如第三方应用程序。版本更新页面可以增加版本更新相关信息条目,也可以减少版本更新相关信息条目,本申请对此不作限制。In some other embodiments, the program version update page may display other program version update related information, including but not limited to, for example, third-party applications. On the version update page, information items related to version update may be added, or information items related to version update may be decreased, which is not limited in this application.

智能手表109的用户界面1002、平板电脑104的用户界面1003可以包括有与前述图9A中用户界面901部分或全部相同的界面元素(例如状态栏、日历指示符、应用程序图标、页面指示符以及常用应用程序图标的托盘等等),在此不再赘述。The user interface 1002 of the smart watch 109 and the user interface 1003 of the tablet 104 may include some or all of the same interface elements (eg, status bar, calendar indicator, application icon, page indicator, and trays for commonly used application icons, etc.), which will not be repeated here.

图10B中示例性示出的手机102的用户界面1008,可以是在接收下载云侧服务器下发的补丁时,手机102上所显示的用户界面,该用户界面1008可以用于提示用户从云侧服务器下载补丁的进度。例如,可以显示出图标1009,该图标1009提示用户补丁正在下载,下载的进度为25%。该用户界面1008还可以显示出文本信息“正在下载补丁”,以提示用户补丁正在下载。不限于文本信息,该提示信息还可以是手机102输出的语音或其他类型的提示信息等,本申请对此不作限制。该用户界面1008还可以显示取消控件1010,用于监听作用于该控件上的触摸操作(例如点击)。响应于该“取消”操作,手机102可以取消从云侧服务器下载补丁。The user interface 1008 of the mobile phone 102 exemplarily shown in FIG. 10B can be the user interface displayed on the mobile phone 102 when receiving and downloading the patch issued by the cloud server. The user interface 1008 can be used to prompt the user to download the patch from the cloud server The progress of the server downloading patches. For example, an icon 1009 may be displayed that informs the user that the patch is being downloaded and that the download progress is 25%. The user interface 1008 may also display the text message "Downloading Patch" to remind the user that the patch is being downloaded. Not limited to text information, the prompt information may also be voice output from the mobile phone 102 or other types of prompt information, etc., which is not limited in this application. The user interface 1008 may also display a cancel control 1010 for listening to touch operations (eg, clicks) acting on the control. In response to the "cancel" operation, the mobile phone 102 can cancel the patch download from the cloud-side server.

图10C示例性示出了手机102的用户界面1011、智能手表109的用户界面1012、平板电脑104的用户界面1013。上述用户界面可以提示用户,在该实施场景中,手机102、智能手表109以及平板电脑104中不同版本的第一程序的第一漏洞均已被修复。例如,用户界面1011可以显示出文字提示信息“第一漏洞已修复”,并显示出手机102所拥有的第一程序的版本号信息“版本10.0”,用户界面1012可以显示出文字提示信息“第一漏洞已修复”,并显示出智能手表109所拥有的第一程序的版本号信息“版本8.0”,用户界面1013可以显示出文字提示信息“第一漏洞已修复”,并显示出平板电脑104所拥有的第一程序的版本号信息“版本9.0”。不限于文本信息,该提示信息还可以是电子设备输出的语音或其他类型的提示信息等,本申请对此不作限制。FIG. 10C exemplarily shows the user interface 1011 of the cell phone 102 , the user interface 1012 of the smart watch 109 , and the user interface 1013 of the tablet computer 104 . The above user interface may prompt the user that, in this implementation scenario, the first vulnerabilities of different versions of the first program in the mobile phone 102 , the smart watch 109 and the tablet computer 104 have all been repaired. For example, the user interface 1011 may display the text prompt information "The first vulnerability has been fixed", and display the version number information "Version 10.0" of the first program possessed by the mobile phone 102, and the user interface 1012 may display the text prompt information "The first program" A bug has been fixed”, and the version number information “Version 8.0” of the first program owned by the smart watch 109 is displayed, and the user interface 1013 can display the text prompt information “The first bug has been fixed”, and display the tablet computer 104 The version number information "version 9.0" of the owned first program. Not limited to text information, the prompt information may also be voice output by the electronic device or other types of prompt information, etc., which is not limited in this application.

在图10A、图10B、图10C所示的实施例中,仅有手机102从云服务器下载了修复第一漏洞的第一补丁,手机102可以在手机侧根据手机102的版本10.0将第一补丁进行机器码化。然后手机可以根据所获取到的智能手表109的版本8.0,平板电脑104的版本9.0所对应的机器码偏移量,生成新的补丁机器码。关于平板电脑104获取手机102中的补丁的具体方法可参考方法实施例一,关于智能手表109获取手机102中的补丁的具体方法可参考方法实施例二,在这里不再赘述。与手机102位于同一个局域网中的平板电脑104和智能手表109不需要再从云服务器重复下载同一补丁,因此在图10B中手机102在下载补丁,智能手表109和平板电脑104并没有下载补丁。但是在手机102下载完成补丁时,同一个局域网中不同程序版本的智能手表109和平板电脑104会自动修复该补丁针对的同一个漏洞。实施本实施例,可以避免重复下载同一个补丁,节省了带宽,提高了打补丁效率。In the embodiments shown in FIG. 10A , FIG. 10B , and FIG. 10C , only the mobile phone 102 downloads the first patch to fix the first vulnerability from the cloud server. Machine code. Then the mobile phone can generate a new patch machine code according to the obtained machine code offset corresponding to the version 8.0 of the smart watch 109 and the version 9.0 of the tablet computer 104 . For the specific method for the tablet computer 104 to obtain the patch in the mobile phone 102, please refer to the method embodiment 1, and for the specific method for the smart watch 109 to obtain the patch in the mobile phone 102, please refer to the second method embodiment, which will not be repeated here. The tablet 104 and the smart watch 109 located in the same local area network as the mobile phone 102 do not need to download the same patch from the cloud server repeatedly, so in FIG. However, when the mobile phone 102 downloads the patch, the smart watch 109 and the tablet computer 104 with different program versions in the same local area network will automatically repair the same vulnerability targeted by the patch. By implementing this embodiment, repeated downloading of the same patch can be avoided, bandwidth is saved, and patching efficiency is improved.

可以理解的是,图9A、图9B、图10A、图10B、图10C仅为一些用户界面的示例,不 对本申请其他实施例构成任何限制。It can be understood that FIGS. 9A , 9B, 10A, 10B, and 10C are only examples of some user interfaces, and do not constitute any limitation to other embodiments of the present application.

上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。As used in the above embodiments, the term "when" may be interpreted to mean "if" or "after" or "in response to determining..." or "in response to detecting..." depending on the context. Similarly, depending on the context, the phrases "on determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining..." or "in response to determining..." or "on detecting (the stated condition or event)" or "in response to the detection of (the stated condition or event)".

在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general purpose computer, special purpose computer, computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server, or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, optical fiber, digital subscriber line) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes an integration of one or more available media. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented. The process can be completed by instructing the relevant hardware by a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed , which may include the processes of the foregoing method embodiments. The aforementioned storage medium includes: ROM or random storage memory RAM, magnetic disk or optical disk and other mediums that can store program codes.

Claims (12)

一种打补丁的方法,其特征在于,所述方法包括:A method for patching, the method comprising: 第一电子设备与第二电子设备建立第一连接;establishing a first connection between the first electronic device and the second electronic device; 所述第一电子设备获取第一补丁文件,所述第一补丁文件用于修复第一程序的第一漏洞,所述第一漏洞存在于所述第二电子设备的所述第一程序中;obtaining, by the first electronic device, a first patch file, where the first patch file is used to repair a first vulnerability of a first program, and the first vulnerability exists in the first program of the second electronic device; 所述第一电子设备根据所述第一程序的第一版本信息,将所述第一补丁编译为第一机器码;The first electronic device compiles the first patch into a first machine code according to the first version information of the first program; 所述第一电子设备将所述第一机器码与第一偏移量合成为第二机器码,并将所述第二机器码烧录生成第二补丁文件,其中,所述第一偏移量是根据第二版本信息所确定,所述第二版本信息为第二电子设备中第一程序的版本信息,所述第二版本信息为所述第一电子设备通过所述第一连接从所述第二电子设备处获取到的,所述第二补丁文件用于修复版本信息为所述第二版本信息的第一程序的第一漏洞。The first electronic device synthesizes the first machine code and the first offset into a second machine code, and burns the second machine code to generate a second patch file, wherein the first offset The amount is determined according to the second version information, the second version information is the version information of the first program in the second electronic device, and the second version information is the first electronic device through the first connection obtained from the second electronic device, the second patch file is used to repair the first vulnerability of the first program whose version information is the second version information. 根据权利要求1所述的方法,其特征在于,所述第一偏移量是根据第二版本信息所确定,具体包括:The method according to claim 1, wherein the first offset is determined according to the second version information, and specifically includes: 所述第一偏移量是根据第一映射表中记录的第二版本信息与所述第一偏移量的对应关系所确定。The first offset is determined according to the correspondence between the second version information recorded in the first mapping table and the first offset. 根据权利要求1或2所述的方法,其特征在于,还包括:The method according to claim 1 or 2, further comprising: 所述第一电子设备向所述第二电子设备发送所述第二补丁文件,所述第二补丁文件用于与所述第二电子设备中的第一程序文件合成为第二程序文件,其中,所述第一程序文件是所述第二电子设备中未修复所述第一漏洞的所述第一程序的可执行文件,所述第二程序文件是所述第二电子设备中已修复所述第一漏洞的所述第一程序的可执行文件。The first electronic device sends the second patch file to the second electronic device, where the second patch file is used to synthesize the second program file with the first program file in the second electronic device, wherein , the first program file is the executable file of the first program in the second electronic device that has not repaired the first vulnerability, and the second program file is the second electronic device that has been repaired The executable file of the first program of the first vulnerability. 根据权利要求1或2所述的方法,其特征在于,还包括:The method according to claim 1 or 2, further comprising: 当所述第二电子设备收到的对于第一程序文件的交互请求时,所述第一电子设备通过所述第一连接接收到对于所述第二程序文件的所述交互请求,其中,所述第一程序文件是所述第二电子设备中未修复所述第一漏洞的所述第一程序的可执行文件,所述第二程序文件是所述第一电子设备将所述第一程序文件与所述第二补丁文件合成得到的,所述第二程序文件是已修复所述第一漏洞的所述第一程序的可执行文件,所述第二电子设备上的所述第一程序文件关联与所述第一电子设备上的所述第二程序文件;When the second electronic device receives the interaction request for the first program file, the first electronic device receives the interaction request for the second program file through the first connection, wherein the The first program file is an executable file of the first program in the second electronic device that does not fix the first vulnerability, and the second program file is the first electronic device that uses the first program The file is synthesized with the second patch file, the second program file is the executable file of the first program that has repaired the first vulnerability, and the first program on the second electronic device file association with the second program file on the first electronic device; 所述第一电子设备读取所述第二程序文件,生成交互结果或可执行指令,并通过所述第一连接向所述第二电子设备发送所述交互结果或可执行指令。The first electronic device reads the second program file, generates interaction results or executable instructions, and sends the interaction results or executable instructions to the second electronic device through the first connection. 根据权利要求1-4中任一项所述的方法,其特征在于,在所述第一电子设备生成第二补丁文件之后,还包括:The method according to any one of claims 1-4, wherein after the first electronic device generates the second patch file, the method further comprises: 所述第一电子设备发送广播信息,所述广播信息包括:所述第一电子设备的身份标识号、所述第二电子设备的身份标识号、所述第二补丁文件所适用的所述第二版本信息;The first electronic device sends broadcast information, and the broadcast information includes: the identification number of the first electronic device, the identification number of the second electronic device, and the first electronic device to which the second patch file is applicable. Second version information; 在接收到所述第二电子设备响应于所述广播信息的应答信息,所述第一电子设备确定所述第二补丁文件为所述第二电子设备用于修复所述第一程序的第一漏洞的补丁文件,所述应 答信息包括:所述第一电子设备的身份标识号、所述第二电子设备的身份标识号、所述第二电子设备中所述第一程序的所述第二版本信息。After receiving the response information from the second electronic device in response to the broadcast information, the first electronic device determines that the second patch file is the first patch file used by the second electronic device to repair the first program A vulnerability patch file, the response information includes: the identification number of the first electronic device, the identification number of the second electronic device, the second electronic device of the first program in the second electronic device Version Information. 一种打补丁的方法,其特征在于,所述包括:A method for patching, characterized in that the method comprises: 第一电子设备与第二电子设备建立第一连接;establishing a first connection between the first electronic device and the second electronic device; 所述第一电子设备获取第一补丁文件,所述第一补丁文件用于修复第一程序的第一漏洞,所述第一漏洞存在于所述第二电子设备的所述第一程序中;obtaining, by the first electronic device, a first patch file, where the first patch file is used to repair a first vulnerability of a first program, and the first vulnerability exists in the first program of the second electronic device; 所述第一电子设备根据所述第一程序的第一版本信息,将所述第一补丁编译为第一机器码;The first electronic device compiles the first patch into a first machine code according to the first version information of the first program; 所述第一电子设备将所述第一机器码与第一偏移量合成为第二机器码,并将所述第二机器码烧录生成第二补丁文件,其中,所述第一偏移量是根据第二版本信息所确定,所述第二版本信息为第二电子设备中第一程序的版本信息,所述第二版本信息为所述第一电子设备通过所述第一连接从所述第二电子设备处获取到的,所述第二补丁文件用于修复版本信息为所述第二版本信息的第一程序的第一漏洞。The first electronic device synthesizes the first machine code and the first offset into a second machine code, and burns the second machine code to generate a second patch file, wherein the first offset The amount is determined according to the second version information, the second version information is the version information of the first program in the second electronic device, and the second version information is the first electronic device through the first connection obtained from the second electronic device, the second patch file is used to repair the first vulnerability of the first program whose version information is the second version information. 根据权利要求6所述的方法,其特征在于,所述第一偏移量是根据第二版本信息所确定,具体包括:The method according to claim 6, wherein the first offset is determined according to the second version information, and specifically includes: 所述第一偏移量是根据第一映射表中记录的第二版本信息与所述第一偏移量的对应关系所确定。The first offset is determined according to the correspondence between the second version information recorded in the first mapping table and the first offset. 根据权利要求6或7所述的方法,其特征在于,还包括:The method according to claim 6 or 7, further comprising: 所述第二电子设备接收所述第一电子设备所生成的所述第二补丁文件;The second electronic device receives the second patch file generated by the first electronic device; 所述第二电子设备将第一程序文件与所述第二补丁文件合成为第二程序文件,其中,所述第一程序文件是所述第二电子设备中未修复所述第一漏洞的所述第一程序的可执行文件,所述第二程序文件是所述第二电子设备中已修复所述第一漏洞的所述第一程序的可执行文件。The second electronic device synthesizes the first program file and the second patch file into a second program file, wherein the first program file is all parts of the second electronic device that have not repaired the first vulnerability. the executable file of the first program, and the second program file is the executable file of the first program that has fixed the first vulnerability in the second electronic device. 根据权利要求6或7所述的方法,其特征在于,还包括:The method according to claim 6 or 7, further comprising: 所述第二电子设备收到的对于第一程序文件的交互请求;an interaction request for the first program file received by the second electronic device; 所述第二电子设备通过所述第一连接将所述交互请求转发给所述第一电子设备的第二程序文件,其中,所述第一程序文件是所述第二电子设备中未修复所述第一漏洞的所述第一程序的可执行文件,所述第二程序文件是所述第一电子设备将所述第一程序文件与所述第二补丁文件合成得到的,所述第二程序文件是已修复所述第一漏洞的所述第一程序的可执行文件,所述第二电子设备上的所述第一程序文件关联与所述第一电子设备上的所述第二程序文件;The second electronic device forwards the interaction request to a second program file of the first electronic device through the first connection, wherein the first program file is the unrepaired part of the second electronic device. The executable file of the first program of the first vulnerability, the second program file is obtained by synthesizing the first program file and the second patch file by the first electronic device, and the second program file is obtained by synthesizing the first program file and the second patch file by the first electronic device. The program file is an executable file of the first program with the first vulnerability fixed, and the first program file on the second electronic device is associated with the second program on the first electronic device document; 所述第一电子设备读取所述第二程序文件,生成交互结果或可执行指令,并通过所述第一连接向所述第二电子设备发送所述交互结果或可执行指令;The first electronic device reads the second program file, generates interactive results or executable instructions, and sends the interactive results or executable instructions to the second electronic device through the first connection; 响应于所述交互结果或可执行指令,所述第二电子设备运行所述第一漏洞已被修复的所述第一程序。In response to the interaction result or the executable instruction, the second electronic device executes the first program in which the first vulnerability has been fixed. 根据权利要求6-9中任一项所述的方法,其特征在于,在所述第一电子设备生成第二补丁文件之后,还包括:The method according to any one of claims 6-9, wherein after the first electronic device generates the second patch file, the method further comprises: 所述第一电子设备发送广播信息,所述广播信息包括:所述第一电子设备的身份标识号、所述第二电子设备的身份标识号、所述第二补丁文件所适用的所述第二版本信息;The first electronic device sends broadcast information, and the broadcast information includes: the identification number of the first electronic device, the identification number of the second electronic device, and the first electronic device to which the second patch file is applicable. Second version information; 响应于所述广播信息,所述第二电子设备向所述第一电子设备发送应答信息,所述应答信息包括:所述第一电子设备的身份标识号、所述第二电子设备的身份标识号、所述第二电子设备中所述第一程序的所述第二版本信息;In response to the broadcast information, the second electronic device sends response information to the first electronic device, where the response information includes: an identification number of the first electronic device, an identification number of the second electronic device number, the second version information of the first program in the second electronic device; 所述第一电子设备确定所述第二补丁文件为所述第二电子设备用于修复所述第一程序的第一漏洞的补丁文件。The first electronic device determines that the second patch file is a patch file used by the second electronic device to repair the first vulnerability of the first program. 一种电子设备,其特征在于,包括通信装置、存储器以及耦合于所述存储器的处理器,多个应用程序,以及一个或多个程序;所述处理器在执行所述一个或多个程序时,使得所述电子设备实现如权利要求1至5、权利要求6至10中任一项所述的方法。An electronic device, characterized by comprising a communication device, a memory and a processor coupled to the memory, multiple application programs, and one or more programs; when the processor executes the one or more programs , so that the electronic device implements the method according to any one of claims 1 to 5 and 6 to 10 . 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在电子设备上运行时,使得所述电子设备执行如权利要求1至5、权利要求6至10中任一项所述的方法。A computer-readable storage medium, comprising instructions, characterized in that, when the instructions are executed on an electronic device, the electronic device is made to perform the execution of any one of claims 1 to 5 and 6 to 10. Methods.
PCT/CN2021/133755 2020-11-30 2021-11-27 Patching method, related apparatus, and system Ceased WO2022111664A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011377442.X 2020-11-30
CN202011377442.XA CN114579181B (en) 2020-11-30 2020-11-30 Patching method, related equipment and system

Publications (1)

Publication Number Publication Date
WO2022111664A1 true WO2022111664A1 (en) 2022-06-02

Family

ID=81753996

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/133755 Ceased WO2022111664A1 (en) 2020-11-30 2021-11-27 Patching method, related apparatus, and system

Country Status (2)

Country Link
CN (1) CN114579181B (en)
WO (1) WO2022111664A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116700738A (en) * 2022-09-20 2023-09-05 荣耀终端有限公司 Application management method, electronic equipment and system
CN117763559A (en) * 2023-12-04 2024-03-26 超聚变数字技术有限公司 Vulnerability determination method and electronic equipment
CN119668629A (en) * 2024-10-29 2025-03-21 深圳开鸿数字产业发展有限公司 Device image burning and testing method, system and development panel

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8396325B1 (en) * 2009-04-27 2013-03-12 Google Inc. Image enhancement through discrete patch optimization
CN105786537A (en) * 2014-12-24 2016-07-20 中兴通讯股份有限公司 Hot patch realization method and device
CN111666096A (en) * 2020-07-02 2020-09-15 腾讯科技(深圳)有限公司 Hot updating method and device for target application, storage medium and electronic equipment

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156651B (en) * 2011-03-02 2015-05-06 奇智软件(北京)有限公司 Method and device for realizing installation of patches
CN104468632A (en) * 2014-12-31 2015-03-25 北京奇虎科技有限公司 Loophole attack prevention method, device and system
DE102017102147B4 (en) * 2016-10-11 2018-09-20 Elmos Semiconductor Aktiengesellschaft Subsequent patchable memory (OTP) with bit memory cells and method of patching same
CN106843933A (en) * 2016-12-27 2017-06-13 北京五八信息技术有限公司 A kind of leak restorative procedure of application program, mobile terminal and patch server
CN107437029A (en) * 2017-08-23 2017-12-05 北京奇虎科技有限公司 Leak restorative procedure, leak prosthetic device and server
CN109376535B (en) * 2018-08-14 2022-03-04 中国信息安全测评中心 Vulnerability analysis method and system based on intelligent symbolic execution
WO2020034227A1 (en) * 2018-08-17 2020-02-20 华为技术有限公司 Multimedia content synchronization method and electronic device
CN110109695B (en) * 2019-04-17 2021-08-27 华为技术有限公司 Patching method, related device and system
CN110633090B (en) * 2019-08-14 2022-04-12 华为技术有限公司 Patching method, related device and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8396325B1 (en) * 2009-04-27 2013-03-12 Google Inc. Image enhancement through discrete patch optimization
CN105786537A (en) * 2014-12-24 2016-07-20 中兴通讯股份有限公司 Hot patch realization method and device
CN111666096A (en) * 2020-07-02 2020-09-15 腾讯科技(深圳)有限公司 Hot updating method and device for target application, storage medium and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116700738A (en) * 2022-09-20 2023-09-05 荣耀终端有限公司 Application management method, electronic equipment and system
CN116700738B (en) * 2022-09-20 2023-12-12 荣耀终端有限公司 Application management methods, electronic devices and systems
CN117763559A (en) * 2023-12-04 2024-03-26 超聚变数字技术有限公司 Vulnerability determination method and electronic equipment
CN119668629A (en) * 2024-10-29 2025-03-21 深圳开鸿数字产业发展有限公司 Device image burning and testing method, system and development panel

Also Published As

Publication number Publication date
CN114579181B (en) 2025-07-11
CN114579181A (en) 2022-06-03

Similar Documents

Publication Publication Date Title
CN110633090B (en) Patching method, related device and system
WO2021159746A1 (en) File sharing method and system, and related device
WO2022111664A1 (en) Patching method, related apparatus, and system
CN114546969A (en) File sharing method and device and electronic equipment
WO2021238376A1 (en) Function pack loading method and apparatus, and server and electronic device
CN114969769A (en) Access control method, electronic device and system
WO2021073337A1 (en) Method and apparatus for installing plug-in, and storage medium
CN113741993B (en) Method and device for compiling plug-in dex file
WO2022253158A1 (en) User privacy protection method and apparatus
CN117687708B (en) Power-on method and electronic device
CN115114619A (en) Access control method, electronic device and system
CN116483734A (en) Compiler-based stub insertion method, system and related electronic equipment
CN114443109B (en) Patch repair method, electronic device and storage medium
CN113885928B (en) Program updating method and electronic device
WO2023051357A1 (en) Method for running virtual device
CN116700811A (en) Applied operating method and related device
CN114168115A (en) Communication system, application downloading method and device
CN115203716A (en) Permission synchronization method, related device and system
CN114996078A (en) Compilation control method and device for dex file
CN113590346A (en) Method and electronic equipment for processing service request
CN117707563B (en) Application resource processing method and related equipment
CN114692641A (en) Method and device for acquiring characters
CN117009023B (en) Method and related device for displaying notification information
CN119271256B (en) Software configuration method and related equipment
CN116048594B (en) Software upgrade method and related devices

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21897164

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21897164

Country of ref document: EP

Kind code of ref document: A1