WO2022156379A1 - 一种热修复方法及装置 - Google Patents

一种热修复方法及装置 Download PDF

Info

Publication number
WO2022156379A1
WO2022156379A1 PCT/CN2021/134732 CN2021134732W WO2022156379A1 WO 2022156379 A1 WO2022156379 A1 WO 2022156379A1 CN 2021134732 W CN2021134732 W CN 2021134732W WO 2022156379 A1 WO2022156379 A1 WO 2022156379A1
Authority
WO
WIPO (PCT)
Prior art keywords
repaired
sdk
project
patch
sdks
Prior art date
Application number
PCT/CN2021/134732
Other languages
English (en)
French (fr)
Inventor
魏君成
Original Assignee
北京字节跳动网络技术有限公司
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 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Priority to US18/008,796 priority Critical patent/US20230229431A1/en
Publication of WO2022156379A1 publication Critical patent/WO2022156379A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Definitions

  • the present application relates to the technical field of software maintenance, and in particular, to a thermal repair method and device.
  • Hotfix technology also known as patch technology, is a technical means that can quickly and inexpensively repair abnormalities in software product lines.
  • a software product needs to provide multiple components that can be accessed externally, and multiple components that can be optionally accessed have dependencies on each other.
  • the software development kits ( Software Development Kit, SDK) may be integrated into the same Android application installation package (Android Application package, APK).
  • APK Android Application package
  • each SDK cannot be regarded as a completely independent SDK when hot-fixing, and all these SDKs need to be hot-fixed.
  • the SDK hot-repair solutions in the prior art are generally solutions for hot-repairing a single SDK.
  • an APK can be selected to access one or more of multiple SDKs, if the solution for hot-repairing a single SDK is reused, one by one For each SDK to be hot-fixed, when multiple SDKs are connected to the same APK at the same time, it is very likely to cause conflicts between the hot-fix patches of the SDK, resulting in the failure of the hot-fix.
  • the present application provides a hot repair method and apparatus, which can avoid conflicts between hot repair patches of each SDK when hot repair is performed on multiple SDKs that can be selectively accessed and have dependencies.
  • thermo repair method including:
  • the project to be repaired includes at least two SDKs with dependencies, and the compiled file of each SDK includes the instrumentation code corresponding to each method to be repaired in the SDK ;
  • the instrumentation code of the target method to be repaired is retained in the compilation of one of the two or more SDKs In the file, delete the instrumentation code of the target to-be-repaired method described in the compilation files of other SDKs;
  • the hot repair patch includes a patch corresponding to the instrumentation code of each method to be repaired;
  • the hot repair patch is sent to the access terminal.
  • the method further includes:
  • mapping table corresponding to each SDK In the process of compiling each SDK of the project to be repaired, a mapping table corresponding to each SDK is generated; the mapping table corresponding to each SDK records the corresponding relationship between each method to be repaired and the method identifier in the corresponding SDK;
  • the judging whether each method to be repaired exists in two or more SDKs of the project to be repaired includes:
  • the set of mapping relationship tables is the set that the mapping relationship tables corresponding to each SDK of the project to be repaired are formed;
  • the target method identifier is a duplicate method identifier, it is determined that the method to be repaired corresponding to the target method identifier exists in two or more SDKs of the project to be repaired.
  • mapping table corresponding to each SDK is generated, including:
  • the method signature of each method to be repaired in each SDK is encrypted based on a preset encryption algorithm, and the encrypted value corresponding to each method to be repaired is obtained, including:
  • the method signature of each method to be repaired in each SDK is encrypted based on MD5, and the MD5 value of each method signature is obtained.
  • the method further includes:
  • the method identifier of each method to be repaired is added to the instrumentation code corresponding to each method to be repaired;
  • the method identifier of each method to be repaired is added to the patch corresponding to the instrumentation code of each method to be repaired;
  • the generating a hot repair patch includes:
  • the target project depends on the compilation file of each SDK of the project to be repaired;
  • a patch of the target project is generated, and the patch of the target project is used as the hot repair patch.
  • the generating the patch of the target project includes:
  • the code set includes the code of each SDK corresponding to the compiled file of the project to be repaired;
  • a patch of the target project is generated according to the code to be repaired.
  • thermo repair device including:
  • the compilation unit is used to compile each SDK of the project to be repaired separately, and obtain the compilation files of each SDK;
  • the project to be repaired includes at least two SDKs with dependencies, and the compilation files of each SDK include the corresponding SDK to be repaired
  • the instrumentation code of the method is used to compile each SDK of the project to be repaired separately, and obtain the compilation files of each SDK;
  • the project to be repaired includes at least two SDKs with dependencies, and the compilation files of each SDK include the corresponding SDK to be repaired.
  • a processing unit for judging whether each method to be repaired exists in two or more SDKs of the project to be repaired
  • a revision unit configured to retain the instrumentation code of the target method to be repaired in the two or more SDKs of the project to be repaired when it is determined that the target method to be repaired exists in the two or more SDKs of the project to be repaired In the compilation file of one of the SDKs, delete the instrumentation code of the target to-be-repaired method described in the compilation files of the other SDKs;
  • the hot repair patch includes a patch corresponding to the instrumentation code of each method to be repaired
  • a sending unit configured to send the hot repair patch to the access terminal when the access terminal accesses the compiled file of at least one SDK of the project to be repaired.
  • the compiling unit is further configured to generate a mapping table corresponding to each SDK in the process of compiling each SDK of the project to be repaired respectively; the mapping table corresponding to each SDK records each method to be repaired and a method identifier in the corresponding SDK the corresponding relationship;
  • the processing unit is specifically configured to determine whether the set of mapping relation tables contains duplicate method identifiers; if the target method identifier is a duplicate method identifier, determine that the method to be repaired corresponding to the target method identifier is existing in the method to be repaired. In two or more SDKs of the project;
  • the set of mapping relationship tables is a set composed of mapping relationship tables corresponding to each SDK of the item to be repaired.
  • the compiling unit is specifically configured to acquire the method signature of each method to be repaired in each SDK in the process of compiling each SDK of the project to be repaired respectively ; Encrypt the method signature of each method to be repaired in each SDK based on the preset encryption algorithm, and obtain the encrypted value corresponding to each method to be repaired; establish the corresponding relationship between each method to be repaired and the corresponding encrypted value in each SDK, and generate the corresponding encrypted value of each method to be repaired.
  • the mapping table corresponding to the SDK is specifically configured to acquire the method signature of each method to be repaired in each SDK in the process of compiling each SDK of the project to be repaired respectively ; Encrypt the method signature of each method to be repaired in each SDK based on the preset encryption algorithm, and obtain the encrypted value corresponding to each method to be repaired; establish the corresponding relationship between each method to be repaired and the corresponding encrypted value in each SDK, and generate the corresponding encrypted value of each method to be repaired.
  • the mapping table corresponding to the SDK is specifically configured to acquire
  • the compiling unit is specifically configured to encrypt the method signature of each method to be repaired in each SDK based on MD5, and obtain the MD5 value of each method signature.
  • the apparatus further includes: a verification unit;
  • the compiling unit is further configured to add the method identifier of each to-be-repaired method to the corresponding instrumentation code of each to-be-repaired method in the process of performing stake-insertion on each to-be-repaired method;
  • the generating unit is further configured to add the method identifier of each method to be repaired to the patch corresponding to the instrumentation code of each method to be repaired in the process of generating the hot repair patch;
  • the verification unit is used to judge whether the method identifier in each instrumentation code is the same as the method identifier in the called patch; if the method identifier in one or more instrumentation codes is different from the method identifier in the called patch, then Confirm that the hot-fix patch is wrong; if the method identifier in each instrumentation is the same as the method identifier in the called patch, confirm that the hot-fix patch is correct.
  • the generating unit is specifically used to create a target project, and the target project depends on the compilation file of each SDK of the project to be repaired; to generate a patch of the target project, The patch of the target project is used as the hot repair patch.
  • the generating unit is specifically configured to obtain a code set, read the code to be repaired in the code set, and generate a patch of the target project according to the code to be repaired;
  • the code set includes the code of the compiled file corresponding to each SDK of the item to be repaired; the code to be repaired is the code corresponding to the method to be repaired of each SDK.
  • embodiments of the present application provide an electronic device, including: a memory and a processor, where the memory is used to store a computer program; the processor is used to execute the first aspect or any possible implementation of the first aspect when the computer program is invoked method of thermal repair.
  • an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. Repair method.
  • an embodiment of the present application provides a computer program product, where the computer program product includes a computer program carried on a computer-readable medium, and when the computer program is executed by a processor, causes the processor to implement the first aspect Or the thermal repair method described in any possible implementation manner of the first aspect.
  • the hot repair method provided by the embodiment of the present application first compiles each SDK of the project to be repaired to obtain the compiled files of each SDK, and judges whether each method to be repaired exists in two or more SDKs, and if the target is to be repaired If the method exists in two or more SDKs, the instrumentation code of the target method to be repaired is kept in the compilation file of one of the two or more SDKs, and the compilation files of other SDKs are deleted. The instrumentation code of the target method to be repaired described in, and then generate a hot repair patch including the patch corresponding to the instrumentation code of each method to be repaired, and finally access the at least one SDK of the project to be repaired at the access end. When the file is compiled, the hot repair patch is sent to the access terminal.
  • FIG. 1 is one of the flowcharts of the thermal repair method provided by the embodiment of the present application.
  • FIG. 2 is the second flow chart of the thermal repair method provided by the embodiment of the present application.
  • FIG. 3 is the third flowchart of the thermal repair method provided by the embodiment of the present application.
  • FIG. 4 is one of the schematic structural diagrams of the thermal repair device provided by the embodiment of the present application.
  • FIG. 5 is the second schematic structural diagram of the thermal repair device provided by the embodiment of the present application.
  • FIG. 6 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
  • words such as “exemplary” or “for example” are used to represent examples, illustrations or illustrations. Any embodiments or designs described in the embodiments of the present application as “exemplary” or “such as” should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as “exemplary” or “such as” is intended to present the related concepts in a specific manner.
  • the meaning of "plurality” refers to two or more.
  • the embodiment of the present application provides a thermal repair method.
  • the thermal repair method provided by the embodiment of the present application includes S101-S105:
  • the project to be repaired includes at least two SDKs with dependencies, and the compiled files of each SDK include instrumentation codes corresponding to the methods to be repaired in the SDK.
  • each SDK in the project to be repaired is compiled as an independent SDK, and the compilation file of any SDK includes the instrumentation of each method to be repaired in the SDK code.
  • the compiled file of SDK1 includes the instrumentation code of each method to be repaired in SDK1.
  • an instrumentation plug-in can be introduced into each SDK of the project to be repaired, and each method to be repaired in each class (class) in the corresponding SDK can be instrumented through the introduced instrumentation plug-in, thereby completing each SDK.
  • Compile get the compiled files of each SDK.
  • the compilation file of each SDK may include the mapping file of each SDK.
  • S102 Determine whether each method to be repaired exists in two or more SDKs of the project to be repaired.
  • each method to be repaired exists only in one SDK of the project to be repaired, the following S104 is executed, and if the target method to be repaired exists in two or more SDKs of the project to be repaired , the following S103 is performed first, and then the following S104 is performed.
  • the target method to be repaired may be any method to be repaired.
  • the instrumentation code of the method 1 to be repaired in the compiled file of the first SDK can be retained, and the compiled file of the second SDK and the third SDK can be deleted.
  • the method of retaining the instrumentation code of the target method to be repaired in the compilation file of one SDK, and deleting the instrumentation code of the target method to be repaired in the compilation file of other SDKs can be: randomly select a compilation file of the SDK, and keep the selection. The compiled file of the SDK remains unchanged, and the instrumentation code of the target method to be repaired in the other SKD compiled files is deleted.
  • the hot repair patch includes a patch corresponding to the instrumentation code of each method to be repaired.
  • a hot-fix patch may be generated based on each method (to-be-repaired method with instrumented code) that needs to be hot-fixed in each SDK of the project to be repaired.
  • the hot repair method provided by the embodiment of the present application first compiles each SDK of the project to be repaired to obtain the compiled files of each SDK, and judges whether each method to be repaired exists in two or more SDKs. If the repair method exists in two or more SDKs, the instrumentation code of the target method to be repaired is kept in the compilation file of one of the two or more SDKs, and the compilation of other SDKs is deleted.
  • the instrumentation code of the target method to be repaired described in the file then generate the instrumentation code including each method to be repaired, and then generate a hot repair patch including the patch corresponding to the instrumentation code of each method to be repaired, and finally When accessing the compiled file of at least one SDK of the project to be repaired, the access terminal sends the hot repair patch to the access terminal.
  • the thermal repair method provided by another embodiment of the present application includes S201-S207:
  • the project to be repaired includes at least two SDKs with dependencies, and the compiled files of each SDK include instrumentation codes corresponding to the methods to be repaired in the SDK.
  • the mapping table corresponding to each SDK records the corresponding relationship between each method to be repaired and the method identifier in the corresponding SDK.
  • mapping table corresponding to any SDK records the corresponding relationship between each method to be repaired and the method identifier in the SDK.
  • mapping table corresponding to the SDK2 records the correspondence between each method to be repaired and the method identifier in the SDK2.
  • the specific implementation manner of S202 may include the following steps a to c.
  • Step a In the process of compiling each SDK of the project to be repaired, the method signature of each method to be repaired in each SDK is obtained.
  • all classes in the SDK can be obtained, then all methods in each class can be obtained, and then all classes in each class can be obtained from the The method to be repaired is determined in the method, and finally the method signature of each method to be repaired is extracted.
  • Step b Encrypt the method signature of each method to be repaired in each SDK based on a preset encryption algorithm, and obtain an encrypted value corresponding to each method to be repaired.
  • the preset encryption algorithm is a message digest algorithm (Message-Digest Algorithm, MD5); based on the preset encryption algorithm, encrypt the method signature of each method to be repaired in each SDK, and obtain each
  • the encrypted value corresponding to the method to be repaired includes: encrypting the method signature of each method to be repaired in each SDK based on MD5, and obtaining the MD5 value of the signature of each method.
  • the preset encryption algorithm in the embodiment of the present application may also be other encryption algorithms.
  • RSA encryption algorithm DES encryption algorithm, etc.
  • Step c Establish the correspondence between each method to be repaired and the corresponding encrypted value in each SDK, and generate a mapping table corresponding to each SDK.
  • the encrypted value corresponding to any method to be repaired is an encrypted value obtained by encrypting the method signature of the method to be repaired based on the preset encryption algorithm.
  • the preset encryption algorithm is MD5
  • the encryption value corresponding to any method to be repaired is the MD5 value of the method to be repaired.
  • the set of mapping relationship tables is a set composed of mapping relationship tables corresponding to each SDK of the item to be repaired.
  • the same method and the same method to be repaired must not exist in the same SDK, but there may be the same method and the same method to be repaired in multiple SDKs, and the method signature and method identification of the same method are also the same. , so the set of mapping tables may include duplicate method IDs.
  • each method identifier only appears in one corresponding relationship, it is determined that the set of mapping relation tables does not contain duplicate method identifiers, and the following S206-S207 are performed; and if the target method identifier appears in two or more In two or more correspondences, the target method identifier is determined to be a duplicate method identifier, and the following S204-S207 are performed.
  • S205 Retain the instrumentation code of the method to be repaired corresponding to the target identifier in the compilation file of one of the two or more SDKs, and delete the to-be-repaired code corresponding to the target identifier in the compilation files of other SDKs The instrumentation code for the method.
  • the hot repair patch includes a patch corresponding to the instrumentation code of each method to be repaired.
  • the thermal repair method provided by the above embodiment is a refinement of the thermal repair method shown in FIG. 1 , and the technical effect that can be achieved is similar to the technical effect that can be achieved by the thermal repair method shown in FIG. 1 . It is not repeated here.
  • the thermal repair method provided by another embodiment of the present application includes S301-S306:
  • the project to be repaired includes at least two SDKs with dependencies, and the compiled files of each SDK include instrumentation codes corresponding to the methods to be repaired in the SDK.
  • S302. Determine whether each method to be repaired exists in two or more SDKs of the project to be repaired.
  • the target project depends on the compilation file of each SDK of the project to be repaired.
  • the implementation manner of the above S305 may include the following steps I to III:
  • Step 1 Obtain a code set.
  • the code set includes the code of the compiled file corresponding to each SDK of the project to be repaired.
  • Step II Read the code to be repaired in the code set.
  • the to-be-repaired code is the code corresponding to the to-be-repaired method of each SDK.
  • Step III Generate a patch of the target project according to the code to be repaired.
  • the above embodiment creates an external project that depends on the compiled file of each SDK of the project to be repaired, then generates a patch of the external project, and uses the patch of the target project as the hot repair patch, so the above embodiment can
  • the patches of all the to-be-repaired methods of the to-be-repaired item are managed as a whole, and it is not necessary to manage the patches of each to-be-repaired method individually, so the above-mentioned embodiment can further simplify the management of hot-repair patches.
  • a hot repair patch including patches corresponding to all the instrumentation codes is sent to the access terminal. Even if the access terminal does not access the compiled file of a certain SDK in the project to be repaired, it will not affect the access terminal. The patches of the compiled files of the SDK take effect, but the patches of the compiled files that are not connected will not take effect.
  • the hot repair method provided by the embodiment of the present application further includes:
  • the method identifier of each method to be repaired is added to the instrumentation code of each method to be repaired;
  • the method identifier of each method to be repaired is added to the patch corresponding to the instrumentation code of each method to be repaired;
  • the corresponding method identifier is added to the instrumentation code
  • the patch of the method to be repaired is generated
  • the corresponding method identifier is added to the corresponding patch, and the insertion is verified before the patch takes effect.
  • the method identifier in the stub code is the same as the method identifier in the patch can be checked whether the generated hot-fix patch is correct. Therefore, the embodiment of the present application can ensure that the hot-fix patch takes effect correctly.
  • the above embodiment can also prevent fake patches from taking effect, thereby improving the security of software products.
  • the embodiment of the present application further provides a thermal repair device, which corresponds to the foregoing method embodiment.
  • this device embodiment does not implement the foregoing method.
  • the details in the examples are described one by one, but it should be clear that the thermal repair apparatus in this embodiment can correspondingly implement all the contents in the foregoing method embodiments.
  • FIG. 4 is a schematic structural diagram of a thermal repair apparatus provided in an embodiment of the present application. As shown in FIG. 4 , the thermal repair apparatus 400 provided in this embodiment includes:
  • the compiling unit 41 is used for compiling each SDK of the project to be repaired separately, and obtaining the compiled files of each SDK; the project to be repaired includes at least two SDKs with dependencies, and the compiled files of each SDK include the corresponding SDKs in the corresponding SDK.
  • a processing unit 42 configured to judge whether each method to be repaired exists in two or more SDKs of the project to be repaired;
  • the revision unit 43 is configured to, when it is determined that the target method to be repaired exists in two or more SDKs of the project to be repaired, retain the instrumentation code of the target method to be repaired in the two or more SDKs of the project to be repaired In the compilation file of one of the above SDKs, delete the instrumentation code of the target to-be-repaired method described in the compilation files of the other SDKs;
  • a generating unit 44 is used to generate a hot repair patch; the hot repair patch includes a patch corresponding to the instrumentation code of each method to be repaired;
  • the sending unit 45 is configured to send the hot repair patch to the access terminal when the access terminal accesses the compiled file of at least one SDK of the project to be repaired.
  • the compiling unit 41 is further configured to generate a mapping table corresponding to each SDK in the process of compiling each SDK of the project to be repaired respectively; the mapping table corresponding to each SDK records each method and method to be repaired in the corresponding SDK The corresponding relationship of the identification;
  • the processing unit 42 is specifically configured to determine whether a duplicate method identifier is included in the set of mapping relation tables; if the target method identifier is a duplicate method identifier, determine that the method to be repaired corresponding to the target method identifier exists in the to-be-repaired method. In two or more SDKs of the project;
  • the set of mapping relationship tables is a set composed of mapping relationship tables corresponding to each SDK of the item to be repaired.
  • the compiling unit 41 is specifically configured to obtain a method for each to-be-repaired method in each SDK during the process of compiling each SDK of the to-be-repaired project. Signature; encrypt the method signature of each method to be repaired in each SDK based on the preset encryption algorithm, and obtain the encrypted value corresponding to each method to be repaired; establish the corresponding relationship between each method to be repaired and the corresponding encrypted value in each SDK, and generate The mapping table corresponding to each SDK.
  • the compiling unit 41 is specifically configured to encrypt the method signature of each method to be repaired in each SDK based on MD5, and obtain the MD5 value of each method signature.
  • the thermal repair device 400 further includes: a verification unit 46;
  • the compiling unit 41 is further configured to add the method identifier of each method to be repaired to the instrumentation code of each method to be repaired in the process of performing the instrumentation of each method to be repaired;
  • the generating unit 44 is further configured to add the method identifier of each method to be repaired to the patch corresponding to the instrumentation code of each method to be repaired in the process of generating the hot repair patch;
  • the verification unit 46 is used to judge whether the method identifier in each instrumentation code is the same as the method identifier in the called patch; if the method identifier in one or more instrumentation codes is different from the method identifier in the called patch , it is confirmed that the hot-fix patch is wrong; if the method identifier in each instrumentation code is the same as the method identifier in the called patch, it is confirmed that the hot-fix patch is correct.
  • the generating unit 44 is specifically configured to create a target project, and the target project depends on the compilation file of each SDK of the project to be repaired; generate a patch of the target project , and use the patch of the target project as the hot-fix patch.
  • the generating unit 44 is specifically configured to obtain a code set, read the code to be repaired in the code set, and generate a patch of the target project according to the code to be repaired ;
  • the code set includes the code of the compiled file corresponding to each SDK of the item to be repaired; the code to be repaired is the code corresponding to the method to be repaired of each SDK.
  • FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device provided by this embodiment includes: a memory 61 and a processor 62.
  • the memory 61 is used for storing computer programs; the processor 62 is used for The steps of the hot repair method provided by the above embodiments are executed when the computer program is invoked.
  • Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the hot repair method provided by the foregoing embodiments are implemented.
  • the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein.
  • the processor can be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable processor Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • CPU Central Processing Unit
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash memory
  • Computer readable media includes both persistent and non-permanent, removable and non-removable storage media.
  • a storage medium can be implemented by any method or technology for storing information, and the information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

