CN111124553B - Program execution method, device, terminal and storage medium - Google Patents

Program execution method, device, terminal and storage medium Download PDF

Info

Publication number
CN111124553B
CN111124553B CN201911243362.2A CN201911243362A CN111124553B CN 111124553 B CN111124553 B CN 111124553B CN 201911243362 A CN201911243362 A CN 201911243362A CN 111124553 B CN111124553 B CN 111124553B
Authority
CN
China
Prior art keywords
execution
code
execution code
execution environment
environment
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
CN201911243362.2A
Other languages
Chinese (zh)
Other versions
CN111124553A (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.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software 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 Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201911243362.2A priority Critical patent/CN111124553B/en
Publication of CN111124553A publication Critical patent/CN111124553A/en
Application granted granted Critical
Publication of CN111124553B publication Critical patent/CN111124553B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • G06F9/4484Executing subprograms

Landscapes

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

Abstract

The disclosure relates to a program execution method, a device, a terminal and a storage medium, wherein the method comprises the following steps: configuring a communication channel between a first execution environment and a second execution environment; first execution code in the first execution environment and calling second execution code running in the second execution environment through the communication channel; and running the second execution code in the first execution environment to obtain a program execution result. Therefore, the same software product can be split for development or debugging, and when the software product is modified or debugged, the part needing to be modified or debugged can be independently processed, so that the workload of developers is reduced, the development efficiency is improved, and the development cost is reduced.

Description

Program execution method, device, terminal and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a program execution method, apparatus, terminal, and storage medium.
Background
In the related art, for the same software product, for example, for an application program, it is required that the entire software product be executed smoothly using the same development language and in the same execution environment. That is, for the same software product, it is required that the developer adopts the same development language and executes in the same execution environment, and when the development or debugging of the whole project is started in the face of some fine adjustments, the workload of the developer is obviously increased, the development efficiency is slow, the development cost is high, and the like.
Disclosure of Invention
According to a first aspect of an embodiment of the present disclosure, there is provided a program execution method, including:
configuring a communication channel between a first execution environment and a second execution environment;
first execution code in the first execution environment and calling second execution code running in the second execution environment through the communication channel;
And running the second execution code in the first execution environment to obtain a program execution result.
Optionally, the first execution code in the first execution environment invokes, through the communication channel, the second execution code running in the second execution environment, including:
Detecting whether a call requirement for calling the second execution code exists;
And when the calling requirement exists, calling the second execution code running in the second execution environment through the communication channel by the first execution code in the first execution environment.
Optionally, the detecting whether there is a call requirement to call the second execution code includes one of:
Determining that the call requirement for calling the second execution code exists when a page which is originally embedded in the first execution code and contains the second execution code is started;
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
Optionally, the first execution code in the first execution environment invokes, through the communication channel, the second execution code running in the second execution environment, including:
Transmitting the encapsulation package of the second execution code to the first execution code through the communication channel, and configuring the encapsulation package at a preset position of the first execution code;
the running the second execution code in the first execution environment to obtain a program running result includes:
the first execution code comprising the encapsulation package is executed in the first execution environment to obtain a program execution result.
Optionally, the method further comprises:
Determining that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
Optionally, the first execution environment is an execution environment of an application program, the first execution code is a native code of the application program, the second execution environment is an execution environment of a webpage presented by the application program, and the second execution code is a code of the webpage;
Or alternatively
The first execution environment is the execution environment of a webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
According to a second aspect of the embodiments of the present disclosure, there is provided a program execution device including:
a configuration module configured to configure a communication channel between the first execution environment and the second execution environment;
a calling module configured to call a first execution code in the first execution environment, and a second execution code running in the second execution environment through the communication channel;
and the running module is configured to run the second execution code in the first execution environment to obtain a program execution result.
Optionally, the calling module further includes:
A detection sub-module configured to detect whether there is a call requirement to call the second execution code;
And the calling sub-module is configured to call the second execution code running in the second execution environment through the communication channel in the first execution environment when the calling requirement exists.
Optionally, the detection sub-module is configured to be one of:
Determining that the call requirement for calling the second execution code exists when a page which is originally embedded in the first execution code and contains the second execution code is started;
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
Optionally, the calling module is further configured to:
Transmitting the encapsulation package of the second execution code to the first execution code through the communication channel, and configuring the encapsulation package at a preset position of the first execution code;
the operation module is further configured to:
the first execution code comprising the encapsulation package is executed in the first execution environment to obtain a program execution result.
Optionally, the apparatus further comprises:
the determining module is configured to determine that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
Optionally, the first execution environment is an execution environment of an application program, the first execution code is a native code of the application program, the second execution environment is an execution environment of a webpage presented by the application program, and the second execution code is a code of the webpage;
Or alternatively
The first execution environment is the execution environment of a webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
According to a third aspect of embodiments of the present disclosure, there is provided a terminal comprising:
A processor;
A memory for storing processor-executable instructions;
wherein the processor is configured to:
configuring a communication channel between a first execution environment and a second execution environment;
first execution code in the first execution environment and calling second execution code running in the second execution environment through the communication channel;
And running the second execution code in the first execution environment to obtain a program execution result.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon a computer program for execution by a processor to perform any of the method steps described above.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
In an embodiment of the present disclosure, a communication channel is configured between a first execution environment and a second execution environment; first execution code in the first execution environment and calling second execution code running in the second execution environment through the communication channel; and running the second execution code in the first execution environment to obtain a program execution result. That is, the embodiments of the present disclosure may call a second execution code running in a second execution environment through a communication channel configured between the first execution environment and the second execution environment, and then run the second execution code in the first execution environment to obtain a program running result. Therefore, the embodiment of the disclosure does not need to limit the same software product to the same execution code and execute the same execution code in the same execution environment, but can use different execution codes for different parts of the same software product to execute the same software product in different execution environments, and realize the mutual calling between the two execution codes through a communication channel to run so as to obtain a program execution result, so that the same software product can be split for development or debugging, and when the software product is modified or debugged, the parts needing to be modified or debugged can be independently processed, thereby reducing the workload of developers, improving the development efficiency and reducing the development cost.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flowchart illustrating a method of program execution according to an exemplary embodiment;
FIG. 2 is another flow chart of a method of program execution according to an exemplary embodiment;
FIG. 3 is yet another flowchart illustrating a method of program execution according to an exemplary embodiment;
FIG. 4 is a block diagram of a program execution device, according to an example embodiment;
fig. 5 is a block diagram of a terminal according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the invention. Rather, they are merely examples of apparatus and methods consistent with aspects of the invention as detailed in the accompanying claims.
Fig. 1 is a flowchart illustrating a program execution method according to an exemplary embodiment, which is applied to a terminal as shown in fig. 1, including the steps of:
Step 101: a communication channel is configured between the first execution environment and the second execution environment.
Here, the terminal may specifically be a mobile terminal or a fixed terminal; the mobile terminal can be a mobile phone, a tablet computer, a notebook computer and the like; the fixed terminal may be a desktop computer. The method may be applied to any terminal capable of running a computer program.
Here, the execution environment refers to an execution environment in which program codes are executed, and programs written in different development languages need to be executed in the execution environment provided for the languages. For example, a program written by Java needs to run in a JRE (Java Runtime Environment, java running environment) environment; the program written by JavaScript is required to run in the environment provided by the browser, and for example, the program written by c# is required to run in microsoft.
It should be noted that JavaScript is a graphic layer language, and java or c# is server-side code.
Here, the communication channel may be a communication protocol defined between the first execution environment and the second execution environment, or a communication rule for performing program interaction between the first execution environment and the second execution environment.
For example, an execution code that needs to interact between a first execution environment and a second execution environment may be packaged in a pre-configured package so that the execution code can be executed in another execution environment based on the package in the other execution environment.
For another example, the execution code that needs to interact between the first execution environment and the second execution environment may be converted in advance, and the converted execution code may be transferred to the other execution environment through the communication channel so as to be executable in the other execution environment.
That is, the communication channel can complete interaction of the execution codes in the first execution environment and the second execution environment, so that smooth execution of the program executed under different execution environments for the same event in the software product is completed. The communication protocol defined by the communication channel is not limited in any way herein.
Step 102: and calling a second execution code running in the second execution environment through the communication channel by the first execution code in the first execution environment.
Here, the first execution code and the second execution code are program codes implementing the same software product. Here, the software product may be an application program, a website system, or the like. The first execution code is executed in the first execution environment and the second execution code is executed in a second execution environment.
Taking the software product as an application program as an example, the first execution code is a native code of the application program. It will be appreciated that the native code of an application is typically used to implement the background of the application, and is server-side code, such as data analysis or data processing for background implementation. The first execution code is a code of a webpage presented by an application program, for example, a webpage written in JavaScript, and is used for displaying a foreground, such as displaying a data analysis result or a data processing result of a background.
Step 103: and running the second execution code in the first execution environment to obtain a program execution result.
In this embodiment, the first execution code may call the second execution code running in the second execution environment through the communication channel, and run the second execution code in the first execution environment to obtain a program execution result, so that execution of the same event between the first execution code and the second execution code may be implemented. For example, for a login event in an application, the first execution code may be an execution code related to analysis of verification data logged in the background, and the second execution code may be an execution code related to presentation of results based on the verification result in the foreground. For another example, for a download event in an application, the first execution code may be an execution code related to the background for performing the download data processing, and the second execution code may be an execution code related to the foreground for performing the result presentation based on the download result.
Therefore, the terminal can call the second execution code which cannot be run in the first execution environment to run in the first execution environment through one communication channel, so that two different execution codes of the same program can be mutually called and executed to obtain an execution result. Therefore, the program can be split and written, the development efficiency of the program is improved, when some parts of the program need to be modified, the whole is not required to be modified and compiled, and only the codes of the corresponding parts need to be modified and tested in the execution environment corresponding to the codes of the parts, so that the workload of developers is reduced, the development efficiency is improved, and the development cost is reduced.
In addition, the program can be split and written, so that when the software product is upgraded for part of the execution codes, the use of the whole software product is not required to be stopped, but only a new version is issued after the part of the execution codes are upgraded, and the phenomenon that the whole software product cannot be used caused by the version iteration of the software product is reduced.
As an optional embodiment, the step 102, that is, the first executing code in the first execution environment, invoking, through the communication channel, the second executing code running in the second execution environment, includes: detecting whether a call requirement for calling the second execution code exists; and when the calling requirement exists, calling the second execution code in the second execution environment through the communication channel by the first execution code in the first execution environment.
Here, the terminal automatically calls the second execution code running in the second execution environment through the communication channel by detecting whether there is a call demand for calling the second execution code.
It will be appreciated that the call requirements for invoking the second execution code may be preconfigured according to the requirements of the software product. Specifically, when an event requiring interaction between a first execution code and a second execution code in a software product occurs, that is, when the first execution code and the second execution code need to together complete the same event, a call requirement for calling the second execution code is determined. For example, a login event or a download event for which interaction is required between the first execution code and the second execution code in the software product.
In practical application, the detecting whether there is a call requirement for calling the second execution code may be that, according to a requirement of a software product, a predetermined instruction code is inserted in a predetermined execution position of the first execution code in advance, and the detecting that there is a call requirement for calling the second execution code is performed by detecting the predetermined instruction code. For example, for jave codes, the corresponding JavaScript code may be called by an instruction code such as webview.loadUrl (), while for JavaScript codes, an instruction such as javatojscallback () may be preconfigured for the java code to call, so as to implement the java call to JavaScript.
As an alternative embodiment, the detecting whether there is a call requirement for calling the second execution code includes:
When a page which is originally embedded in the first execution code and contains second execution code is started, determining that the call requirement for calling the second execution code exists;
Here, when the first executing code is started to embed the page containing the second executing code, the call requirement for calling the second executing code is determined, which is understood as that the page containing the second executing code is embedded in the first executing code in advance, and when a predetermined event occurs on the page containing the second executing code embedded in the first executing code, the page containing the second executing code is started to be originally embedded in the first executing code. At this time, the terminal determines that there is the call requirement to call the second execution code.
Specifically, the page including the second execution code may be a page corresponding to a login control displayed in a webpage presented by an application program, or a page corresponding to a download control, that is, when the page corresponding to the login control or the page corresponding to the download control detects that there is a corresponding click operation, a corresponding predetermined event is generated, and a page including the second execution code is started up, where the page including the second execution code is originally embedded.
In other embodiments, the determining that the call requirement for calling the second execution code is determined when the first execution code is started to embed the page containing the second execution code, which may be understood that the page containing the second execution code is embedded in the first execution code in advance, and when the first execution code runs to the program node embedded with the second execution code, the start of starting the first execution code is indicated. At this time, the terminal determines that there is the call requirement to call the second execution code.
Specifically, the page including the second execution code may be a page showing comments in a web page of a forum website, that is, when a comment event occurs in the background, a page embedded with the first execution code and including the second execution code is started.
As another alternative embodiment, the detecting whether there is a call requirement to call the second execution code includes:
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
Here, when the second execution code that has been invoked in the first execution environment is executed, a predetermined user operation or a predetermined trigger event is monitored, and it is determined that there is a call requirement for invoking the second execution code, it may be understood that the first execution environment is a trigger event such as when a predetermined user operation or a predetermined trigger event is monitored, for example, when a stop operation of a user is monitored, or a problem occurs in a server download resource when the second execution code is invoked in the first execution environment, for example, when a download event is being executed. At this time, the background is required to return an interactive page with failed download to the foreground, so that it can be determined that there is the call requirement to call the second execution code at this time.
As an alternative embodiment, the first execution code in the first execution environment invokes, through the communication channel, the second execution code running in the second execution environment, including:
Transmitting the encapsulation package of the second execution code to the first execution code through the communication channel, and configuring the encapsulation package at a preset position of the first execution code;
the running the second execution code in the first execution environment to obtain a program running result includes:
the first execution code comprising the encapsulation package is executed in the first execution environment to obtain a program execution result.
Here, the encapsulation package of the second execution code may include: and the interface is encapsulated by the second execution code and can be identified by the first execution environment, and the first execution code can call the second execution code through the interface so as to execute the second execution code.
In another embodiment, the encapsulation package of the second execution code may further include: the package of the function library of the second execution code can enable the first execution code to call the function library of the second execution code through the function library to replace the second execution code for execution. For example, taking a first execution code as a java code and a second execution code as a JaveScript code as an example, if the java code needs to call the JaveScript code, a function library of the JaveScript code may be configured in advance at a predetermined location, such as a header, of the java code, so that the JaveScript code may be executed by calling the function library of the JaveScript code at the same time when the java code is executed.
It should be added that, in some embodiments, when the call requirement is determined, a second execution code corresponding to the first execution code is called through a certain call instruction. For example, for jave code, the JavaScript code that needs to be invoked can be judged by shouldOverrideUrlLoading ().
In this embodiment, by configuring the package of the second execution code at the predetermined position of the first execution code, the problem that the second execution code cannot run in the first execution environment of the first execution code is solved, and the implementation is convenient and simple, and the implementation is realized without complex programming modes such as corresponding replacement of the first execution code and the second execution code by a developer.
As an alternative embodiment, the method further comprises:
Determining that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
Because the second execution code that the first execution code needs to call is pre-recorded in the whitelist, in some embodiments, the method may further include: and determining whether the first execution code has a call requirement for calling the second execution code by using the white list.
Taking java codes as an example, the terminal can call out a white list through needInjectJsBridget () instructions, judge the java codes to be loaded before the application program is loaded, and judge whether the java codes need to be called or not through the white list.
In this embodiment, through the establishment of the white list, the second execution code that needs to be called by the first execution code may be placed in the white list, and the second execution code that does not need to be called may be excluded in advance. Therefore, when the first execution code needs to be called, the second execution code which needs to be called by the first code can be quickly found out through the white list, so that the program execution efficiency is improved.
As an optional embodiment, the first execution environment is an execution environment of an application program, the first execution code is a native code of the application program, the second execution environment is an execution environment of a web page presented by the application program, and the second execution code is a code of the web page;
Or alternatively
The first execution environment is the execution environment of a webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
Here, taking an application program as an example of the software product, the software product of the application program can be split into the native code of the application program and the code of the web page of the application program, and because the code of the web page presented by the application program, such as html, javaScript, has the characteristics of short development period, on-line updating and the like, and does not need to start large engineering development like the native code of the application program.
Further, in the embodiment, the code of the webpage presented by the application program can be called through the communication channel and is operated in the execution environment of the application program; or calling the native code of the application program through the communication channel and running in the execution environment of the webpage presented by the application program to complete interaction between the native code of the application program and the code of the webpage presented by the application program. In this way, even if the application program is split into the execution codes under the two execution environments to develop the execution code, the execution of the application program is not affected. Therefore, in this embodiment, when modifying some codes of the web page related to the application program, it is not necessary to start modification of the native code of the application program, so that workload of a developer can be reduced, development efficiency is improved, and development cost is reduced.
Further, the present disclosure also provides a specific embodiment to further understand the program execution method provided by the embodiments of the present disclosure.
The execution environment of the application program is taken as a first execution environment, and the native code of the application program is taken as a first execution code; and taking the execution environment of the webpage presented by the application program as a second execution environment, and taking the code of the webpage as a second execution code.
Here, the second execution code of the web page is Js (JavaScript) code, and the native code of the application program is jave code.
FIG. 2 is another flow chart of a method of program execution, as shown in FIG. 2, according to an exemplary embodiment, the method comprising:
Step 201: js is loaded.
It will be appreciated that the Js is loaded, i.e. the web page of the application is loaded.
Step 202: whether injection is required is determined, if so, step 203 is executed, and if not, step 204 is executed.
Here, it is determined whether injection is required, that is, whether there is a call requirement for calling the second execution code is detected as described in the above embodiment.
Step 203: and (5) injection.
Here, injecting the Js may be understood as the first execution code in the first execution environment described in the above embodiment, and invoking the second execution code in the second execution environment through the communication channel.
In a specific application, the determination of whether injection is needed may be generally determined by the current execution status of the application program, for example, when the application program currently starts the page in which the first execution code is embedded and the second execution code is embedded, the injection is determined to be needed.
Step 204: and (5) ending.
In this embodiment, the Js is injected into the native code of the application program, and the native code of the application program is matched to implement interaction between the application program and the web page presented by the application program. Meanwhile, the execution code of the webpage based on the application program can be independent of the native code of the application program, and when the style and the like of the webpage of the application program are changed, the native code of the application program is not required to be modified at all, so that the efficiency of program development is improved. And based on the characteristic that the period of webpage development is short and online update can be realized, in the process of cross-platform development of the application program, the webpages of the application program are developed aiming at different platforms, so that the development workload is reduced and the development efficiency is improved.
The execution environment of the application program is taken as a second execution environment, and the native code of the application program is taken as a second execution code; and taking the execution environment of the webpage presented by the application program as a first execution environment, and taking the code of the webpage as a second execution code.
Here, the second execution code of the web page is Js code, and the native code of the application program is java code.
FIG. 3 is yet another flow chart of a method of program execution, as shown in FIG. 3, according to an exemplary embodiment, the method comprising:
step 301: a callback occurs.
It will be appreciated that after Js is injected into the native code of the application, a program execution result is obtained. Whether a response will occur to this program execution result. For example, for the program execution result of the downloading event, the callback is successful downloading or failed downloading; and aiming at the program execution result of the login event, the callback is login success or login failure.
Step 302: if the page processes the callback by itself, if not, step 303 is executed, and if yes, step 304 is executed.
Here, the page refers to whether the execution environment executed by the native code of the application program responds to the callback, if not, the callback which needs to be processed is determined, that is, the callback which needs to be returned to the webpage presented by the application program is determined.
Step 303: and processing the callback.
Here, the processing callback may be understood as the first execution code in the first execution environment when the call needs, and call the second execution code running in the second execution environment through the communication channel. I.e., code on the web page of the application, invokes the native code of the application running in the execution environment of the application through the communication channel.
Step 304: and (5) ending.
In this embodiment, the native code of the application program is tuned to the web page code of the application program through the communication channel, so as to show the return result of the native code of the application program for the related event, and achieve the interaction between the native code of the application program and the web page presented by the application program. Similarly, the execution code of the webpage based on the application program can be independent of the native code of the application program, and when the style and the like of the webpage of the application program are changed, the native code of the application program does not need to be modified at all, so that the efficiency of program development is improved. And based on the characteristic that the period of webpage development is short and online update can be realized, in the process of cross-platform development of the application program, the webpages of the application program are developed aiming at different platforms, so that the development workload is reduced and the development efficiency is improved.
Fig. 4 is a block diagram of a program execution device, according to an example embodiment. Referring to fig. 4, the apparatus includes a configuration module 41, a calling module 42 and an operation module 43;
The configuration module 41 is configured to configure a communication channel between the first execution environment and the second execution environment;
the calling module 42 is configured to call a second execution code running in the second execution environment through the communication channel by a first execution code in the first execution environment;
the execution module 43 is configured to execute the second execution code in the first execution environment to obtain a program execution result.
In an alternative embodiment, the calling module 42 further includes:
A detection sub-module configured to detect whether there is a call requirement to call the second execution code;
And the calling sub-module is configured to call the second execution code running in the second execution environment through the communication channel in the first execution environment when the calling requirement exists.
In an alternative embodiment, the detection sub-module is configured to be one of:
Determining that the call requirement for calling the second execution code exists when a page which is originally embedded in the first execution code and contains the second execution code is started;
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
In an alternative embodiment, the calling module 42 is further configured to:
Transmitting the encapsulation package of the second execution code to the first execution code through the communication channel, and configuring the encapsulation package at a preset position of the first execution code;
the operation module 43 is further configured to:
the first execution code comprising the encapsulation package is executed in the first execution environment to obtain a program execution result.
In an alternative embodiment, the apparatus further comprises:
the determining module is configured to determine that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
In an alternative embodiment, the first execution environment is an execution environment of an application program, the first execution code is a native code of the application program, the second execution environment is an execution environment of a web page presented by the application program, and the second execution code is a code of the web page;
Or alternatively
The first execution environment is the execution environment of a webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Fig. 5 is a block diagram of a terminal 500, according to an example embodiment. For example, the terminal 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, or the like.
Referring to fig. 5, a terminal 500 may include one or more of the following components: a processing component 502, a memory 504, a power component 506, a multimedia component 508, an audio component 510, an input/output (I/O) interface 512, a sensor component 514, and a communication component 516.
The processing component 502 generally controls overall operation of the terminal 500, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 502 can include one or more modules that facilitate interactions between the processing component 502 and other components. For example, the processing component 502 can include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.
The memory 504 is configured to store various types of data to support operations at the terminal 500. Examples of such data include instructions for any application or method operating on the terminal 500, contact data, phonebook data, messages, pictures, videos, and the like. The memory 504 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power component 506 provides power to the various components of the terminal 500. The power components 506 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the terminal 500.
The multimedia component 508 includes a screen between the terminal 500 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front-facing camera and/or a rear-facing camera. The front camera and/or the rear camera may receive external multimedia data when the terminal 500 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 510 is configured to output and/or input audio signals. For example, the audio component 510 includes a Microphone (MIC) configured to receive external audio signals when the terminal 500 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 516. In some embodiments, the audio component 510 further comprises a speaker for outputting audio signals.
The I/O interface 512 provides an interface between the processing component 502 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 514 includes one or more sensors for providing status assessment of various aspects of the terminal 500. For example, the sensor assembly 514 may detect the on/off state of the terminal 500, the relative positioning of the components, such as the display and keypad of the terminal 500, the sensor assembly 514 may also detect a change in position of one of the components of the terminal 500 or the terminal 5000, the presence or absence of user contact with the terminal 500, the orientation or acceleration/deceleration of the terminal 500, and a change in temperature of the terminal 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 516 is configured to facilitate communication between the terminal 500 and other devices, either wired or wireless. The terminal 500 may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In one exemplary embodiment, the communication component 516 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the terminal 500 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 504, including instructions executable by processor 520 of terminal 500 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
A non-transitory computer-readable storage medium, which when executed by a processor of a terminal, enables the terminal to perform the program execution method described in the above embodiments.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the invention is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (12)

1. A program execution method, characterized by comprising:
configuring a communication channel between a first execution environment and a second execution environment;
Transmitting the encapsulation package of the second execution code to the first execution code through the communication channel, and configuring the encapsulation package at a preset position of the first execution code;
Running the second execution code containing the package in the first execution environment to obtain a program running result; the encapsulation package includes: an interface which can be identified by a first execution environment encapsulated by the second execution code and a function library of the second execution code; a function library of a second execution code in the package can be called by the first execution code;
The first execution environment is the execution environment of an application program, the first execution code is the native code of the application program, the second execution environment is the execution environment of a webpage presented by the application program, and the second execution code is the code of the webpage; or the first execution environment is the execution environment of the webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
2. The method of claim 1, wherein the running the second execution code containing the encapsulation package in the first execution environment to obtain a program run result comprises:
Detecting whether a call requirement for calling the second execution code exists;
And when the calling requirement exists, calling the second execution code running in the second execution environment through the communication channel by the first execution code in the first execution environment.
3. The method of claim 2, wherein the detecting whether there is a call need to call the second execution code comprises one of:
Determining that the call requirement for calling the second execution code exists when a page which is originally embedded in the first execution code and contains the second execution code is started;
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
4. The method of claim 1, wherein the running the first execution code containing the encapsulation package in the first execution environment to obtain a program run result comprises:
If the package is an interface which can be identified by the first execution environment and is packaged by a second execution code, calling the second execution code in the first execution environment through the interface;
and if the package packages the package packages of the function library of the second execution code, the first execution code passes through the library function of the second execution code in the first execution environment.
5. The method according to claim 1, wherein the method further comprises:
Determining that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
6. A program execution device, comprising:
a configuration module configured to configure a communication channel between the first execution environment and the second execution environment;
a calling module configured to call a first execution code in the first execution environment, and a second execution code running in the second execution environment through the communication channel;
An execution module configured to transmit an encapsulation packet of the second execution code to the first execution code through the communication channel and configured at a predetermined location of the first execution code; running the second execution code containing the package in the first execution environment to obtain a program running result; the encapsulation package includes: an interface which can be identified by a first execution environment encapsulated by the second execution code and a function library of the second execution code; a function library of a second execution code in the package can be called by the first execution code; the first execution environment is the execution environment of an application program, the first execution code is the native code of the application program, the second execution environment is the execution environment of a webpage presented by the application program, and the second execution code is the code of the webpage; or the first execution environment is the execution environment of the webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
7. The apparatus of claim 6, wherein the calling module further comprises:
A detection sub-module configured to detect whether there is a call requirement to call the second execution code;
And the calling sub-module is configured to call the second execution code running in the second execution environment through the communication channel in the first execution environment when the calling requirement exists.
8. The apparatus of claim 7, wherein the detection sub-module is configured to be one of:
Determining that the call requirement for calling the second execution code exists when a page which is originally embedded in the first execution code and contains the second execution code is started;
And when the second execution code which is called in the first execution environment is executed, monitoring a preset user operation or a preset trigger event, and determining that the call requirement for calling the second execution code exists.
9. The apparatus of claim 6, wherein the calling module is further configured to:
If the package is an interface which can be identified by the first execution environment and is packaged by a second execution code, calling the second execution code in the first execution environment through the interface;
and if the package packages the package packages of the function library of the second execution code, the first execution code passes through the library function of the second execution code in the first execution environment.
10. The apparatus of claim 6, wherein the apparatus further comprises:
the determining module is configured to determine that the first execution code corresponds to the second execution code to be called based on a white list; the white list is recorded with the second execution code which needs to be called by the first execution code in advance.
11. A terminal, comprising:
A processor;
A memory for storing processor-executable instructions;
wherein the processor is configured to:
configuring a communication channel between a first execution environment and a second execution environment;
first execution code in the first execution environment and calling second execution code running in the second execution environment through the communication channel;
Running the second execution code containing an encapsulation package in the first execution environment to obtain a program execution result; the encapsulation package includes: an interface which can be identified by a first execution environment encapsulated by the second execution code and a function library of the second execution code; a function library of a second execution code in the package can be called by the first execution code; the first execution environment is the execution environment of an application program, the first execution code is the native code of the application program, the second execution environment is the execution environment of a webpage presented by the application program, and the second execution code is the code of the webpage; or the first execution environment is the execution environment of the webpage presented by the application program, the first execution code is the code of the webpage, the second execution environment is the execution environment of the application program, and the second execution code is the native code of the application program.
12. A non-transitory computer readable storage medium having stored thereon a computer program, characterized in that the program is executed by a processor to implement the method of any of claims 1 to 5.
CN201911243362.2A 2019-12-06 2019-12-06 Program execution method, device, terminal and storage medium Active CN111124553B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911243362.2A CN111124553B (en) 2019-12-06 2019-12-06 Program execution method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911243362.2A CN111124553B (en) 2019-12-06 2019-12-06 Program execution method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN111124553A CN111124553A (en) 2020-05-08
CN111124553B true CN111124553B (en) 2024-04-26

Family

ID=70497677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911243362.2A Active CN111124553B (en) 2019-12-06 2019-12-06 Program execution method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN111124553B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2343266A (en) * 1998-10-29 2000-05-03 Ibm Event controller object
CN106445518A (en) * 2016-09-22 2017-02-22 中国传媒大学 Method and system for developing cross-platform mobile terminal application
CN106815055A (en) * 2017-02-15 2017-06-09 深圳创维-Rgb电子有限公司 The method and system of Mobile solution Dynamic Distribution
CN109032612A (en) * 2018-07-02 2018-12-18 平安科技(深圳)有限公司 Interface calling method and device of hybrid application and computer readable storage medium
CN109976831A (en) * 2019-03-28 2019-07-05 山东浪潮通软信息科技有限公司 Data interactive method between a kind of JavaScript and primary APP

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4023803B2 (en) * 2003-05-30 2007-12-19 インターナショナル・ビジネス・マシーンズ・コーポレーション Web application development support apparatus, data processing method, and program

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2343266A (en) * 1998-10-29 2000-05-03 Ibm Event controller object
CN106445518A (en) * 2016-09-22 2017-02-22 中国传媒大学 Method and system for developing cross-platform mobile terminal application
CN106815055A (en) * 2017-02-15 2017-06-09 深圳创维-Rgb电子有限公司 The method and system of Mobile solution Dynamic Distribution
CN109032612A (en) * 2018-07-02 2018-12-18 平安科技(深圳)有限公司 Interface calling method and device of hybrid application and computer readable storage medium
CN109976831A (en) * 2019-03-28 2019-07-05 山东浪潮通软信息科技有限公司 Data interactive method between a kind of JavaScript and primary APP

Also Published As

Publication number Publication date
CN111124553A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN111026396B (en) Page rendering method and device, electronic equipment and storage medium
CN111736916B (en) Java language-based dynamic expansion method and device, electronic equipment and storage medium
CN110990105B (en) Interface display method and device, electronic equipment and storage medium
CN111273899B (en) Code processing method, device, electronic equipment and storage medium
CN111427622B (en) Execution method and device of script codes in application program
CN110781080B (en) Program debugging method and device and storage medium
CN113377370B (en) File processing method and device, electronic equipment and storage medium
CN109117144B (en) Page processing method, device, terminal and storage medium
CN107911482B (en) Target application opening method and device
CN107423218A (en) Application testing method, device and terminal
CN110795354A (en) Information processing method, device and storage medium
CN110851370B (en) Program testing method and device and storage medium
CN111596980B (en) Information processing method and device
CN111338961B (en) Application debugging method and device, electronic equipment and storage medium
CN111124553B (en) Program execution method, device, terminal and storage medium
CN114860358B (en) Object processing method and device, electronic equipment and storage medium
CN107861666B (en) Desktop application installation method and device
CN111008050A (en) Page task execution method, device, terminal and storage medium
CN112631695B (en) Data verification method and device, electronic equipment and storage medium
CN113141530B (en) Remote control interaction based method and device, electronic equipment and storage medium
CN111131000B (en) Information transmission method, device, server and terminal
CN111831292A (en) Method and device for generating installation package, storage medium and electronic equipment
CN113407879A (en) Data reporting method, device and readable medium
CN110941459A (en) Method and device for calling Replugin
CN116450534B (en) Method, device, equipment and medium for generating mobile terminal application program

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