[go: up one dir, main page]

CN110389753B - Chained calling method and device of native application, electronic equipment and storage medium - Google Patents

Chained calling method and device of native application, electronic equipment and storage medium Download PDF

Info

Publication number
CN110389753B
CN110389753B CN201910490788.1A CN201910490788A CN110389753B CN 110389753 B CN110389753 B CN 110389753B CN 201910490788 A CN201910490788 A CN 201910490788A CN 110389753 B CN110389753 B CN 110389753B
Authority
CN
China
Prior art keywords
calling
chained
code
script file
script
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.)
Active
Application number
CN201910490788.1A
Other languages
Chinese (zh)
Other versions
CN110389753A (en
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.)
Wuba Co Ltd
Original Assignee
Wuba 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 Wuba Co Ltd filed Critical Wuba Co Ltd
Priority to CN201910490788.1A priority Critical patent/CN110389753B/en
Publication of CN110389753A publication Critical patent/CN110389753A/en
Application granted granted Critical
Publication of CN110389753B publication Critical patent/CN110389753B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention provides a chained calling method and device of a native application, electronic equipment and a storage medium, wherein the method comprises the following steps: reading the method names corresponding to each calling method in the chained script file; replacing the method name with a standard method name to obtain a processed chained script file; injecting the processed chained script file into a script execution environment; and executing the processed chained script file in the script execution environment to obtain an execution result. The chained calling method of the native application can effectively reduce the number of code lines of the chained script file by writing each calling method into a method of a single line code, and can effectively ensure that each calling method can normally call the corresponding native application by replacing the method name of each calling method with the standard method name, thereby ensuring the realizability of the chained script file.

Description

Chained calling method and device of native application, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of code design, and in particular, to a chained call method, apparatus, electronic device, and storage medium for native applications.
Background
In normal operation of App (Application software), a large number of native applications need to be invoked. In order to realize the related native application of the App call, the calling method for calling each native application needs to be written into the App script.
When the native application is called by the point grammar, the technician needs to write the calling method of all the native applications involved in the running of the App into the App script, and the calling method needs to contain a plurality of lines of codes such as the method name, the parameters and the like of the called native application. When the calling mode is adopted, if the same native application is required to be repeatedly called, all codes of a calling method of the native application are required to be repeatedly written into the App script, and at the moment, the added number of code lines in the App script is the sum of the number of code lines of all calling methods required to be written. For example, in the running process of the camera App, various native applications including a camera application, a lighting application, a timing application and the like need to be called, wherein the calling method of the camera application is 6 lines of codes, the calling method of the lighting application is 5 lines of codes, and the calling method of the timing application is 7 lines of codes, meanwhile, in the process, if the lighting application needs to be repeatedly called for 5 times, the 5 lines of codes of the lighting application need to be correspondingly written into the App script for 5 times, and finally, 38 lines of codes need to be added into the camera App script.
It can be seen that the native application is called using point grammar, if the same native application needs to be called multiple times, then code on the native application calling method needs to be added multiple times in App script. When the number of the code lines is large, the total number of the code lines of the App script is increased obviously.
Disclosure of Invention
The application provides a chained calling method, a chained calling device, electronic equipment and a storage medium of a native application, and aims to solve the problem that the number of code lines of an App script in the existing point grammar calling method is too large.
In a first aspect, an embodiment of the present invention provides a chained call method for a native application, including:
reading method names corresponding to each calling method in a chained script file, wherein the chained script file is a script file containing chained calling method codes, and the chained calling method codes are single-row codes written in a mode of integrating the calling method codes into one row according to a calling sequence;
replacing the method name with a standard method name to obtain a processed chained script file, wherein the standard method name and the method name of the native application corresponding to each calling method have the same code structure;
injecting the processed chained script file into a script execution environment, wherein the script execution environment comprises objects and functions for supporting execution of each calling method;
and executing the processed chained script file in the script execution environment to obtain an execution result.
In one possible implementation method of the first aspect of the embodiment of the present invention, before reading the method name corresponding to each calling method in the chained script file, the method name includes:
and positioning each code to be read in the chained script file, wherein the code to be read is a chained calling method code.
In a possible implementation manner of the first aspect of the embodiment of the present invention, the reading a method name corresponding to each calling method in the chained script file includes:
dividing the substitution code to be read into fragment codes according to the code structure of each calling method, wherein each fragment code corresponds to one calling method;
analyzing the code structure of the segment codes and extracting the method names in the segment codes;
and reading the method name.
In one possible implementation manner of the first aspect of the embodiment of the present invention, the replacing each method name with a standard method name, to obtain the processed chained script file includes:
acquiring a code of a target method name, wherein the target method name is a method name in a native application script file corresponding to the calling method;
analyzing the code of the target method name and determining a standard code structure of the target method name;
and replacing each method name with a standard method name by adopting a preset regular expression according to the standard code structure.
In one possible implementation manner of the first aspect of the embodiment of the present invention, before injecting the processed chained script file into the JS execution environment, the method includes:
and adding the objects and functions corresponding to the calling requirements in the script execution environment according to the calling requirements of the processed chained script file.
In a possible implementation manner of the first aspect of the embodiment of the present invention, the executing the processed chained script file in the script execution environment, to obtain the execution result includes:
acquiring an object and a function corresponding to the calling method from the script execution environment by adopting the calling method for executing the native application;
determining a calling interface, wherein the calling interface corresponds to a calling method in the processed chained script file;
and executing each calling method in the processed chained script file by using the object and the function through the calling interface to obtain an execution result.
In a second aspect, an embodiment of the present invention provides a chained call device for a native application, including:
the reading module is used for reading the method names corresponding to the calling methods in the chained script file, wherein the chained script file is a script file containing chained calling method codes, and the chained calling method codes are single-line codes which are compiled in a code compiling mode of integrating the calling method codes into one line according to a calling sequence;
the replacing module is used for replacing the method name with a standard method name to obtain a processed chained script file, wherein the standard method name and the method name of the native application corresponding to each calling method have the same code structure;
the injection module is used for injecting the processed chained script file into a script execution environment, and the script execution environment comprises objects and functions for supporting execution of each calling method;
and the execution module is used for executing the processed chained script file in the script execution environment to obtain an execution result.
In a possible implementation manner of the second aspect of the embodiment of the present invention, the apparatus further includes:
the code positioning module is used for positioning each code to be read in the chained script file, wherein the code to be read is chained calling method code.
In a possible implementation manner of the second aspect of the embodiment of the present invention, the reading module includes:
the code division module is used for dividing the substitution codes to be read into fragment codes according to the code structure of each calling method, and each fragment code corresponds to one calling method;
the method name extraction module is used for analyzing the code structure of the segment codes and extracting the method names in the segment codes;
and the method name reading module is used for reading the method name.
In a possible implementation manner of the second aspect of the embodiment of the present invention, the replacing module includes:
the code acquisition module is used for acquiring codes of target method names, wherein the target method names are method names in a native application script file corresponding to the calling method;
the standard code structure determining module is used for analyzing the codes of the target method names and determining the standard code structures of the target method names;
and the method name replacing module is used for replacing each method name with a standard method name by adopting a preset regular expression according to the standard code structure.
In a possible implementation manner of the second aspect of the embodiment of the present invention, the apparatus includes:
and the adding module is used for adding the object and the function corresponding to the calling requirement in the script execution environment according to the calling requirement of the processed chained script file.
In a possible implementation manner of the second aspect of the embodiment of the present invention, the executing module includes:
the element acquisition module is used for acquiring an object and a function corresponding to the calling method from the script execution environment by adopting the calling method for executing the native application;
the interface determining module is used for determining a calling interface, and the calling interface corresponds to a calling method in the processed chained script file;
and the script file executing module is used for executing each calling method in the processed chained script file by using the object and the function through the calling interface to obtain an executing result.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
processor and method for controlling the same
A memory for storing executable instructions of the processor;
wherein the processor is configured to execute a chained call method of any of the native applications via execution of the executable instructions.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a chained invocation method for any of the native applications.
The chained calling method, the chained calling device, the electronic equipment and the storage medium of the native application, provided by the embodiment of the invention, are characterized in that in the chained calling method of the native application, the method name corresponding to each calling method in the chained script file is read; replacing the method name with a standard method name to obtain a processed chained script file; injecting the processed chained script file into a script execution environment; and executing the processed chained script file in the script execution environment to obtain an execution result. In the embodiment of the invention, the chained calling method codes are written in a code writing mode of integrating the calling method codes into one line according to the calling sequence, and then the calling methods in a single line code form are obtained in the chained script file. In order to avoid that the chained calling method codes in the chained script file cannot normally call the original application due to the differences of written languages and the like of the chained script file and the original application, the method names corresponding to the calling methods in the chained script file need to be replaced by standard method names conforming to the method name code structure of the original application. And injecting the processed chained script file into a script execution environment, and calling a corresponding native application by using the objects and functions of each calling method contained in the script execution environment to obtain an execution result. Therefore, the chained calling method of the native application can effectively reduce the number of lines of codes of the chained script file by writing each calling method into a method of a single line code, and can effectively ensure that each calling method can normally call the corresponding native application by replacing the method name of each calling method with the standard method name, thereby ensuring the realizability of the chained script file.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the embodiments will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flowchart of a chained call method of a native application according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for reading method names according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method for replacing method names according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for executing a processed chain script file according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a chain call device of a native application according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a read module according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an alternative module according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an alternative module according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of a chained call method of a native application according to an embodiment of the present invention. As shown in fig. 1, the chained call method of the native application provided in this embodiment includes:
s1, reading method names corresponding to each calling method in a chained script file, wherein the chained script file is a script file containing chained calling method codes, and the chained calling method codes are single-line codes written in a code writing mode of integrating the calling method codes into one line according to a calling sequence.
The code writing of the existing application script file adopts a multi-line code writing mode, wherein the code of each calling method is in a multi-line code mode, and the code writing of the script file adopts the mode that the codes of all the calling methods are overlapped together in a serial mode. Thus, for each calling method, the adopted execution mode is to take line codes as units, and the execution is jumped between lines; and for the whole script file, the adopted execution mode is to take the calling method codes as units, and because the code line differences exist among the calling method codes, jump execution exists between the calling methods. As can be seen, the existing multi-line code writing mode of the script file has a jump process, namely has a pause and lacks continuity when being executed. The script file provided by the embodiment of the invention is a chained script file, namely, the script file which is obtained by writing a code writing mode of integrating all calling method codes into one line according to the calling sequence and has a single line code form is adopted. Therefore, the number of lines of codes of the chained script file provided by the application is one line, although the whole code quantity is not reduced, as the difference of the code lines does not exist between the codes of each calling method and the difference of the code lines does not exist before the codes of each calling method, the jump problem in the executing process can be effectively avoided, the executing process of the chained script file is more continuous, and meanwhile, the maintenance work of code writers can be more convenient due to the remarkable reduction of the number of lines of codes.
For example, in the running process of the camera App, various native applications need to be called, including a camera application, a lighting application, a timing application, and the like, where the calling method code of the camera application is a, the calling method code of the lighting application is B, and the calling method code of the timing application is C, and in this process, if the lighting application needs to be repeatedly called 5 times, the code of each native application required to be called by the camera App written by adopting the single-line code writing manner provided by the embodiment of the present invention is a: b: b: b: c: b: B. therefore, each calling method has no code line difference in the chained script file, and when the chained script file is executed, the corresponding native application can be continuously executed only by sequentially calling the method names in the calling method. Meanwhile, in the chained script file, the compiling sequence of each calling method code is controlled, so that the calling sequence of each native application is controlled.
S2, replacing the method name with a standard method name to obtain a processed chain script file, wherein the standard method name and the method name of the native application corresponding to each calling method have the same code structure.
Typically, technicians write chained script files in a language environment such as java, javascript, while native applications are typically written in a language environment such as Objective-C, swift. It can be seen that the programming language of the method name corresponding to each calling method in the chained script file is different from the programming language of the method name corresponding to the native application. For example, a method written using javascript in a chained script file will be named a, while a corresponding native application will be named a using Objective-C.
When the chained script file obtained through the S1 runs, the corresponding native application is correspondingly called through the written method name, so that if the method name in the chained script file is different from the method name of the native application, the situation that the corresponding native application cannot be found can occur. Therefore, it is necessary to replace each method name in the chained script file with a standard method name having the same code structure as the native method name. For example, a regular expression is preset, and all method names A written by adopting javascript in a chained script file are replaced by corresponding method names a written by adopting Objective-C in the original application, so that the calling condition of the original application is met.
S3, injecting the processed chained script file into a script execution environment, wherein the script execution environment comprises objects and functions for supporting execution of each calling method;
s4, executing the processed chained script file in the script execution environment to obtain an execution result.
The processed chained script file obtained by replacing the method name by the S2 has a foundation capable of calling the corresponding native application, namely the method name, but the related native application cannot be really executed only by the method name, and the corresponding execution environment is required to be really realized to execute the native application. Therefore, the processed chained script file needs to be injected into a script execution environment with a certain execution capability, wherein the certain execution capability is defined as containing objects and functions supporting execution of each calling method. When the chained script file is executed, the needed objects and functions are searched in the script execution environment, and then the execution is carried out to obtain an execution result, so that the chained calling process is completed.
Therefore, the chained calling method of the native application can effectively reduce the number of lines of codes of the chained script file by writing each calling method into a method of a single line code, and can effectively ensure that each calling method can normally call the corresponding native application by replacing the method name of each calling method with the standard method name, thereby ensuring the realizability of the chained script file.
The chained script file is based on the current script file, various calling methods are added to realize corresponding calling actions, so that the S1 reads the process of the method names corresponding to the calling methods in the chained script file, the position of the method names in the chained script file is needed to be determined firstly, the method names are written in chained calling method codes, and therefore the chained calling method codes are positioned in the chained script, and the method names can be positioned.
Specifically, each code to be read is positioned in the chained script file, and the code to be read is chained calling method code. Because the chained calling method codes are codes which are compiled in a single-line code compiling mode and contain the calling methods, the chained calling method codes can be rapidly resolved through the code structure, and the chained calling method codes can be determined from codes with single-line, long-line and/or multiple repeated character segment structures.
Because the chained calling method codes are directly positioned, the time for analyzing the rest part of the script file can be saved, and meanwhile, the chained calling method codes are positioned progressively through the structures of the chained calling method codes, so that the speed is high, and the accuracy is high. The progressive positioning method can effectively improve the positioning efficiency and accuracy.
From the chain call method code obtained as described above, each method name in the chain call method code can be further determined.
FIG. 2 shows a flow chart of a method of reading a method name. The method comprises the following steps:
s101, comparing code structures of the calling methods, dividing the substitution codes to be read into fragment codes, wherein each fragment code corresponds to one calling method;
s102, analyzing a code structure of the segment codes, and extracting method names in the segment codes;
s103, reading the method name.
The code to be read contains various fields, such as a function field, a representation field, a method name segment and the like used for calling the method, wherein each field has a corresponding code. Thus, by referring to the code structure of each calling method, the code to be read composed of a plurality of calling methods can be divided into fragment codes in units of a single calling method. The fragment code contains redundant fields such as function digital segments, and the like, and because the fields are different from the code structures of the method names, the method names in the fragment code can be accurately extracted and further read by analyzing the code structures of the fragment code.
The method for locating the method name code provided by the embodiment of the invention can accurately locate the method name, so as to ensure the accuracy of the standard method name replaced subsequently, and prevent the bad influence on the regular replacement subsequently caused by the error locating of the method name, such as missing and deleting the code.
The writing language of each method name obtained in S1 is different from the writing language of the native application method name, so that these method names cannot be directly called, and therefore, regular replacement needs to be performed on each method name.
Fig. 3 shows a schematic flow chart of a method of replacing a method name, the method comprising:
s201, acquiring a code of a target method name, wherein the target method name is a method name in a native application script file corresponding to the calling method;
s202, analyzing codes of the target method names, and determining standard code structures of the target method names;
s203, replacing each method name with a standard method name by adopting a preset regular expression according to the standard code structure.
The method names obtained by S101-S103 each have a corresponding target method name in the native application script file of each native application, for example, the method name in the chained call method code is a, the standard method name in the corresponding native application script file is a, and although a and a are the method names corresponding to the same native application, the language environment adopted by a and a in programming is different, so that a and a have different code structures, and only the method name of a with such code structure can normally call the native application. In order to replace the method name in the chained calling method code with the standard method name capable of normally calling the native application, it is necessary to first determine what structure the standard method name capable of normally calling the native application has, so that the code of the target method name is acquired, the standard code structure of the target method name can be determined by analyzing the code of the target method name, and the method name with the standard code structure is the method name capable of normally calling the native application. Therefore, according to the standard code structure, a preset regular expression can be adopted to replace each method name in the chained calling method code with a standard method name with a standard code structure, so that the standard method name of the native application can be normally called.
Meanwhile, other alternative modes of replacing the code of the target method name with the standard code structure can be adopted, and the details are not repeated here.
The method name obtained by the replacement of the embodiment of the invention can ensure that various native applications can be successfully called in the execution process of the chained script file, and the situation that the native applications cannot be found is avoided.
The standard method name obtained by S2 already has the condition of normally calling the native application, but a script execution environment for providing a processed chain script file for calling the native application is also required. The script execution environment needs to have objects and functions capable of handling the calling methods, and the setting of the calling methods is determined according to the calling requirements of the chained script file after the processing. For example, when the camera App is used at night, illumination is required, the illumination is a call demand, and the illumination application is a native application waiting for the call. Only if the script execution environment contains objects and functions capable of supporting illumination, the illumination application can be invoked normally. Therefore, according to the call requirement of the processed chained script file, adding the object and the function corresponding to the call requirement in the script execution environment.
FIG. 4 illustrates a flow diagram of a method of executing a post-processing chained script file, comprising:
s401, acquiring an object and a function corresponding to a calling method from the script execution environment by adopting the calling method for executing the native application;
s402, determining a calling interface, wherein the calling interface corresponds to a calling method in the processed chained script file;
s403, executing each calling method in the processed chained script file by using the object and the function through the calling interface to obtain an execution result.
After S2 and S3, a calling method of the Native application, for example, a run Native method is executed, and execution of the chained script file in the script execution environment is started. At this time, it is necessary to acquire a Native object, a method Name (selector Name) ready for execution, a method parameter (arg), and the like from the script execution environment. The act of invoking the native application is typically implemented through an invocation interface, the native application corresponding to the invocation method, so that each invocation interface, e.g., bridge JS, can be determined by the invocation method. The procedure of calling can be as follows, the bridge js. Run Native Method With Target Method Name And Parameters, call the native application by using the reflection mechanism, and obtain the execution result.
If the calling method contains parameters, the selector Name written by Objective-C will contain: in executing the chained script file, if the parameter to be transferred is one, the parameter is directly written in brackets, such as xxx: (arg 1), wherein xxx is a method name and arg is a parameter; if the parameters to be transferred are plural, for example, the selector Name written in Objective-C is xxx_xxx (arg 1, arg 2), then it needs to be replaced with yyy: yyy, where yyy contains xxx and arg, which can reduce the occurrence of parameters, unify code formats.
Fig. 5 is a schematic structural diagram of a chained call device for native applications according to an embodiment of the present invention, where the device includes: the reading module 1 is used for reading the method names corresponding to each calling method in the chained script file, wherein the chained script file is a script file containing chained calling method codes, and the chained calling method codes are single-line codes which are obtained by writing a code writing mode of integrating the calling method codes into one line according to a calling sequence; the replacing module 2 is used for replacing the method name with a standard method name to obtain a processed chained script file, wherein the standard method name and the method name of the native application corresponding to each calling method have the same code structure; an injection module 3, configured to inject the processed chained script file into a script execution environment, where the script execution environment includes objects and functions that support executing each of the calling methods; and the execution module 4 is used for executing the processed chained script file in the script execution environment to obtain an execution result.
Further, the apparatus further comprises: and the code positioning module 5 is used for positioning each code to be read in the chained script file, wherein the code to be read is chained calling method code.
Fig. 6 is a schematic structural diagram of a reading module according to an embodiment of the present invention, where the reading module 1 includes: the code division module 11 is configured to divide the substitution code to be read into fragment codes against the code structures of the calling methods, where each fragment code corresponds to one calling method; a method name extraction module 12, configured to analyze a code structure of the segment code, and extract a method name in the segment code; a method name reading module 13, configured to read the method name.
Fig. 7 is a schematic structural diagram of a replacement module according to an embodiment of the present invention, where the replacement module 2 includes: a code obtaining module 21, configured to obtain a code of a target method name, where the target method name is a method name in a native application script file corresponding to the calling method; a standard code structure determining module 22, configured to analyze the code of the target method name and determine a standard code structure of the target method name; and a method name replacing module 23, configured to replace each of the method names with a standard method name by using a preset regular expression according to the standard code structure.
As shown in fig. 5, the apparatus further includes: and the adding module 6 is used for adding the object and the function corresponding to the calling requirement in the script execution environment according to the calling requirement of the processed chained script file.
Fig. 8 is a schematic structural diagram of an execution module according to an embodiment of the present invention, where the execution module 4 includes: an element obtaining module 41, configured to obtain, from the script execution environment, an object and a function corresponding to a calling method for executing a native application; an interface determining module 42, configured to determine a calling interface, where the calling interface corresponds to a calling method in the processed chained script file; and the script file executing module 43 is configured to execute each calling method in the processed chained script file by using the object and the function through the calling interface, so as to obtain an execution result.
Fig. 9 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention. The electronic device includes: a memory 101 and a processor 102;
a memory 101 for storing a computer program;
a processor 102 for executing a computer program stored in a memory to implement the chained call method of the native application in the above embodiment. Reference may be made in particular to the relevant description of the embodiments of the method described above.
Alternatively, the memory 101 may be separate or integrated with the processor 102.
When the memory 101 is a device separate from the processor 102, the electronic device may further include:
a bus 103 for connecting said memory 101 and processor 102.
The electronic device provided by the embodiment of the invention can be used for executing the chained call method of the native application shown in any one of the above embodiments, and the implementation manner and the technical effect are similar, and the embodiment of the invention is not repeated here.
The embodiment of the invention also provides a readable storage medium, in which a computer program is stored, and when at least one processor of the message sending device executes the computer program, the message sending device executes the chained call method of the native application in any of the above embodiments.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer-readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that modifications may be made to the technical solutions described in the foregoing embodiments, or equivalents may be substituted for some or all of the technical features thereof, without departing from the spirit of the technical solutions of the embodiments of the invention.

Claims (10)

1. A chained call method for a native application, the method comprising:
positioning each code to be read in a chained script file, wherein the code to be read is a chained calling method code, the chained calling method code is determined in the codes with single-row, long-chain and/or multiple repeated character segment structures in the chained script file based on a code structure, the chained calling method code is a single-row code written in a mode of integrating each calling method code into one row according to a calling sequence, and each calling method has no code row difference in the chained script file;
reading the method names corresponding to the calling methods in the code to be read, and when the chained script file is executed, sequentially calling the method names in the calling methods and continuously executing corresponding native applications;
acquiring codes of target method names, wherein the target method names are method names in a native application script file corresponding to the calling method, analyzing the codes of the target method names, determining a standard code structure of the target method names, wherein the method names with the standard code structure are method names capable of normally calling native applications, replacing each method name in the chained calling method codes with the standard code structure and the standard method name capable of normally calling the native applications according to the standard code structure by adopting a preset regular expression, and obtaining a processed chained script file, wherein the standard method names and the method names of the native applications corresponding to each calling method have the same code structure;
injecting the processed chained script file into a script execution environment, wherein the script execution environment comprises objects and functions for supporting execution of each calling method;
and executing the processed chained script file in the script execution environment to obtain an execution result.
2. The method of claim 1, wherein the reading the method name corresponding to each calling method in the code to be read comprises:
dividing the substitution code to be read into fragment codes according to the code structure of each calling method, wherein each fragment code corresponds to one calling method;
analyzing the code structure of the segment codes and extracting the method names in the segment codes;
and reading the method name.
3. The method of claim 1, wherein the injecting the post-processing chained script file into the script execution environment is preceded by:
and adding the objects and functions corresponding to the calling requirements in the script execution environment according to the calling requirements of the processed chained script file.
4. The method of claim 1, wherein executing the post-processing chained script file in the script execution environment to obtain the execution result comprises:
acquiring an object and a function corresponding to the calling method from the script execution environment by adopting the calling method for executing the native application;
determining a calling interface, wherein the calling interface corresponds to a calling method in the processed chained script file;
and executing each calling method in the processed chained script file by using the object and the function through the calling interface to obtain an execution result.
5. A chained call device for a native application, the device comprising:
the code positioning module is used for positioning each code to be read in a chained script file, wherein the code to be read is a chained calling method code, the chained calling method code is determined in the codes with single-row, long-chain and/or multiple repeated character segment structures in the chained script file based on a code structure, the chained calling method code is a single-row code written in a code writing mode of integrating the calling method codes into one row according to a calling sequence, and the calling methods have no difference of code rows in the chained script file;
the reading module is used for reading the method names corresponding to the calling methods in the substitution codes to be read, and when the chained script file is executed, the method names in the calling methods are sequentially called, and corresponding native applications are continuously executed;
a replacement module, comprising: the code acquisition module is used for acquiring codes of target method names, wherein the target method names are method names in a native application script file corresponding to the calling method; the standard code structure determining module is used for analyzing the code of the target method name, determining the standard code structure of the target method name, wherein the method name with the standard code structure is a method name capable of normally calling a native application; the method name replacing module is used for replacing each method name in the chained calling method code with a standard method name which has the standard code structure and can normally call the original application by adopting a preset regular expression according to the standard code structure to obtain a processed chained script file, wherein the standard method name has the same code structure as the method name of the original application corresponding to each calling method;
the injection module is used for injecting the processed chained script file into a script execution environment, and the script execution environment comprises objects and functions for supporting execution of each calling method;
and the execution module is used for executing the processed chained script file in the script execution environment to obtain an execution result.
6. The apparatus of claim 5, wherein the reading module comprises:
the code division module is used for dividing the substitution codes to be read into fragment codes according to the code structure of each calling method, and each fragment code corresponds to one calling method;
the method name extraction module is used for analyzing the code structure of the segment codes and extracting the method names in the segment codes;
and the method name reading module is used for reading the method name.
7. The apparatus of claim 5, wherein the apparatus comprises:
and the adding module is used for adding the object and the function corresponding to the calling requirement in the script execution environment according to the calling requirement of the processed chained script file.
8. The apparatus of claim 5, wherein the execution module comprises:
the element acquisition module is used for acquiring an object and a function corresponding to the calling method from the script execution environment by adopting the calling method for executing the native application;
the interface determining module is used for determining a calling interface, and the calling interface corresponds to a calling method in the processed chained script file;
and the script file executing module is used for executing each calling method in the processed chained script file by using the object and the function through the calling interface to obtain an executing result.
9. An electronic device, the electronic device comprising:
processor and method for controlling the same
A memory for storing executable instructions of the processor;
wherein the processor is configured to execute the chained call method of the native application of any one of claims 1-4 via execution of the executable instructions.
10. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the chained invocation method of a native application of any of claims 1-4.
CN201910490788.1A 2019-06-06 2019-06-06 Chained calling method and device of native application, electronic equipment and storage medium Active CN110389753B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910490788.1A CN110389753B (en) 2019-06-06 2019-06-06 Chained calling method and device of native application, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910490788.1A CN110389753B (en) 2019-06-06 2019-06-06 Chained calling method and device of native application, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110389753A CN110389753A (en) 2019-10-29
CN110389753B true CN110389753B (en) 2024-01-23

Family

ID=68285239

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910490788.1A Active CN110389753B (en) 2019-06-06 2019-06-06 Chained calling method and device of native application, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110389753B (en)

Citations (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1369825A (en) * 2001-02-15 2002-09-18 英业达股份有限公司 Method for replacing system function function in operating system
EP1936532A1 (en) * 2006-12-21 2008-06-25 Telefonaktiebolaget LM Ericsson (publ) Obfuscating computer program code
CN101216760A (en) * 2007-12-28 2008-07-09 北京方正国际软件系统有限公司 Dynamic mapping interface calling system and method
CN104335220A (en) * 2012-03-30 2015-02-04 爱迪德加拿大公司 Method and system for preventing and detecting security threats
CN104423986A (en) * 2013-09-02 2015-03-18 北京亿阳信通科技有限公司 Method and device for embedding script into application system
CN104699503A (en) * 2015-02-28 2015-06-10 深圳市同洲电子股份有限公司 Method and device for replacing function execution logic in Android system
WO2015185328A1 (en) * 2014-06-06 2015-12-10 Rode Oliver Computer-implemented method and signal sequence for a program for reusing software configurations that can be executed for software systems, and computer system, and a computer program with program code for carrying out the method
CN105446788A (en) * 2014-08-20 2016-03-30 联想(北京)有限公司 Information processing method and electronic equipment
CN105808438A (en) * 2016-03-11 2016-07-27 北京信息科技大学 Test case reuse method based on function call path
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN106547527A (en) * 2015-09-22 2017-03-29 阿里巴巴集团控股有限公司 A kind of JavaScript file construction method and device
CN107015873A (en) * 2017-01-23 2017-08-04 阿里巴巴集团控股有限公司 Call method, component interface device, electronic equipment and the App of App functional module
CN107122169A (en) * 2017-03-21 2017-09-01 武汉斗鱼网络科技有限公司 A kind of method and device of Flash function encryptings
CN107239270A (en) * 2016-03-29 2017-10-10 阿里巴巴集团控股有限公司 Code process method and apparatus
CN107480476A (en) * 2017-06-15 2017-12-15 西北大学 A kind of Android local layer compiling of instruction based on ELF infection virtualizes shell adding method
CN107678968A (en) * 2017-10-18 2018-02-09 北京奇虎科技有限公司 Sample extraction method, apparatus, computing device and the storage medium of source code function
JP2018041373A (en) * 2016-09-09 2018-03-15 オムロン株式会社 Executable program creation device, executable program creation method, and executable program creation program
CN107943493A (en) * 2016-10-12 2018-04-20 北京京东尚科信息技术有限公司 A kind of method and apparatus that problem in the App that reached the standard grade is repaired based on iOS system silence
CN108037914A (en) * 2017-12-26 2018-05-15 福建中金在线信息科技有限公司 A kind of method and device of Android primary system combination js exploitations
CN108197440A (en) * 2017-11-28 2018-06-22 五八有限公司 A kind of Code obfuscation method, equipment and computer readable storage medium
CN108459852A (en) * 2018-01-30 2018-08-28 美通云动(北京)科技有限公司 Script processing method and device, storage medium, electronic equipment
CN108846264A (en) * 2018-06-11 2018-11-20 北京奇虎科技有限公司 Code reinforcement means, device, intelligent terminal and computer readable storage medium
CN108845841A (en) * 2018-06-15 2018-11-20 广州多益网络股份有限公司 Change the method, apparatus and terminal of terminal applies behavior
CN109032687A (en) * 2018-06-11 2018-12-18 北京奇艺世纪科技有限公司 Shield the method and device that SDK danger is called
CN109240697A (en) * 2017-05-22 2019-01-18 腾讯科技(深圳)有限公司 Calling processing method and device, storage medium
CN109376074A (en) * 2018-09-14 2019-02-22 浙江口碑网络技术有限公司 Obtain method and device, the storage medium, electronic device of log
CN109710340A (en) * 2019-01-18 2019-05-03 北京顺丰同城科技有限公司 Software tool call method and device, software tool packaging method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005141380A (en) * 2003-11-05 2005-06-02 Matsushita Electric Ind Co Ltd Template compile method
JP4770425B2 (en) * 2005-11-24 2011-09-14 富士ゼロックス株式会社 Program, method and apparatus for creating protected execution program
US9419991B2 (en) * 2014-09-30 2016-08-16 Juniper Networks, Inc. De-obfuscating scripted language for network intrusion detection using a regular expression signature
US10223080B2 (en) * 2015-01-14 2019-03-05 Dynatrace Llc Method and system for automated, static instrumentation for applications designed for execution in environments with restricted resources
JP6186387B2 (en) * 2015-03-19 2017-08-23 株式会社日立製作所 Confidential data processing system
DE102015112143B4 (en) * 2015-07-24 2017-04-06 Infineon Technologies Ag A method of determining an integrity of an execution of a code fragment and a method of providing an abstract representation of a program code

Patent Citations (27)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1369825A (en) * 2001-02-15 2002-09-18 英业达股份有限公司 Method for replacing system function function in operating system
EP1936532A1 (en) * 2006-12-21 2008-06-25 Telefonaktiebolaget LM Ericsson (publ) Obfuscating computer program code
CN101216760A (en) * 2007-12-28 2008-07-09 北京方正国际软件系统有限公司 Dynamic mapping interface calling system and method
CN104335220A (en) * 2012-03-30 2015-02-04 爱迪德加拿大公司 Method and system for preventing and detecting security threats
CN104423986A (en) * 2013-09-02 2015-03-18 北京亿阳信通科技有限公司 Method and device for embedding script into application system
WO2015185328A1 (en) * 2014-06-06 2015-12-10 Rode Oliver Computer-implemented method and signal sequence for a program for reusing software configurations that can be executed for software systems, and computer system, and a computer program with program code for carrying out the method
CN105446788A (en) * 2014-08-20 2016-03-30 联想(北京)有限公司 Information processing method and electronic equipment
CN104699503A (en) * 2015-02-28 2015-06-10 深圳市同洲电子股份有限公司 Method and device for replacing function execution logic in Android system
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN106547527A (en) * 2015-09-22 2017-03-29 阿里巴巴集团控股有限公司 A kind of JavaScript file construction method and device
CN105808438A (en) * 2016-03-11 2016-07-27 北京信息科技大学 Test case reuse method based on function call path
CN107239270A (en) * 2016-03-29 2017-10-10 阿里巴巴集团控股有限公司 Code process method and apparatus
JP2018041373A (en) * 2016-09-09 2018-03-15 オムロン株式会社 Executable program creation device, executable program creation method, and executable program creation program
CN107943493A (en) * 2016-10-12 2018-04-20 北京京东尚科信息技术有限公司 A kind of method and apparatus that problem in the App that reached the standard grade is repaired based on iOS system silence
CN107015873A (en) * 2017-01-23 2017-08-04 阿里巴巴集团控股有限公司 Call method, component interface device, electronic equipment and the App of App functional module
CN107122169A (en) * 2017-03-21 2017-09-01 武汉斗鱼网络科技有限公司 A kind of method and device of Flash function encryptings
CN109240697A (en) * 2017-05-22 2019-01-18 腾讯科技(深圳)有限公司 Calling processing method and device, storage medium
CN107480476A (en) * 2017-06-15 2017-12-15 西北大学 A kind of Android local layer compiling of instruction based on ELF infection virtualizes shell adding method
CN107678968A (en) * 2017-10-18 2018-02-09 北京奇虎科技有限公司 Sample extraction method, apparatus, computing device and the storage medium of source code function
CN108197440A (en) * 2017-11-28 2018-06-22 五八有限公司 A kind of Code obfuscation method, equipment and computer readable storage medium
CN108037914A (en) * 2017-12-26 2018-05-15 福建中金在线信息科技有限公司 A kind of method and device of Android primary system combination js exploitations
CN108459852A (en) * 2018-01-30 2018-08-28 美通云动(北京)科技有限公司 Script processing method and device, storage medium, electronic equipment
CN108846264A (en) * 2018-06-11 2018-11-20 北京奇虎科技有限公司 Code reinforcement means, device, intelligent terminal and computer readable storage medium
CN109032687A (en) * 2018-06-11 2018-12-18 北京奇艺世纪科技有限公司 Shield the method and device that SDK danger is called
CN108845841A (en) * 2018-06-15 2018-11-20 广州多益网络股份有限公司 Change the method, apparatus and terminal of terminal applies behavior
CN109376074A (en) * 2018-09-14 2019-02-22 浙江口碑网络技术有限公司 Obtain method and device, the storage medium, electronic device of log
CN109710340A (en) * 2019-01-18 2019-05-03 北京顺丰同城科技有限公司 Software tool call method and device, software tool packaging method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
iOS Runtime System安全性研究;周泊宁;;计算机应用与软件(第01期);全文 *
基于VB6.0的监控系统软件中数据存储及数据曲线实现方法的研究;赵卫强等;《沈阳航空工业学院学报》;20030425(第01期);全文 *

Also Published As

Publication number Publication date
CN110389753A (en) 2019-10-29

Similar Documents

Publication Publication Date Title
CN108388514B (en) Interface automation test method, device, equipment and computer readable storage medium
US20170132026A1 (en) Apparatus and method for optimizing startup of embedded system
US9229738B2 (en) Software development tool for providing user context information to improve message quality at development time
CN109375921B (en) Page file quick compiling method and device, storage device and computer device
CN109814948B (en) Method, device and electronic device for hooking native layer functions based on xposed framework
EP2876556A1 (en) Fast restart of applications using shared memory
US9870309B2 (en) Variable tracking in program debugging
US8881107B2 (en) Automatic memory leak detection
US10268568B2 (en) System and method for data element tracing
CN110554962A (en) Regression testing process covering method, server and computer readable storage medium
CN114860654A (en) Method and system for dynamically changing Iceberg table Schema based on Flink data stream
CN110471786B (en) Online thermal remediation method, device, equipment and computer readable storage medium
CN107544811B (en) Method, storage medium, electronic device and system for hiding dylib file in IOS platform
CN110389753B (en) Chained calling method and device of native application, electronic equipment and storage medium
CN110990051B (en) Maintenance method, device, medium and equipment for software package dependency relationship
CN102880473A (en) Method and device for task execution based on quartz framework
CN108459952B (en) Program exception processing method and system
CN103218241B (en) patch loading method and device
CN111352610A (en) Interface return value modification method and device, electronic equipment and storage medium
CN110597549B (en) Searching method, device and equipment in code engineering and readable storage medium
CN112597131B (en) Distributed script control method and related device
CN110008116B (en) Wechat webapp debugging method and device
CN116155934A (en) Method, device, electronic equipment and storage medium for intelligent contract call account book
US11379251B2 (en) Method for executing a computer program in a computer network, in particular in order to control a microscope
CN111061467B (en) Method for efficiently managing front-end engineering request module

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
GR01 Patent grant
GR01 Patent grant