本申请实施例提供了一种热修复方法及装置,涉及软件维护技术领域。该方法包括:对每一个SDK进行编译获取各SDK的编译文件;待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括各待修复方法的插桩代码;若目标待修复方法存在于多个SDK中,则将目标待修复方法的插桩代码保留在其中一个中,删除其它中目标待修复方法的插桩代码;生成热修复补丁,热修复补丁包括每一个待修复方法的插桩代码对应的补丁;在接入端接入待修复项目的至少一个SDK的编译文件时,向接入端发送热修复补丁。本申请实施例用于在对多个可选择接入且具有依赖关系的SDK进行热修复时,避免各SDK的热修复补丁之间冲突。

Description

一种热修复方法及装置
本申请要求于2021年01月19日提交中国专利局、申请号为202110071098.X、申请名称为“一种热修复方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及软件维护技术领域,尤其涉及一种热修复方法及装置。
背景技术
热修复(hotfix)技术,又称为补丁(patch)技术,是一种能够快速、低成本修复软件产品线上异常的技术手段。
在一些应用场景中,软件产品需要对外提供多个可选择接入的组件,且多个可选择接入的组件相互之间具有依赖关系,这些可选择接入的组件对应的软件开发工具包(Software Development Kit,SDK)可能会被接入同一安卓应用安装包(Android Application package,APK)中。在此类应用场景中,进行热修复时不能将各SDK视为完全独立的SDK,需要对这些SDK均进行热修复。现有技术中的SDK热修复方案普遍是针对单个SDK进行热修复的方案,由于APK可选择接入多个SDK中的一个或多个,因此若复用针对单个SDK进行热修复的方案逐一对每一个SDK进行热修复,则在多个SDK被同时接入同一个APK中时,非常可能会造成SDK的热修复补丁之间冲突,进而导致热修复失败。
发明内容
有鉴于此,本申请提供了一种热修复方法及装置,能够在对多个可选择接入且具有依赖关系的SDK进行热修复时,避免各SDK的热修复补丁之间冲突。
为了实现上述目的,本申请实施例提供技术方案如下:
第一方面,本申请的实施例提供了一种热修复方法,包括:
分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件;所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码;
若目标待修复方法存在于所述待修复项目的两个或两个以上SDK中,则将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码;
生成热修复补丁;所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁;
在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
作为本申请实施例一种可能的实施方式,所述方法还包括:
在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表;各SDK对应的映射表记录有对应SDK中每一个待修复方法与方法标识的对应关系;
所述判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中,包括:
判断映射关系表集合中是否包含重复的方法标识;所述映射关系表集合为所述待修复 项目的每一个SDK对应的映射关系表组成的集合;
若目标方法标识为重复的方法标识,则确定所述目标方法标识对应的待修复方法为存在于所述待修复项目的两个或两个以上SDK中。
作为本申请实施例一种可能的实施方式,所述在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表,包括:
在分别对所述待修复项目的每一个SDK进行编译的过程中,获取各SDK中每一个待修复方法的方法签名;
基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值;
建立各SDK中各待修复方法与对应的加密值的对应关系,生成各SDK对应的映射表。
作为本申请实施例一种可能的实施方式,所述基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值,包括:
基于MD5对各SDK中每一个待修复方法的方法签名进行加密,获取各方法签名的MD5值。
作为本申请实施例一种可能的实施方式,所述方法还包括:
在对各待修复方法进行插桩的过程中,将各待修复方法的方法标识添加到各待修复方法对应的插桩代码中;
在生成热修复补丁的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码对应的补丁中;
判断各插桩代码中的方法标识与调用的补丁中的方法标识是否相同;
若一个或多个插桩代码中的方法标识与调用的补丁中的方法标识不同,则确认所述热修复补丁错误;
若各插桩代码中的方法标识与调用的补丁中的方法标识均相同,则确认所述热修复补丁正确。
作为本申请实施例一种可能的实施方式,所述生成热修复补丁,包括:
创建目标工程,所述目标工程依赖所述待修复项目的每一个SDK的编译文件;
生成所述目标工程的补丁,并将所述目标工程的补丁作为所述热修复补丁。
作为本申请实施例一种可能的实施方式,所述生成所述目标工程的补丁,包括:
获取代码集合,所述代码集合包括所述待修复项目的每一个SDK对应编译文件的代码;
在所述代码集合中读取待修复代码,所述待修复代码为各SDK的待修复方法对应的代码;
根据所述待修复代码生成所述目标工程的补丁。
第二方面,本申请实施例提供一种热修复装置,包括:
编译单元,用于分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件;所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码;
处理单元,用于判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK 中;
修订单元,用于在确定目标待修复方法存在于所述待修复项目的两个或两个以上SDK中时,将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码;
生成单元,用于生成热修复补丁;所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁;
下发单元,用于在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
作为本申请实施例一种可能的实施方式,
所述编译单元,还用于在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表;各SDK对应的映射表记录有对应SDK中每一个待修复方法与方法标识的对应关系;
所述处理单元,具体用于判断映射关系表集合中是否包含重复的方法标识;若目标方法标识为重复的方法标识,则确定所述目标方法标识对应的待修复方法为存在于所述待修复项目的两个或两个以上SDK中;
其中,所述映射关系表集合为所述待修复项目的每一个SDK对应的映射关系表组成的集合。
作为本申请实施例一种可能的实施方式,所述编译单元,具体用于在分别对所述待修复项目的每一个SDK进行编译的过程中,获取各SDK中每一个待修复方法的方法签名;基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值;建立各SDK中各待修复方法与对应的加密值的对应关系,生成各SDK对应的映射表。
作为本申请实施例一种可能的实施方式,所述编译单元,具体用于基于MD5对各SDK中每一个待修复方法的方法签名进行加密,获取各方法签名的MD5值。
作为本申请实施例一种可能的实施方式,所述装置还包括:校验单元;
所述编译单元,还用于在对各待修复方法进行插桩的过程中,将各待修复方法的方法标识添加到各待修复方法对应的插桩代码中;
所述生成单元,还用于在生成热修复补丁的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码对应的补丁中;
所述校验单元,用于判断各插桩代码中的方法标识与调用的补丁中的方法标识是否相同;若一个或多个插桩中的方法标识与调用的补丁中的方法标识不同,则确认所述热修复补丁错误;若各插桩中的方法标识与调用的补丁中的方法标识均相同,则确认所述热修复补丁正确。
作为本申请实施例一种可能的实施方式,所述生成单元,具体用于创建目标工程,所述目标工程依赖所述待修复项目的每一个SDK的编译文件;生成所述目标工程的补丁,并将所述目标工程的补丁作为所述热修复补丁。
作为本申请实施例一种可能的实施方式,所述生成单元,具体用于获取代码集合,在所述代码集合中读取待修复代码,根据所述待修复代码生成所述目标工程的补丁;
其中,所述代码集合包括所述待修复项目的每一个SDK对应编译文件的代码;所述待修复代码为各SDK的待修复方法对应的代码。
第三方面,本申请实施例提供一种电子设备,包括:存储器和处理器,存储器用于存储计算机程序;处理器用于在调用计算机程序时执行第一方面或第一方面任一种可能的实施方式所述的热修复方法。
第四方面,本申请实施例提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现第一方面或第一方面任一种可能的实施方式所述的热修复方法。
第五方面,本申请实施例提供一种计算机程序产品,所述计算机程序产品包括承载在计算机可读介质上的计算机程序,当所述计算机程序被处理器执行时,使得处理器实现第一方面或第一方面任一种可能的实施方式所述的热修复方法。
本申请实施例提供的热修复方法先分别对待修复项目的每一个SDK进行编译获取各SDK的编译文件,并判断每个待修复方法是否存在于两个或两个以上SDK中,若目标待修复方法为存在于两个或两个以上SDK中,则将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码,然后再生成包括每一个待修复方法的插桩代码对应的补丁的热修复补丁,最后在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。可见,由于本申请实施例会先判断每一个待修复方法是否存在于两个或两个以上SDK中,并在某一待修复方法存在于两个或两个以上SDK中时,仅保留一个SDK的编译文件中的该修复方法的插桩,从而剔除待修复项目中重复的待修复方法,进而避免热修复补丁修复错误的待修复方法,因此本申请实施例可以在对多个可选择接入且具有依赖关系的SDK进行热修复时,避免各SDK的热修复补丁之间冲突。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的热修复方法的流程图之一;
图2为本申请实施例提供的热修复方法的流程图之二;
图3为本申请实施例提供的热修复方法的流程图之三;
图4为本申请实施例提供的热修复装置的结构示意图之一;
图5为本申请实施例提供的热修复装置的结构示意图之二;
图6为本申请实施例提供的电子设备的硬件结构示意图。
具体实施方式
为了能够更清楚地理解本申请的上述目的、特征和优点,下面将对本申请的方案进行进一步描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。
在下面的描述中阐述了很多具体细节以便于充分理解本申请,但本申请还可以采用其他不同于在此描述的方式来实施;显然,说明书中的实施例只是本申请的一部分实施例,而不是全部的实施例。
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。此外,在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或两个以上。
本申请实施例提供了一种热修复方法,参照图1所示,本申请实施例提供的热修复方法包括S101-S105:
S101、分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件。
其中,所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码。
即,在对待修复项目中的SDK进行编译过程中,将待修复项目中的每一个SDK都作为一个独立的SDK进行编译,且任一SDK的编译文件包括该SDK中各待修复方法的插桩代码。例如:SDK1的编译文件包括SDK1中各待修复方法的插桩代码。
示例性的,可以对待修复项目的每一个SDK引入插桩插件,通过引入的插桩插件对对应SDK中的每一个类(class)中的每一个待修复方法进行插桩,从而完成每一个SDK的编译,获取每一个SDK的编译文件。具体的,各SDK的编译文件可以包括各SDK的mapping文件。
S102、判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中。
具体的,同一个SDK中必然不存在相同的方法,也不存在相同的待修复方法,然而不同SDK之间可能会有相同的方法和相同的待修复方法。在进行热修复时,会针对每一个SDK中的每一个待修复方法生成补丁,且不同SDK中的同一待修复方法的补丁也可能会不同,若目标待修复方法存在于SDK1和SDK2中,则当SDK1中的目标待修复方法调用补丁时很可能会调用到SDK2中目标待修复方法的补丁,进而导致该补丁被错误的待修复方法调用了,因此本申请实施例在生成热修复补丁之前,先判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中,并通过下述步骤避免待修复方法存在于两个或两个以上SDK中所带来的上述问题。
在上述S102中,若各待修复方法均仅存在于所述待修复项目的一个SDK中,则执行如下S104,而若目标待修复方法存在于所述待修复项目的两个或两个以上SDK中,则先执行如下S103,再执行如下S104。其中,目标待修复方法可以为任意待修复方法。
S103、将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码。
即,若某一待修复方法存在于所述待修复项目的两个或两个以上SDK中,则保留一个 SDK的编译文件中该待修复方法的插桩代码,删除其它SDK的编译文件中该待修复方法的插桩代码。
例如:待修复方法1同时存在于第一SDK、第二SDK和第三SDK中,则可以保留第一SDK的编译文件中待修复方法1的插桩代码,删除第二SDK的编译文件和第三SDK的编译文件中待修复方法1的插桩代码。
需要说明的是,保留一个SDK的编译文件中目标待修复方法的插桩代码,删除其它SDK的编译文件中目标待修复方法的插桩代码方式可以为:随机选取一个SDK的编译文件,保持选取的SDK的编译文件不变,并将其余SKD的编译文件中目标待修复方法的插桩代码删除。
S104、生成热修复补丁。
其中,所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁。
具体的,可以基于待修复项目的每一个SDK中每一个需要进行热修复的方法(具有插桩代码的待修复方法)生成热修复补丁。
S105、在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
本申请实施例提供的热修复方法先分别对待修复项目的每一个SDK进行编译获取各SDK的编译文件,并判断每个待修复方法是否存在于两个或两个以上SDK中,若某一待修复方法为存在于两个或两个以上SDK中,则将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码,然后再生成包括每一个待修复方法的插桩代码,然后再生成包括每一个待修复方法的插桩代码对应的补丁的热修复补丁,最后在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
可见,由于本申请实施例会先判断每一个待修复方法是否存在于两个或两个以上SDK中,并在某一待修复方法存在于两个或两个以上SDK中时,仅保留一个SDK的编译文件中的该修复方法的插桩代码,从而剔除待修复项目中重复的待修复方法,进而避免热修复补丁被错误的待修复方法所调用,因此本申请实施例可以在对多个可选择接入且具有依赖关系的SDK进行热修复时,避免各SDK的热修复补丁之间冲突。
作为本申请实施例一种可能的实施方式,参照图2所示,本申请另一实施例提供的热修复方法包括S201-S207:
S201、分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件。
其中,所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码。
需要说明的是,S201的相关内容请参见上文S101。
S202、在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表。
其中,各SDK对应的映射表记录有对应SDK中每一个待修复方法与方法标识的对应关系。
即,任一SDK对应的映射表记录有该SDK中每一个待修复方法与方法标识的对应关 系。例如:SDK2对应的映射表记录有SDK2中每一个待修复方法与方法标识的对应关系。
在一种可能的实施方式中,S202的具体实现方式可以包括如下步骤a至步骤c。
步骤a、在分别对所述待修复项目的每一个SDK进行编译的过程中,获取各SDK中每一个待修复方法的方法签名。
具体的,可以在对所述待修复项目中的任一SDK进行编译的过程中,获取该SDK中的所有类(class),然后获取每一个类中的全部方法,再从每一个类的全部方法中确定待修复方法,最后提取每一个待修复方法的方法签名。
步骤b、基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值。
在一种可能的实施方式中,所述预设加密算法为消息摘要算法(Message-Digest Algorithm,MD5);基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值,包括:基于MD5对各SDK中每一个待修复方法的方法签名进行加密,获取各方法签名的MD5值。
在上述实施例的基础上,本申请实施例中的预设加密算法还可以为其它加密算法。例如:RSA加密算法、DES加密算法等。
步骤c、建立各SDK中各待修复方法与对应的加密值的对应关系,生成各SDK对应的映射表。
即,任一待修复方法对应的加密值为基于所述预设加密算法对该待修复方法的方法签名进行加密得到的加密值。当预设加密算法为MD5,则任一待修复方法对应的加密值为该待修复方法的MD5值。
S203、判断映射关系表集合中是否包含重复的方法标识。
其中,所述映射关系表集合为所述待修复项目的每一个SDK对应的映射关系表组成的集合。
如上所述,同一个SDK中必然不存在相同的方法和相同的待修复方法,但多个SDK中可能会有相同的方法和相同的待修复方法,而相同方法的方法签名和方法标识也相同,因此映射关系表集合中可能包括重复的方法标识。
在上述S203中,若每一个方法标识均只出现在一个对应关系中,则确定映射关系表集合中不包含重复的方法标识,并执行如下S206-S207;而若目标方法标识出现在两个或两个以上对应关系中,则确定所述目标方法标识为重复的方法标识,并执行如下S204-S207。
S204、确定所述目标标识对应的待修复方法为存在于所述待修复项目的两个或两个以上SDK中。
S205、将所述目标标识对应的待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标标识对应的待修复方法的插桩代码。
需要说明的是,S205的实施方式类似于上文S103的实施方式。
S206、生成热修复补丁。
其中,所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁。
需要说明的是,S206的相关内容请参见上文S104。
S207、在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
上述实施例提供的热修复方法为对图1所示热修复方法的细化,其可以达到的技术效果与图1所示热修复方法可以达到的技术效果类似。在此不再赘述。
作为本申请实施例一种可能的实施方式,参照图3所示,本申请另一实施例提供的热修复方法包括S301-S306:
S301、分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件。
其中,所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码。
需要说明的是,S301的相关内容请参见上文S101。
S302、判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中。
在上述S302中,若目标待修复方法存在于所述待修复项目的两个或两个以上SDK中,则执行如下S303-S306;若各待修复方法均仅存在于所述待修复项目的一个SDK中,则执行如下S304-S306。
S303、将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码。
S304、创建目标工程。
其中,所述目标工程依赖所述待修复项目的每一个SDK的编译文件。
即,将待修复项目中的全部SDK视为一体,创建一个依赖待修复项目中的全部SDK的外部工程。
S305、生成所述目标工程的补丁,并将所述目标工程的补丁作为所述热修复补丁。
在一种可能的实施方式中,上述S305的实现方式可以包括如下步骤Ⅰ至步骤Ⅲ:
步骤Ⅰ、获取代码集合。
所述代码集合包括所述待修复项目的每一个SDK对应编译文件的代码。
步骤Ⅱ、在所述代码集合中读取待修复代码。
所述待修复代码为各SDK的待修复方法对应的代码。
具体的,可以在通过注解标注各SDK的待修复方法,然后根据注解查找待修复代码。
步骤Ⅲ、根据所述待修复代码生成所述目标工程的补丁。
S306、在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
上述实施例创建一个依赖所述待修复项目的每一个SDK的编译文件的外部工程,然后生成该外部工程的补丁,并将所述目标工程的补丁作为所述热修复补丁,因此上述实施例可以将待修复项目全部待修复方法的补丁作为一个整体进行管理,无需单独对每一个待修复方法的补丁进行管理,因此上述实施例可以进一步简化热修复补丁的管理。
此外,本申请实施例将包括全部插桩代码对应的补丁的热修复补丁发送接入端,即使接入端未接入待修复项目中的某一个SDK的编译文件,也不会影响接入的SDK的编译文件的补丁生效,只是未接入的编译文件的补丁不会生效。
作为本申请实施例一种可能的实施方式,在上述任一实施例提供的热修复方法的基础 上,本申请实施例提供的热修复方法还包括:
在对各待修复方法进行插桩的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码中;
在生成热修复补丁的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码对应的补丁中;
判断各插桩代码中的方法标识与调用的补丁中的方法标识是否相同;
若一个或多个插桩代码中的方法标识与调用的补丁中的方法标识不同,则确认所述热修复补丁错误;
若各插桩代码中的方法标识与调用的补丁中的方法标识均相同,则确认所述热修复补丁正确。
上述实施例在对待修复方法进行插桩时将对应的方法标识添加到插桩代码中,在生成待修复方法的补丁时将对应的方法标识添加对应的补丁中,并在补丁生效前先验证插桩代码中的方法标识与补丁中的方法标识是否相同,从而校验生成的热修复补丁是否正确,因此本申请实施例可以保证热修复补丁的正确生效。
此外,由于在对待修复方法进行插桩时将对应的方法标识添加到了插桩代码中,且在补丁生效前先验证插桩代码中的方法标识与补丁中的方法标识是否相同,因此上述实施例提供的方法还可以避免伪造的补丁生效,进而提高软件产品的安全性。
基于同一发明构思,作为对上述方法的实现,本申请实施例还提供了一种热修复装置,该装置实施例与前述方法实施例对应,为便于阅读,本装置实施例不再对前述方法实施例中的细节内容进行逐一赘述,但应当明确,本实施例中的热修复装置能够对应实现前述方法实施例中的全部内容。
图4为本申请实施例提供的热修复装置的结构示意图,如图4所示,本实施例提供的热修复装置400包括:
编译单元41,用于分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件;所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码;
处理单元42,用于判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中;
修订单元43,用于在确定目标待修复方法存在于所述待修复项目的两个或两个以上SDK中时,将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码;
生成单元44,用于生成热修复补丁;所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁;
下发单元45,用于在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
作为本申请实施例一种可能的实施方式,
所述编译单元41,还用于在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表;各SDK对应的映射表记录有对应SDK中每一个待修复方法与方 法标识的对应关系;
所述处理单元42,具体用于判断映射关系表集合中是否包含重复的方法标识;若目标方法标识为重复的方法标识,则确定所述目标方法标识对应的待修复方法存在于所述待修复项目的两个或两个以上SDK中;
其中,所述映射关系表集合为所述待修复项目的每一个SDK对应的映射关系表组成的集合。
作为本申请实施例一种可能的实施方式,所述编译单元41,具体用于在分别对所述待修复项目的每一个SDK进行编译的过程中,获取各SDK中每一个待修复方法的方法签名;基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值;建立各SDK中各待修复方法与对应的加密值的对应关系,生成各SDK对应的映射表。
作为本申请实施例一种可能的实施方式,所述编译单元41,具体用于基于MD5对各SDK中每一个待修复方法的方法签名进行加密,获取各方法签名的MD5值。
作为本申请实施例一种可能的实施方式,参照图5所示,所述热修复装置400还包括:校验单元46;
所述编译单元41,还用于在对各待修复方法进行插桩的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码中;
所述生成单元44,还用于在生成热修复补丁的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码对应的补丁中;
所述校验单元46,用于判断各插桩代码中的方法标识与调用的补丁中的方法标识是否相同;若一个或多个插桩代码中的方法标识与调用的补丁中的方法标识不同,则确认所述热修复补丁错误;若各插桩代码中的方法标识与调用的补丁中的方法标识均相同,则确认所述热修复补丁正确。
作为本申请实施例一种可能的实施方式,所述生成单元44,具体用于创建目标工程,所述目标工程依赖所述待修复项目的每一个SDK的编译文件;生成所述目标工程的补丁,并将所述目标工程的补丁作为所述热修复补丁。
作为本申请实施例一种可能的实施方式,所述生成单元44,具体用于获取代码集合,在所述代码集合中读取待修复代码,根据所述待修复代码生成所述目标工程的补丁;
其中,所述代码集合包括所述待修复项目的每一个SDK对应编译文件的代码;所述待修复代码为各SDK的待修复方法对应的代码。
基于同一发明构思,本申请实施例还提供了一种电子设备。图6为本申请实施例提供的电子设备的结构示意图,如图6所示,本实施例提供的电子设备包括:存储器61和处理器62,存储器61用于存储计算机程序;处理器62用于在调用计算机程序时执行上述实施例提供的热修复方法的步骤。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述实施例提供的热修复方法的步骤。
本领域技术人员应明白,本申请的实施例可提供为方法、***、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例 的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质上实施的计算机程序产品的形式。
处理器可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动存储介质。存储介质可以由任何方法或技术来实现信息存储,信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。根据本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。

Claims (11)

  1. 一种热修复方法,其特征在于,包括:
    分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件;所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码;
    判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中;
    若目标待修复方法存在于所述两个或两个以上SDK中,则将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码;
    生成热修复补丁,所述热修复补丁包括每一个所述待修复方法的插桩代码对应的补丁;
    在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表;各SDK对应的映射表记录有对应SDK的每一个待修复方法与方法标识的对应关系;
    所述判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中,包括:
    判断映射关系表集合中是否包含重复的方法标识;所述映射关系表集合为所述待修复项目的每一个SDK对应的映射关系表组成的集合;
    若目标方法标识为重复的方法标识,则确定所述目标方法标识对应的待修复方法存在于所述待修复项目的两个或两个以上SDK中。
  3. 根据权利要求2所述的方法,其特征在于,所述在分别对待修复项目的每一个SDK进行编译的过程中,生成各SDK对应的映射表,包括:
    在分别对所述待修复项目的每一个SDK进行编译的过程中,获取各SDK中每一个待修复方法的方法签名;
    基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值;
    建立各SDK中各待修复方法与对应的加密值的对应关系,生成各SDK对应的映射表。
  4. 根据权利要求3所述的方法,其特征在于,所述基于预设加密算法对各SDK每一个待修复方法的方法签名进行加密,获取每一个待修复方法对应的加密值,包括:
    基于消息摘要算法MD5对各SDK中每一个待修复方法的方法签名进行加密,获取各方法签名的MD5值。
  5. 根据权利要求1的方法,其特征在于,所述方法还包括:
    在对各待修复方法进行插桩的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码中;
    在生成热修复补丁的过程中,将各待修复方法的方法标识添加到各待修复方法的插桩代码对应的补丁中;
    判断各插桩代码中的方法标识与调用的补丁中的方法标识是否相同;
    若一个或多个插桩代码中的方法标识与调用的补丁中的方法标识不同,则确认所述热修复补丁错误;
    若各插桩代码中的方法标识与调用的补丁中的方法标识均相同,则确认所述热修复补丁正确。
  6. 根据权利要求1的方法,其特征在于,所述生成热修复补丁,包括:
    创建目标工程,所述目标工程依赖所述待修复项目的每一个SDK的编译文件;
    生成所述目标工程的补丁,并将所述目标工程的补丁作为所述热修复补丁。
  7. 根据权利要求6的方法,其特征在于,所述生成所述目标工程的补丁,包括:
    获取代码集合,所述代码集合包括所述待修复项目的每一个SDK对应编译文件的代码;
    在所述代码集合中读取待修复代码,所述待修复代码为各SDK的待修复方法对应的代码;
    根据所述待修复代码生成所述目标工程的补丁。
  8. 一种热修复装置,其特征在于,包括:
    编译单元,用于分别对待修复项目的每一个SDK进行编译,获取各SDK的编译文件;所述待修复项目包括至少两个具有依赖关系的SDK,各SDK的编译文件包括对应SDK中各待修复方法的插桩代码;
    处理单元,用于判断各待修复方法是否存在于所述待修复项目的两个或两个以上SDK中;
    修订单元,用于在确定目标待修复方法存在于所述待修复项目的两个或两个以上SDK中时,将所述目标待修复方法的插桩代码保留在所述两个或两个以上SDK的其中一个的编译文件中,删除其它SDK的编译文件中所述目标待修复方法的插桩代码;
    生成单元,用于生成热修复补丁;所述热修复补丁包括每一个待修复方法的插桩代码对应的补丁;
    下发单元,用于在接入端接入所述待修复项目的至少一个SDK的编译文件时,向所述接入端发送所述热修复补丁。
  9. 一种电子设备,其特征在于,包括:存储器和处理器,存储器用于存储计算机程序;处理器用于在调用计算机程序时执行权利要求1-7任一项所述的热修复方法。
  10. 一种计算机可读存储介质,其特征在于,其上存储有计算机程序,计算机程序被处理器执行时实现权利要求1-7任一项所述的热修复方法。
  11. 一种计算机程序产品,其特征在于,所述计算机程序产品包括承载在计算机可读介质上的计算机程序,当所述计算机程序被处理器执行时,使得处理器实现权利要求1-7任一项所述的热修复方法。
PCT/CN2021/134732 2021-01-19 2021-12-01 一种热修复方法及装置 WO2022156379A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/008,796 US20230229431A1 (en) 2021-01-19 2021-12-01 Hotfix method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110071098.X 2021-01-19
CN202110071098.XA CN112667521B (zh) 2021-01-19 2021-01-19 一种热修复方法及装置

Publications (1)

Publication Number Publication Date
WO2022156379A1 true WO2022156379A1 (zh) 2022-07-28

Family

ID=75415691

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/134732 WO2022156379A1 (zh) 2021-01-19 2021-12-01 一种热修复方法及装置

Country Status (3)

Country Link
US (1) US20230229431A1 (zh)
CN (1) CN112667521B (zh)
WO (1) WO2022156379A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115129355A (zh) * 2022-09-01 2022-09-30 平安银行股份有限公司 页面修复方法及其***、计算机设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112667521B (zh) * 2021-01-19 2022-07-19 北京字节跳动网络技术有限公司 一种热修复方法及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019787A (zh) * 2012-12-14 2013-04-03 华为技术有限公司 函数调用关系确定方法、热补丁升级方法及装置
US8607208B1 (en) * 2008-10-01 2013-12-10 Oracle International Corporation System and methods for object code hot updates
CN107179925A (zh) * 2017-04-14 2017-09-19 北京五八信息技术有限公司 热更新方法及装置
CN109344619A (zh) * 2018-08-15 2019-02-15 北京奇艺世纪科技有限公司 应用程序的热修复方法和装置
CN112068903A (zh) * 2020-09-21 2020-12-11 深圳市欢太科技有限公司 应用程序的加载方法、应用程序的加载装置、介质与设备
CN112667521A (zh) * 2021-01-19 2021-04-16 北京字节跳动网络技术有限公司 一种热修复方法及装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078262B (zh) * 2018-10-18 2023-04-11 百度在线网络技术(北京)有限公司 应用的热修复方法和装置
CN111831316A (zh) * 2020-07-21 2020-10-27 北京字节跳动网络技术有限公司 一种软件开发包更新方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8607208B1 (en) * 2008-10-01 2013-12-10 Oracle International Corporation System and methods for object code hot updates
CN103019787A (zh) * 2012-12-14 2013-04-03 华为技术有限公司 函数调用关系确定方法、热补丁升级方法及装置
CN107179925A (zh) * 2017-04-14 2017-09-19 北京五八信息技术有限公司 热更新方法及装置
CN109344619A (zh) * 2018-08-15 2019-02-15 北京奇艺世纪科技有限公司 应用程序的热修复方法和装置
CN112068903A (zh) * 2020-09-21 2020-12-11 深圳市欢太科技有限公司 应用程序的加载方法、应用程序的加载装置、介质与设备
CN112667521A (zh) * 2021-01-19 2021-04-16 北京字节跳动网络技术有限公司 一种热修复方法及装置

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115129355A (zh) * 2022-09-01 2022-09-30 平安银行股份有限公司 页面修复方法及其***、计算机设备

