CN112860279A - Method, device, equipment and medium for generating application installation package - Google Patents

Method, device, equipment and medium for generating application installation package Download PDF

Info

Publication number
CN112860279A
CN112860279A CN202110193157.0A CN202110193157A CN112860279A CN 112860279 A CN112860279 A CN 112860279A CN 202110193157 A CN202110193157 A CN 202110193157A CN 112860279 A CN112860279 A CN 112860279A
Authority
CN
China
Prior art keywords
target
bytecode
view control
time point
jitter
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.)
Pending
Application number
CN202110193157.0A
Other languages
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.)
Netease Media Technology Beijing Co Ltd
Original Assignee
Netease Media Technology Beijing 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 Netease Media Technology Beijing Co Ltd filed Critical Netease Media Technology Beijing Co Ltd
Priority to CN202110193157.0A priority Critical patent/CN112860279A/en
Publication of CN112860279A publication Critical patent/CN112860279A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a method, an apparatus, a device and a medium for generating an application installation package, which relate to the technical field of computers, and the method comprises: compiling a development source code of an application program to obtain a target byte code of the application program; identifying a bytecode of a target method in the target bytecode; the byte code of the target method is used for setting a click event for the view control; inserting an anti-jitter byte code segment into the byte code of the target method; and generating an installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment. According to the method and the device, the anti-jitter byte code segment can be inserted into the target method of the target byte code to realize anti-jitter protection of the view control, so that a business developer does not need to add an annotation of anti-jitter protection in a source code, and the development workload of the business developer is reduced.

Description