Also Published As

Publication number Publication date
CN112667521A (zh) 2021-04-16
US20230229431A1 (en) 2023-07-20
CN112667521B (zh) 2022-07-19

Similar Documents

Publication Publication Date Title
TWI709056B (zh) 韌體升級方法及裝置
RU2744054C2 (ru) Устройство и способ хранения данных, проверки данных и связывания данных
CN110990045B (zh) 一种双bmc flash升级方法和设备
WO2022156379A1 (zh) 一种热修复方法及装置
US11232098B2 (en) Data structure reading methods and apparatuses, data structure update methods and apparatuses, and electronic devices
CN108614702B (zh) 字节码优化方法及装置
KR20190061075A (ko) 소프트웨어 재패키징 방지 방법 및 장치
JP2008503014A5 (zh)
WO2022100063A1 (zh) 智能合约的日志生成及保存方法、装置、设备和存储介质
CN109960597B (zh) 一种应用层接口的动态注册方法及相关装置
CN111125725A (zh) 一种镜像校验的加解密方法、设备及介质
CN107092517B (zh) 一种sdk工具包的生成方法及装置
WO2019024392A1 (zh) 依赖包工具的验证方法、存储介质、电子设备及***
US11770460B2 (en) Method and system for sharing multi-protocol port, and server
CN114637675A (zh) 软件评估方法及装置、计算机可读存储介质
US20130227541A1 (en) Updating a web services description language for a service test
US20200183675A1 (en) Image file packaging method and image file packaging system
Detken et al. Software-design for internal security checks with dynamic integrity measurement (DIM)
CN112115477A (zh) 内核修复方法、装置、电子设备及存储介质
JP2022553498A (ja) イベント・ログの改竄耐性
CN117112047B (zh) 一种usb设备的管控方法、设备及存储介质
US20230418935A1 (en) Detecting tampering in data processing pipelines
CN117009979B (zh) 一种可处理合约信息的智能合约漏洞检测方法
CN112732644B (zh) 应用程序的资源索引处理方法、计算机设备和存储介质
US20100306844A1 (en) Application information tampering monitoring apparatus and method

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: 21920754

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.11.2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21920754

Country of ref document: EP

Kind code of ref document: A1