Method, device, equipment and medium for generating application installation package
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for generating an application installation package.
Background
This section is intended to provide a background or context to the embodiments of the disclosure recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Click behavior is one of the most common operations for users to use Applications (APPs). For example, in the Android system, setting a click event for View control View is implemented by developing source code, that is, setting code logic to be executed when the View is clicked.
When a user clicks View many times continuously and quickly due to hand shaking and false touch, and the last click event is not executed completely, the situation of continuously responding to the click events of many times can easily occur. For example, from a news information stream list, by clicking on an entry into a text page, if the user clicks quickly two times, it can easily happen that the text page of an article is opened first and then a same text page is opened to cover the text page. For example, if the user clicks twice quickly, the user can easily like to approve and then cancel the approval immediately.
At present, in order to solve the above problems, it is generally required that when developing the source code of an application program, a business developer writes out a note outside the method of each click event, where the note is used to identify that the click event needs anti-jitter protection, that is, when a view control is clicked many times in a quick and continuous manner, no repeated response is made. Thus, the development workload of the service developers is increased.
Disclosure of Invention
The embodiment of the disclosure provides a method, a device, equipment and a medium for generating an application installation package, which are used for identifying a target method for setting a click event for a view control in a byte code, and further inserting an anti-jitter byte code segment into the target method to realize anti-jitter protection of the view control, so that a service developer does not need to add an annotation of the anti-jitter protection in a source code, and the development workload of the service developer is reduced.
In a first aspect, the present disclosure provides a method for generating an application installation package, including:
compiling a development source code of an application program to obtain a target byte code of the application program;
identifying a bytecode of a target method in the target bytecode; the byte code of the target method is used for setting a click event for the view control;
inserting an anti-jitter byte code segment into the byte code of the target method;
and generating an installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
In an optional embodiment, the identifying the bytecode of the target method in the target bytecode includes:
traversing the byte codes of the method in the target byte codes, and determining whether the byte codes of the method contain target characteristic information;
if the target characteristic information is contained, determining that the bytecode of the method is the bytecode of the target method.
In an alternative embodiment, the target feature information includes one or more of:
the interface attribute comprises a first byte code segment;
the method name is a target name;
the method description includes a second bytecode fragment;
the method calling mode is a target mode;
the method description ends with a third bytecode segment;
the parameter position of the view control is located at the target position in the method description.
In an optional embodiment, the inserting, in the bytecode of the target method, an anti-jitter bytecode fragment includes:
inserting the anti-jitter bytecode fragment in front of a fourth bytecode fragment in the bytecode of the target method; wherein the fourth target bytecode segment is a bytecode segment at which execution of the target method is started.
In an alternative embodiment, the logic for anti-jitter bytecode fragmentation includes:
if the target view control is clicked, determining whether a target time point responding to the click of the target view control at the last time exists according to a corresponding relation between the view control stored before the current time point and the time point responding to the click of the view control;
and if the target time point exists and the interval duration between the current time point and the target time point is less than the set duration, intercepting the click event of the target view control.
In an optional implementation, the logic for anti-jitter bytecode fragmentation further includes:
if the target time point exists and the interval duration between the current time point and the target time point is greater than the set duration, responding to a click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control; or
And if the target time point does not exist, responding to the click event of the view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control.
In an optional implementation, the logic for anti-jitter bytecode fragmentation further includes:
and if the number of the stored corresponding relations exceeds the set number, cleaning according to a preset rule.
In an optional embodiment, the method further comprises:
and setting the set duration in an application program initialization byte code segment in the target byte code.
In an alternative embodiment, the target bytecode is one or two of the following:
bytecode compiled from development source code, bytecode of third party software development kit SDK.
In an optional implementation manner, an annotation source code is set in a source code of a corresponding target method in the development source code, wherein the annotation source code is used for indicating that the target method is not subjected to anti-jitter protection;
the method further comprises the following steps:
if the identified bytecode of the target method comprises an annotation bytecode, not inserting the anti-jitter bytecode fragment into the bytecode of the target method; wherein the annotation bytecode is compiled from the annotation source code.
In an alternative embodiment, the development source code is provided in a different code package, and the method further comprises:
adding configuration information of an object code packet in an object configuration file, wherein the configuration information of the object code packet is used for representing anti-jitter protection on the object method in the object code packet.
In a second aspect, the present disclosure also provides an apparatus for generating an application installation package, including:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for compiling a development source code of an application program and then acquiring a target byte code of the application program;
the identification module is used for identifying the byte codes of the target methods in the target byte codes; the byte code of the target method is used for setting a click event for the view control;
the inserting module is used for inserting anti-jitter byte code segments into the byte codes of the target method;
and the generating module is used for generating the installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
In an optional embodiment, the identification module is further configured to:
traversing the byte codes of the method in the target byte codes, and determining whether the byte codes of the method contain target characteristic information;
if the target characteristic information is contained, determining that the bytecode of the method is the bytecode of the target method.
In an alternative embodiment, the target feature information includes one or more of:
the interface attribute comprises a first byte code segment;
the method name is a target name;
the method description includes a second bytecode fragment;
the method calling mode is a target mode;
the method description ends with a third bytecode segment;
the parameter position of the view control is located at the target position in the method description.
In an alternative embodiment, the insertion module is further configured to:
inserting the anti-jitter bytecode fragment in front of a fourth bytecode fragment in the bytecode of the target method; wherein the fourth target bytecode segment is a bytecode segment at which execution of the target method is started.
In an alternative embodiment, the logic for anti-jitter bytecode fragmentation includes:
if the target view control is clicked, determining whether a target time point responding to the click of the target view control at the last time exists according to a corresponding relation between the view control stored before the current time point and the time point responding to the click of the view control;
and if the target time point exists and the interval duration between the current time point and the target time point is less than the set duration, intercepting the click event of the target view control.
In an optional implementation, the logic for anti-jitter bytecode fragmentation further includes:
if the target time point exists and the interval duration between the current time point and the target time point is greater than the set duration, responding to a click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control; or
And if the target time point does not exist, responding to the click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control.
In an optional implementation, the logic for anti-jitter bytecode fragmentation further includes:
and if the number of the stored corresponding relations exceeds the set number, cleaning according to a preset rule.
In an optional embodiment, the apparatus further comprises a setting module configured to:
and setting the set duration in an application program initialization byte code segment in the target byte code.
In an alternative embodiment, the target bytecode is one or two of the following:
bytecode compiled from development source code, bytecode of third party software development kit SDK.
In an optional implementation manner, an annotation source code is set in a source code of a corresponding target method in the development source code, wherein the annotation source code is used for indicating that the target method is not subjected to anti-jitter protection;
the apparatus also includes an inhibit insertion module:
if the identified bytecode of the target method comprises an annotation bytecode, not inserting the anti-jitter bytecode fragment into the bytecode of the target method; wherein the annotation bytecode is compiled from the annotation source code.
In an optional implementation, the development source code is provided in a different code package, and the apparatus further includes a configuration module configured to:
adding configuration information of an object code packet in an object configuration file, wherein the configuration information of the object code packet is used for representing anti-jitter protection on the object method in the object code packet.
In a third aspect, the present disclosure also provides an electronic device, including a memory and a processor, where the memory stores a computer program operable on the processor, and when the computer program is executed by the processor, the processor is caused to implement the steps of any one of the methods for generating an application installation package in the first aspect.
In a fourth aspect, the present disclosure also provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any one of the methods for generating an application installation package in the first aspect.
According to the scheme provided by the embodiment of the disclosure, after the development source code of the application program is compiled, the target byte code of the application program can be obtained, then the target method for setting the click event for the view control in the target byte code is identified, and then the anti-jitter byte code segment is inserted into the target method to realize the anti-jitter protection of the view control, so that the service developer does not need to add the annotation of the anti-jitter protection in the source code, and the development workload of the service developer is reduced.
Additional features and advantages of the disclosure will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the disclosure. The objectives and other advantages of the disclosure may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for generating an application installation package according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of another method for generating an application installation package according to an embodiment of the present disclosure;
FIG. 3 is a flow chart of an anti-jitter protection logic provided by an embodiment of the present disclosure;
fig. 4 is a schematic diagram of an apparatus for generating an application installation package according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the present disclosure clearer, the present disclosure will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
It is noted that the terms "first," "second," and the like in the description and in the claims of the present disclosure are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein.
Furthermore, the terms "comprises," "comprising," and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of understanding, some concepts related to the embodiments of the present application are explained below.
Application (APP): the method refers to a program installed on intelligent equipment such as a mobile phone, and generally needs to be matched with a server side for operation. Common applications fall into two main categories. One is pre-installed system applications such as short messages, photos, etc.; still another type is third party applications such as e.g. internet news for information, wechat for social use, etc.
VIEW control (VIEW): in Android APP, all user interface elements are composed of View and View group, where View is an object drawn on a screen and a View container for storing other views and View groups. The embodiment of the present disclosure may simply refer to the VIEW control as VIEW.
Page dithering: when a user uses APP, if the user clicks VIEW continuously very quickly, a situation may occur in which multiple click events are responded to, and the effect may be to open multiple pages continuously, send multiple requests continuously, and the like, which is called page shaking.
Click event (CLICKEVENT): in Android, five ways of setting a click event for View are included, and the essence is to specify a method (a section of source code) to be executed when View is clicked. Wherein, the dynamic setting comprises four modes: inner class, implementation click event interface, Lambda expression, method reference. The static settings may be declared in a layout xml (Extensible Markup Language) file.
And (3) SDK: software Development Kit, Software Development Kit. There are two formats in Android development: JAR, AAR, can be integrated directly into the engineering, the sources are typically: (1) the SDK provided by the Android, that is, the source code corresponding to each system version, is as described above for the specific implementation of View. (2) The SDK provided by the third party developer, i.e., the packaged service implementation, may be directly integrated into the project, such as a third party push service.
Packaging and compiling: android packaging and compiling refers to a process of changing codes written by developers into APK files capable of running on a mobile phone, wherein the process comprises a plurality of steps, such as changing java files into class files. Typically by a gradle tool.
Byte code file: in Android development, a file in a class format is generally referred to, and java. It is platform independent and is a binary form of service that is provided independently of the underlying host platform.
Gradle Transform: in the packaging and compiling process provided by the Android, a developer can customize, the input is byte codes compiled by engineering and the SDK, and the developer can complete own logic.
ASM: is a bytecode operation framework which can be used for dynamically generating bytecode or strengthening the existing class. The ASM can generate the binary class bytecode directly, or can change its behavior dynamically before it is loaded, such as inserting code before and after the method execution, etc.
ClassVisitor: class bytecode visitors in the ASM support custom trigger events, custom annotation parsing, method parsing and the like.
MethodVisitor: the method visitors of the ASM support the self-defined trigger event, such as the attribute of the method, the attribute of the parameter and the like.
The following is a description of the design concept of the embodiments of the present application.
For the problem of page jitter, currently, it is usually required that a business developer writes a note outside each click event method when developing a source code of an application program, where the note is used to identify that the click event needs anti-jitter protection, that is, when a view control is clicked many times continuously and quickly, the view control only responds for the first time, and does not respond repeatedly. However, this increases the development workload of the service developers.
In order to improve the above situation, embodiments of the present application provide a method, an apparatus, a device, and a medium for generating an application installation package, where after a development source code of an application program is compiled, a target bytecode of the application program may be obtained, then a target method for setting a click event for a view control in the target bytecode is identified, and then an anti-jitter bytecode fragment is inserted in the bytecode of the target method, so as to implement anti-jitter protection of the view control, and a service developer does not need to add an annotation of anti-jitter protection in the source code, thereby reducing development workload of the service developer.
The method for generating an application installation package according to the present application is described below with reference to the accompanying drawings and specific embodiments.
Referring to fig. 1, an embodiment of the present application provides a method for generating an application installation package, which is applicable to a compiling device installed with a compiling environment. The method for generating the application installation package can comprise the following steps:
step S101, compiling the development source code of the application program and then obtaining the target byte code of the application program.
The development source code is a code written by a service developer in an APP development process, for example, in Android APP development, the development source code may be a java-format code, a kotlin-format code, and the like. For the developed source code, package compilation is required to generate an APK file running on the smart device, and in this process, the developed source code may be compiled by a compiler to obtain a bytecode, for example, a code in a class format.
The target bytecode of the application program may include a bytecode compiled from a development source code of the application program itself, and may also include a bytecode of a third-party SDK, for example, a bytecode of a third-party push service. The method can also simultaneously develop byte codes after source code compilation and byte codes of third-party SDKs.
It should be noted that the APP development may be based on an Android system or other operating systems, which is not limited in the embodiment of the present disclosure. The following embodiment is described by taking an example of APP development based on an Android system.
Step S102, identifying the byte code of the target method in the target byte code; wherein the bytecode of the target method is used to set a click event for the view control.
In this step, the target method may be identified according to the characteristic information of the bytecode of the target method, for example, the characteristic information may include a method description, a method name, interface attribute information, and the like. The target method may include a plurality of setting manners, including, for example, the following setting manners: the method comprises the steps of internal classification, realization of click event interfaces, Lambda expressions, method reference and the like, wherein the characteristic information of the bytecode of the target method is different in different setting modes and can be determined according to the corresponding setting modes.
Step S103, inserting anti-jitter byte code segments into the byte codes of the target method.
In this step, an anti-jitter bytecode fragment may be inserted at a designated position in the bytecode of the target method, for example, the anti-jitter bytecode fragment may be inserted in front of a fourth bytecode fragment in the bytecode of the target method, where the fourth target bytecode fragment is a bytecode fragment for starting execution of the target method.
Illustratively, after decompiling the bytecode of the target method before inserting the anti-jitter bytecode fragment, the obtained source code is as follows:
Figure BDA0002945069130000101
after inserting the anti-jitter byte code segment, decompiling the byte code of the target method to obtain the following source code:
Figure BDA0002945069130000102
Figure BDA0002945069130000111
the source code corresponding to the anti-jitter bytecode fragment is "if (| click guard.instance.watch. {"), and it can be seen that, after the source code fragment "public void onClick {", the target method starts to be executed, so the bytecode fragment compiled by the source code fragment may be the fourth target bytecode fragment.
And step S104, generating an installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
In this step, after the target bytecode inserted with the anti-jitter bytecode fragment is obtained, the plurality of bytecode files where the target bytecode is located may be integrated into one DEX file, and the DEX file is further packaged to generate the APK application installation package. The DEX file is an executable file of an Android system and comprises all operation instructions and runtime data of the application program.
For example, as shown in fig. 2, the source code file in the application module includes a developed source code, the application dependency may be a third-party SDK, the third-party SDK includes a bytecode, the developed source code is compiled to obtain a bytecode of the application itself, the bytecode file of the application itself and the bytecode file in the third-party SDK may be integrated into a DEX file, and the DEX file is packaged to generate an APK application installation package.
In the embodiment of the disclosure, after a development source code of an application program is compiled, a target byte code of the application program can be obtained, then a target method for setting a click event for a view control in the target byte code is identified, and then an anti-jitter byte code segment is inserted into the byte code of the target method to realize anti-jitter protection of the view control, so that a service developer does not need to add an anti-jitter protection note to the source code, development workload of the service developer is reduced, and the service developer does not need to know the logic of the anti-jitter byte code segment to make the service developer have no sense of anti-jitter protection.
In addition, usually, a third-party SDK needs to be introduced for APP development, and if a manner of adding an annotation for anti-jitter protection to a source code is adopted, anti-jitter protection cannot be provided for a click event in the third-party SDK because the third-party SDK is a compiled bytecode, but the embodiment of the disclosure may not only provide anti-jitter protection for the click event in the development source code of the APP, but also provide anti-jitter protection for the click event in the third-party SDK.
In some embodiments, step S102 may be implemented by:
a. and traversing the byte codes of the method in the target byte codes, and determining whether the byte codes of the method contain target characteristic information.
b. If the target characteristic information is contained, determining that the bytecode of the method is the bytecode of the target method.
In the embodiment of the disclosure, the packaging and compiling of the development source code can be completed through a Gradle tool, and in the packaging and compiling process, after the development source code is compiled through a compiler, the process of the Gradle Transform can be increased. For example, in fig. 2, in the process from the completion of the compilation to the generation of the DEX file, a process of the Gradle Transform is added, so that a ClassVisitor can be customized in a bytecode operating frame ASM, a target bytecode is traversed by the ClassVisitor, and when a bytecode of a method (i.e., visitMethod occasion) is accessed, whether the method is a target method is determined by judging whether the bytecode of the method includes target feature information, that is, a method for setting a click event for the view control. The target characteristic information can be determined according to the setting mode of the target method.
In an alternative embodiment, the target characteristic information includes one or more of:
the interface attribute comprises a first byte code segment;
the method name is a target name;
the method description includes a second bytecode fragment;
the method calling mode is a target mode;
the method description ends with a third bytecode segment;
the parameter position of the view control is located at the target position in the method description.
Illustratively, the target method may include the following four: first, a target method by internal class setting; secondly, a target method set by a click event interface is realized; thirdly, a target method set by a Lambda expression; fourth, the set target method is referenced by a method. The object characteristic information of these four object methods is described below.
The first target method and the second target method have the same target characteristic information, and may include: the interface attribute comprises 'android/View $ OnclickListener', namely the first byte code segment; the name of the method is 'onClick', namely the name of the target; the method is described as "(Landoroid/View/View;) V", the second byte code segment described above.
The third target method and the fourth target method have the same target characteristic information, and comprise the following steps: the method calling mode is invokeDynamic, namely the target mode; the method name is "onClick"; method description in ")) Landroid/View $ oncliclisterner; "end, i.e., the third bytecode fragment described above; one or more parameters are declared in the method description, the parameter position of the view control is the last position in the declared parameters, namely the parameter position of the first parameter is from 0, the parameter position of the view is the number of parameters minus one, for example, the number of parameters is 4, and the parameter position of the view is 3; if there is only one parameter view, its parameter position is 0.
In the related art, the method of adding the annotation for anti-jitter protection to the source code cannot provide anti-jitter protection for the third target method and the fourth target method, because the two target methods do not support adding the annotation, but the embodiment of the present disclosure may provide anti-jitter protection for the four target methods.
Further, based on the Gradle Transform process of the above embodiment, step S103 can be implemented as follows: a method Visitor is customized in the ASM, and when a target method is identified, an anti-jitter byte code segment can be dynamically inserted in a specified position of the target method through the ability of writing byte codes provided by the method Visitor.
Illustratively, dynamic insertion of anti-jitter bytecode fragments by the MethodVisitor can be achieved by:
Label l0=new Label();
mv.visitLabel(l0);
mv.visitFieldInsn(GETSTATIC,"com/netease/parkinson/ClickGuarder",
"INSTANCE","Lcom/netease/parkinson/ClickGuarder;");
mv.visitVarInsn(ALOAD,mParamPosition);
mv.visitMethodInsn(INVOKEVIRTUAL,
"com/netease/parkinson/ClickGuarder","watch","(Ljava/lang/Object;)Z",false);
Label l1=new Label();
mv.visitJumpInsn(IFEQ,l1);
Label l2=new Label();
mv.visitLabel(l2);
mv.visitInsn(RETURN);
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME,0,null,0,null);
wherein mv is a class provided by the method viewer and capable of writing byte codes, and mParamPosition is an index where a view parameter is located.
In some embodiments, the logic for anti-jitter bytecode segmentation may include the steps of:
(1) and if the target view control is clicked, determining whether a target time point for responding to the click of the target view control at the last time exists according to the corresponding relation between the view control stored before the current time point and the time point for responding to the click of the view control.
In this step, for example, a Key-Value relationship graph of timestamps in which the View clicks are responded, the maximum number of which is the set number, may be cached, where Key-Value is a corresponding relationship between the View control and the time point at which the View control is clicked, where Key may be a hash code corresponding to the View control, and for example, hash operation may be performed on an identifier of the View control to obtain the hash code, and Value is the time point.
Illustratively, when the view control 1 is clicked, the hash coding Key1 of the view control is firstly determined, and then whether a Key1 exists is searched from the cached relationship graph, and if yes, the latest time point Value1 corresponding to the Key1, that is, the last time point corresponding to the view control 1 is clicked, can be determined.
(2) And if the target time point exists and the interval duration between the current time point and the target time point is less than the set duration, intercepting the click event of the target view control.
The set time length may be set as required, for example, may be 400 milliseconds, which is not limited in the embodiment of the present disclosure, and if the interval time length between the current time point and the target time point is less than the set time length, the view control is considered to be touched by mistake, and is forced to return, and the click event of the view control is not responded.
Further, the case of responding to the click event of the target view control includes the following two cases:
first, if the interval duration between the current time point and the target time point is longer than the set duration, responding to the click event of the target view control, and storing the corresponding relationship between the target view control and the current time point where the response target view control is clicked.
And secondly, if the target time point does not exist, responding to the click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control.
For example, the target view control is the view control 1, and if no Key1 exists in the cached relationship diagram, it indicates that there is no target time point at which the view control 1 was clicked last time, at this time, a click event of the view control 1 needs to be responded, and the corresponding relationship between the view control 1 and the current response time point at which the view control 1 is clicked is stored.
When the corresponding relations are stored, whether the number of the corresponding relations in the cache exceeds a set number or not can be determined, and if the number of the corresponding relations in the cache exceeds the set number, cleaning is carried out according to a preset rule.
The number of settings may be set as needed, and may be, for example, 10. During cleaning, several first-stored correspondences may be deleted, for example, the maximum number of caches is 10, the previous 5 correspondences may be deleted, and the number of deletions may be set as needed, which is not limited in the embodiment of the present disclosure.
In some embodiments, to facilitate setting the set duration, the set duration may be set in an application initialization bytecode segment in the target bytecode.
For example, at the time of APP initialization, the set time length may be set by the following method:
ClickGuarder.INSTANCE.setup(400L);
wherein 400L refers to a set duration.
The logic of the debounce bytecode fragment is illustratively described below with reference to fig. 3 as an example.
Referring to fig. 3, if the target view control is clicked, the following steps are performed:
step S301, inquiring a target time point of the last time of the click of the response target view control;
step S302, if the target time point exists, judging whether the interval duration between the current time point and the target time point is less than the set duration; if yes, executing step S303, otherwise executing step S304-step S306;
step S303, intercepting a click event of a target view control;
step S304, responding to the click event of the target view control;
step S305, recording the corresponding relation between the target view control and the time point of the current response target view control;
step S306, judging whether the number of the corresponding relations in the cache exceeds the set number, if so, executing step S307;
and step S307, cleaning according to a preset rule.
In some embodiments, some target methods may not need anti-jitter protection, for example, in a live scene, when a viewer continuously clicks on a main broadcast, a repeated response is needed for continuous clicking of a click control, and at this time, an annotation source code may be set in the source code of the corresponding target method in the development source code, where the annotation source code is used to indicate that the target method is not anti-jitter protected.
For example, the annotation source code may be "@ Parkinson (needGuard ═ false)", and the following source code is the source code of the target method provided with the annotation source code.
Figure BDA0002945069130000161
Further, if the identified bytecode of the target method comprises an annotation bytecode, inserting no anti-jitter bytecode fragment into the bytecode of the target method; wherein the annotation bytecode is compiled from annotation source code.
In an alternative embodiment, the development source code is set in a different code packet, and in order to set the range of inserting the anti-jitter bytecode fragment, the configuration information of the target code packet may be added in the target configuration file, where the configuration information of the target code packet is used to indicate anti-jitter protection on the target method in the target code packet.
For example, the following configuration may be added to the ext part of the build.
ext{
clickGuarderScope=[‘com.netease.newsreader’,‘com.netease.nr’]
}
Where,' com.
Based on the same inventive concept, the present disclosure also provides a device for generating an application installation package, and the principle of the device for solving the problem is similar to the method of the above embodiment, so the implementation of the device may refer to the implementation of the method, and repeated details are not repeated. Referring to fig. 4, the apparatus for generating an application installation package includes:
the obtaining module 41 is configured to compile a development source code of an application program, and obtain a target bytecode of the application program;
an identifying module 42, configured to identify a bytecode of a target method in the target bytecode; the byte code of the target method is used for setting a click event for the view control;
an inserting module 43, configured to insert an anti-jitter byte code segment into the byte code of the target method;
and the generating module 44 is configured to generate an installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
In an alternative embodiment, the identification module 42 may be further configured to:
traversing the byte codes of the method in the target byte codes, and determining whether the byte codes of the method contain target characteristic information;
if the target characteristic information is contained, determining that the bytecode of the method is the bytecode of the target method.
In an alternative embodiment, the target feature information may include one or more of the following:
the interface attribute comprises a first byte code segment;
the method name is a target name;
the method description includes a second bytecode fragment;
the method calling mode is a target mode;
the method description ends with a third bytecode segment;
the parameter position of the view control is located at the target position in the method description.
In an alternative embodiment, the insertion module 43 may also be used to:
inserting an anti-jitter byte code segment in front of a fourth byte code segment in the byte code of the target method; wherein the fourth target bytecode segment is a bytecode segment for starting execution of the target method.
In an alternative embodiment, the logic for anti-jitter bytecode fragmentation may include:
if the target view control is clicked, determining whether a target time point for responding to the click of the target view control at the last time exists according to the corresponding relation between the view control stored before the current time point and the time point for responding to the click of the view control;
and if the target time point exists and the interval duration between the current time point and the target time point is less than the set duration, intercepting the click event of the target view control.
In an alternative embodiment, the logic for anti-jitter bytecode segmentation may further include:
if the target time point exists and the interval duration between the current time point and the target time point is greater than the set duration, responding to the click event of the target view control, and storing the corresponding relation between the target view control and the current time point where the response target view control is clicked; or
And if the target time point does not exist, responding to the click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control.
In an alternative embodiment, the logic for anti-jitter bytecode segmentation may further include:
and if the number of the stored corresponding relations exceeds the set number, cleaning according to a preset rule.
In an optional implementation, the apparatus may further include a setting module configured to:
and setting a set time length in an application program initialization byte code segment in the target byte code.
In an alternative embodiment, the target bytecode may be one or two of the following:
bytecode compiled from development source code, bytecode of third party software development kit SDK.
In an optional implementation manner, annotation source code is set in source code of a corresponding target method in the development source code, wherein the annotation source code is used for indicating that anti-jitter protection is not performed on the target method;
the apparatus may further include a disabling the insertion module:
if the byte code of the identified target method comprises the annotation byte code, inserting no anti-jitter byte code segment into the byte code of the target method; wherein the annotation bytecode is compiled from annotation source code.
In an alternative embodiment, the development source code is provided in a different code package, and the apparatus may further include a configuration module configured to:
and adding configuration information of the object code packet in the object configuration file, wherein the configuration information of the object code packet is used for representing anti-jitter protection on an object method in the object code packet.
Based on the same inventive concept, the embodiment of the present application further provides an electronic device, and the principle of the electronic device to solve the problem is similar to the method of the above embodiment, so that the implementation of the electronic device may refer to the implementation of the method, and repeated details are not repeated. Fig. 5 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Referring to fig. 5, an electronic device may include a processor 502 and a memory 501. Memory 501 provides program instructions and data stored in memory 501 to processor 502. In the embodiment of the present application, the memory 501 may be used to store a program for generating an application installation package in the embodiment of the present application.
The processor 502 is configured to execute a method of generating an application installation package in any of the above-described method embodiments, for example, a method of generating an application installation package provided in the embodiment shown in fig. 1, by calling the program instructions stored in the memory 501.
The specific connection medium between the memory 501 and the processor 502 is not limited in the embodiments of the present application. In the embodiment of the present application, the memory 501 and the processor 502 are connected by the bus 503 in fig. 5, the bus 503 is represented by a thick line in fig. 5, and the connection manner between other components is merely for illustrative purposes and is not limited thereto. The bus 503 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 5, but this is not intended to represent only one bus or type of bus.
The Memory may include a Read-Only Memory (ROM) and a Random Access Memory (RAM), and may further include a Non-Volatile Memory (NVM), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a central processing unit, a Network Processor (NP), and the like; but may also be a Digital instruction processor (DSP), an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like.
The embodiment of the present application further provides a computer storage medium, where a computer program is stored in the computer readable storage medium, a processor of a computer device reads the computer program from the computer readable storage medium, and the processor executes the computer program, so that the computer device executes the method for generating an application installation package in any method embodiment described above.
In particular implementations, computer storage media may include: various storage media capable of storing program codes, such as a Universal Serial Bus Flash Drive (USB), a mobile hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In some possible embodiments, the aspects of the method for generating an application installation package provided by the present application may also be implemented in the form of a program product, which includes program code for causing a computer device to execute the steps of generating an application installation package according to various exemplary embodiments of the present application described above in this specification when the program product runs on the computer device, for example, the computer device may execute the flow of generating an application installation package in steps S101-S104 shown in fig. 1.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or 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 (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A method of generating an application installation package, comprising:
compiling a development source code of an application program to obtain a target byte code of the application program;
identifying a bytecode of a target method in the target bytecode; the byte code of the target method is used for setting a click event for the view control;
inserting an anti-jitter byte code segment into the byte code of the target method;
and generating an installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
2. The method of claim 1, wherein the identifying the bytecode of the target method in the target bytecode includes:
traversing the byte codes of the method in the target byte codes, and determining whether the byte codes of the method contain target characteristic information;
if the target characteristic information is contained, determining that the bytecode of the method is the bytecode of the target method.
3. The method of claim 2, wherein the target feature information comprises one or more of:
the interface attribute comprises a first byte code segment;
the method name is a target name;
the method description includes a second bytecode fragment;
the method calling mode is a target mode;
the method description ends with a third bytecode segment;
the parameter position of the view control is located at the target position in the method description.
4. The method according to claim 2, wherein inserting a debounce byte code segment in the byte code of the target method comprises:
inserting the anti-jitter bytecode fragment in front of a fourth bytecode fragment in the bytecode of the target method; wherein the fourth target bytecode segment is a bytecode segment at which execution of the target method is started.
5. The method of any of claims 1 to 4, wherein the logic for anti-jittering bytecode segments comprises:
if the target view control is clicked, determining whether a target time point responding to the click of the target view control at the last time exists according to a corresponding relation between the view control stored before the current time point and the time point responding to the click of the view control;
and if the target time point exists and the interval duration between the current time point and the target time point is less than the set duration, intercepting the click event of the target view control.
6. The method of claim 5, wherein the logic for anti-jittering bytecode segments further comprises:
if the target time point exists and the interval duration between the current time point and the target time point is greater than the set duration, responding to a click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control; or
And if the target time point does not exist, responding to the click event of the target view control, and storing the corresponding relation between the target view control and the current time point responding to the click of the target view control.
7. The method of claim 6, wherein the logic for anti-jittering bytecode segments further comprises:
and if the number of the stored corresponding relations exceeds the set number, cleaning according to a preset rule.
8. An apparatus for generating an application installation package, comprising:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for compiling a development source code of an application program and then acquiring a target byte code of the application program;
the identification module is used for identifying the byte codes of the target methods in the target byte codes; the byte code of the target method is used for setting a click event for the view control;
the inserting module is used for inserting anti-jitter byte code segments into the byte codes of the target method;
and the generating module is used for generating the installation package of the application program based on the target bytecode inserted with the anti-jitter bytecode fragment.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program operable on the processor, the computer program, when executed by the processor, causing the processor to carry out the method of any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored therein, the computer program characterized by: the computer program, when executed by a processor, implements the method of any of claims 1 to 7.
CN202110193157.0A 2021-02-20 2021-02-20 Method, device, equipment and medium for generating application installation package Pending CN112860279A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110193157.0A CN112860279A (en) 2021-02-20 2021-02-20 Method, device, equipment and medium for generating application installation package

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110193157.0A CN112860279A (en) 2021-02-20 2021-02-20 Method, device, equipment and medium for generating application installation package

Publications (1)

Publication Number Publication Date
CN112860279A true CN112860279A (en) 2021-05-28

Family

ID=75988342

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110193157.0A Pending CN112860279A (en) 2021-02-20 2021-02-20 Method, device, equipment and medium for generating application installation package

Country Status (1)

Country Link
CN (1) CN112860279A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107168757A (en) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 A kind of Android ends prevent View controls from clicking on the method and device of shake
CN110618933A (en) * 2019-08-15 2019-12-27 华为技术有限公司 Performance analysis method and system, electronic device and storage medium
CN111679831A (en) * 2020-06-04 2020-09-18 同盾控股有限公司 Software development kit processing method, operation monitoring method, device and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107168757A (en) * 2017-03-31 2017-09-15 武汉斗鱼网络科技有限公司 A kind of Android ends prevent View controls from clicking on the method and device of shake
CN110618933A (en) * 2019-08-15 2019-12-27 华为技术有限公司 Performance analysis method and system, electronic device and storage medium
CN111679831A (en) * 2020-06-04 2020-09-18 同盾控股有限公司 Software development kit processing method, operation monitoring method, device and storage medium

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
CN107025559B (en) Service processing method and device
US11556348B2 (en) Bootstrapping profile-guided compilation and verification
CN111078223B (en) Application program packaging method and device
US10613844B2 (en) Using comments of a program to provide optimizations
US8843920B2 (en) Systems and methods for deferring software implementation decisions until load time
CN104798075A (en) Application randomization
CN110059456B (en) Code protection method, code protection device, storage medium and electronic equipment
CN110688232A (en) Application program calling method, terminal device and computer readable storage medium
CN110770698A (en) Difference static analysis for dynamic code optimization
CN111176717B (en) Method and device for generating installation package and electronic equipment
CN109408354B (en) Data processing method and device for application component
US20140053285A1 (en) Methods for detecting plagiarism in software code and devices thereof
CN111880801A (en) Application program dynamic method and device and electronic equipment
US10747514B2 (en) Reduced save and restore instructions for call-clobbered registers
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN114461223A (en) Code generation method and device and terminal equipment
US10496433B2 (en) Modification of context saving functions
CN112631656A (en) Intelligent contract optimization method and device based on source code
CN112988175A (en) Cross-platform application installation package generation method, device, medium and electronic equipment
CN116578282A (en) Code generation method, device, electronic equipment and medium
CN110941443A (en) Method and device for modifying file name in SDK and electronic equipment
US10394610B2 (en) Managing split packages in a module system
CN106778270B (en) Malicious application detection method and system
CN113296854B (en) Data loading method and system, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination