Code sharing method and device, electronic equipment and storage medium

By packaging the public function package with the application body package, the problem of repeated writing of the same function code in different programming languages ​​is solved, and code sharing across programming languages ​​is realized, reducing development costs and improving efficiency.

CN120233987APending Publication Date: 2025-07-01BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311845749.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-28
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

In the prior art, when developing multiple applications, codes with the same functions need to be written in different programming languages ​​respectively, resulting in high development costs and low efficiency.

Method used

A code sharing method is proposed. By obtaining the main package and public function package of multiple applications, the public function package contains the shared code corresponding to the public handler and the target function, the public function package and the main package are packaged into an installation package, and the code sharing across programming languages ​​is realized.

Benefits of technology

It realizes code sharing among multiple applications, reduces development costs and improves development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120233987A_ABST
    Figure CN120233987A_ABST
Patent Text Reader

Abstract

The invention relates to a code sharing method and device, electronic equipment and a storage medium. The method can comprise the steps that main body packages of a plurality of application programs are obtained, all the main body packages are developed through different programming languages, and all the main body packages do not contain common codes corresponding to target functions needing to be supported by the application programs; a public function package is obtained, the public function package comprises a public processing program and a shared code corresponding to the target function, and the public processing program is used for executing the shared code after receiving the calling request and returning an execution result to a requester; and respectively packaging the public function package with each main body package to obtain installation packages respectively corresponding to the plurality of application programs. Through the technical scheme of the invention, code sharing among a plurality of cross-programming application programs can be realized, the development efficiency of the application programs is greatly improved, and the development cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for code sharing, an electronic device, and a storage medium. Background Art

[0002] Generally, developers develop application programs using different programming languages. And there are overlapping functions supported by multiple application programs. For example, multiple application programs can all call a microphone to implement an audio function. This means that for the code corresponding to the same function, developers need to write it in different programming languages, resulting in a high development cost of the application program and greatly reducing the development efficiency of the application program. Summary of the Invention

[0003] The present disclosure provides a method and apparatus for code sharing, an electronic device, and a storage medium to solve the deficiencies in the related technologies.

[0004] According to a first aspect of an embodiment of the present disclosure, a method for code sharing is provided. The method includes:

[0005] Obtain main packages of multiple application programs, where each main package is developed using a different programming language, and each main package does not include shared code corresponding to a target function that all of the multiple application programs need to support;

[0006] Obtain a common function package, where the common function package includes a common processing program and shared code corresponding to the target function, and the common processing program is configured to execute the shared code after receiving a call request and return an execution result to the requester;

[0007] Package the common function package with each main package respectively to obtain installation packages corresponding to the multiple application programs respectively.

[0008] Optionally, the type of the shared code includes at least one of the following: command, function, and resource. Among them, the shared code of the command type represents a call process to execute a request, the shared code of the function type represents an execution method to obtain an operation result, and the code of the resource type represents a corresponding resource.

[0009] Optionally, the shared code is encapsulated into corresponding instructions, and the instructions corresponding to any shared code include a general call method of the common processing program, the any shared code, and its call function.

[0010] Optionally, the common processing program is developed using Java or Node.JS.

[0011] According to a second aspect of an embodiment of the present disclosure, a method for code sharing is provided. The method includes:

[0012] The main package of the application initiates a call request for the common code corresponding to the target function to the common handler in the common function package of the application in response to the implementation requirement of the target function; wherein, the installation package of the application is generated by the method described in the embodiment of the first aspect.

[0013] The common handler executes the common code in response to the call request and returns the execution result to the main package.

[0014] Optionally, the main package initiating a call request for the common code corresponding to the target function to the common handler in the common function package of the application includes: the main package calls the process creation class in the programming language supported by itself to create a process, and initiates a call request for the common code corresponding to the target function to the common handler through the created process.

[0015] Optionally, when the main package is developed using Java, the main package calling the process creation class in the programming language supported by itself to create a process includes: the main package calls the ProcessBuilder class in Java to create a process; or, when the main package is developed using Node.JS, the main package calling the process creation class in the programming language supported by itself to create a process includes: the main package calls the Child Process class in Node.JS to create a process.

[0016] Optionally, the common handler returning the execution result to the main package includes: the common handler records the execution result in a log and returns the log to the main package, so that the main package can obtain the execution result from the received log.

[0017] Optionally, the main package obtaining the execution result from the received log includes: the main package calls the input / output stream in its own process creation class to read the execution result from the log.

[0018] Optionally, when the main package is developed using Java, the main package calls the input / output stream in the class for creating its own process to read the execution result from the log, including: the main package calls the inputStream of the ProcessBuilder class in Java to read the execution result from the log; or, when the main package is developed using Node.JS, the main package calls the input / output stream in the class for creating its own process to read the execution result from the log, including: the main package calls the stdout of the Child Process class in Node.JS to read the execution result from the log.

[0019] According to a third aspect of the embodiments of the present disclosure, a code sharing device is provided, the device includes:

[0020] A first acquisition module, configured to acquire main packages of multiple application programs, each main package is developed using a different programming language, and each main package does not include the shared code corresponding to the target function that the multiple application programs all need to support;

[0021] A second acquisition module, configured to acquire a common function package, the common function package includes a common processing program and the shared code corresponding to the target function, and the common processing program is configured to execute the shared code after receiving a call request and return an execution result to the requester;

[0022] A packaging module, configured to package the common function package with each main package respectively to obtain installation packages corresponding to the multiple application programs respectively.

[0023] According to a fourth aspect of the embodiments of the present disclosure, a code sharing device is provided, the device includes:

[0024] A request sending module, configured to, in response to a requirement for implementing a target function, the main package of an application program initiate a call request for the shared code corresponding to the target function to the common processing program in the common function package of the application program; wherein, the installation package of the application program is generated by the method as described in the embodiments of the first aspect;

[0025] An execution module, configured to the common processing program execute the shared code in response to the call request and return an execution result to the main package.

[0026] According to a fifth aspect of the embodiments of the present disclosure, an electronic device is provided, including:

[0027] A processor;

[0028] A memory for storing instructions executable by the processor;

[0029] Among them, the processor is configured to implement the method described in the embodiments of the first aspect / second aspect above.

[0030] According to a sixth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in the embodiments of the first aspect / second aspect above are implemented.

[0031] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:

[0032] As can be seen from the above embodiments, in the development stage of the application program, the common code corresponding to the target function (i.e., the same function) that multiple application programs need to support and the common processing program for executing the common code are packaged into a common function package, and then the main package of the application program (developed in different programming languages respectively) and the common function package are packaged into an installation package of the application program. In this way, only the common code corresponding to the target function needs to be written in the programming language supported by the common processing program, and there is no need to write the common code according to the programming languages supported by each application program respectively, thereby realizing code sharing between multiple cross-programming application programs, greatly improving the development efficiency of the application program, and reducing the development cost.

[0033] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.

[0035] Figure 1 is a schematic flowchart of a code sharing method shown according to an embodiment of the present disclosure.

[0036] Figure 2 is a schematic diagram of a common function package shown according to an embodiment of the present disclosure.

[0037] Figure 3 is a schematic flowchart of another code sharing method shown according to an embodiment of the present disclosure.

[0038] Figure 4 is a schematic block diagram of a code sharing device shown according to an embodiment of the present disclosure.

[0039] Figure 5It is a schematic block diagram of another code sharing device shown according to an embodiment of the present disclosure.

[0040] Figure 6 It is a schematic block diagram of an electronic device shown according to an embodiment of the present disclosure. Detailed implementation manners

[0041] Next, the technical solutions in the embodiments of the present disclosure will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present disclosure.

[0042] The terms used in the embodiments of the present disclosure are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present disclosure. The singular forms "a" and "the" used in the embodiments of the present disclosure and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0043] It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the embodiments of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".

[0044] For the purpose of simplicity and easy understanding, when representing the size relationship herein, the terms "greater than" or "less than", "higher than" or "lower than" are used. However, for those skilled in the art, it can be understood that the term "greater than" also covers the meaning of "greater than or equal to", and "less than" also covers the meaning of "less than or equal to"; the term "higher than" covers the meaning of "higher than or equal to", and "lower than" also covers the meaning of "lower than or equal to".

[0045] Next, one or more embodiments of the present disclosure will be described in detail.

[0046] Figure 1 It is a schematic flowchart of a code sharing method shown according to an embodiment of the present disclosure. As Figure 1 shown, the method may include the following steps:

[0047] S101: Obtain the main packages of multiple application programs. Each main package is developed in a different programming language, and each main package does not contain the common code corresponding to the target function that all of the multiple application programs need to support.

[0048] The main packages of application programs can be developed by developers in different programming languages, including but not limited to Java, Node.JS, or Kotlin, etc. Each application program can support multiple functions, and some of the functions supported by different application programs may be the same. For example, multiple application programs can all call the microphone to support the audio function, or multiple application programs can all obtain real-time news resource data to support the news push function. This part of the same function is the target function that all of the multiple application programs need to support. The aforementioned audio function and news push function are target functions. Since the target function is the same function that multiple application programs can all implement, the code corresponding to the target function is called common code. In this embodiment, during the development stage of the application program, the main package of each application program does not contain the common code corresponding to the target function, but contains the code corresponding to other functions except the target function. That is to say, the code corresponding to the other functions can be written in the corresponding programming language to develop the main package of the application program.

[0049] S102: Obtain a public function package. The public function package includes a public handler and the common code corresponding to the target function. The public handler is used to execute the common code after receiving a call request and return the execution result to the requester.

[0050] The public handler can be developed in any programming language. Since the public handler needs to execute the common code corresponding to the target function after receiving a call request, the common code corresponding to the target function needs to be written in the programming language supported by the public handler. When the public handler receives a call request for the common code, it can execute the corresponding common code in response to the call request and return the execution result to the requester.

[0051] In one embodiment, the public handler can be developed in Java or Node.JS. Of course, the public handler can also be developed in other programming languages, and those skilled in the art can select the programming language for developing the public handler according to actual needs. The present disclosure does not limit this.

[0052] In one embodiment, the types of shared code may include at least one of the following: commands, functions, and resources. Among them, the shared code of the command type represents a request that needs to be called by a process to execute. For example, when a user initiates a request to power off, after the public handler receives the power-off request, it calls the process to execute the shared code corresponding to the power-off command to achieve power-off. The shared code of the function type represents executing a series of methods to obtain an operation result, which can be understood as the execution result obtained after executing the methods. For example, for the shared code that executes the function getDevices with the function parameter status=online, the obtained operation result is information about online devices (including information such as the attributes and quantity of online devices). The code of the resource type represents the corresponding resources, such as resources like web pages and scripts.

[0053] Figure 2 is a schematic diagram of a public function package shown in an embodiment of the present disclosure. As Figure 2 shown, the public function package includes a public handler and the shared code corresponding to the target function. The public handler is developed using Java, and the shared code of the three types of commands, functions, and resources is written in Java.

[0054] In one embodiment, the shared code can be encapsulated into corresponding instructions and exposed externally. Each instruction corresponding to the shared code includes the calling method of the public handler, the shared code, and the calling function of the shared code. For example, encapsulate the shared code of "obtaining online devices" into an instruction, and the instruction is "comtool func getDevices--status=online", where comtool represents the calling method of the public handler, func represents the calling function of the shared code, and getDevices--status=online represents the shared code. By encapsulating the shared code into corresponding instructions, when there is a functional requirement, just call the corresponding instruction, without the need to repeatedly write the calling function of the same shared code, effectively improving the reusability and maintainability of the shared code.

[0055] It should be noted that there is no sequence between the above two steps S101 and S102 in the actual implementation process of the solution of the present disclosure, as Figure 1 shown. In other words, it is possible to choose to execute S101 first and then S102; it is also possible to choose to execute S102 first and then S101; it is also possible to choose to execute S101 and S102 simultaneously.

[0056] S103: Package the public function package with each main package respectively to obtain the installation packages corresponding to the multiple application programs.

[0057] Package the common function package with the main packages of each application respectively to obtain the installation packages corresponding to multiple applications respectively. Users can download the installation packages of the applications to use the applications to implement corresponding functions.

[0058] In the above embodiments, by determining the common code corresponding to the target function that multiple applications need to support, and separately developing the determined common code and the common processing program for executing the common code into a common function package, when developing applications based on different programming languages, only the code corresponding to other functions except the target function needs to be written in the programming language supported by the application to generate the main package of the application, and then the main package and the common function package are packaged to obtain the installation package corresponding to the application, thus completing the development of the application. In the development process of the above application, there is no need to write the common code in the programming languages supported by each application respectively, thereby realizing code sharing between cross-programming applications, greatly improving the development efficiency of the application and reducing the development cost.

[0059] Figure 1 The above embodiments describe the specific implementation process of the present disclosure solution in the development scenario. When a user wants to use an application to implement corresponding functions, the installation package of the application can be downloaded to the user device. The specific process of the installed application implementing the target function through the common code is as Figure 3 shown.

[0060] Figure 3 is a flowchart of a code sharing method shown according to an embodiment of the present disclosure. As Figure 3 shown, the process may include the following steps:

[0061] S301: In response to the requirement for implementing the target function, the main package of the application sends a call request for the common code corresponding to the target function to the common processing program in the common function package of the application; wherein, the installation package of the application is generated by the method described in any of the above embodiments.

[0062] The installation package of the application is generated by the method described in any of the above embodiments, so the installation package includes the main package and the common function package of the application. During the running process of the application, if a requirement for implementing a function is received, the main package of the application will first determine whether the implementation requirement is for the target function or a non-target function. The target function is a function that multiple applications need to support. If the main package determines that the implementation requirement is for a non-target function, then the main package will execute the code corresponding to the non-target function by itself. If the main package determines that the implementation requirement is for the target function, the main package will send a call request to the common processing program in the common function package of the same application, and the call request is used to indicate the call of the common code corresponding to the target function.

[0063] In one embodiment, since the programming languages used for the main package and the common handler during development may not be the same, when the main package initiates a call request to the common handler, it needs to first call the process creation class in the programming language it supports to create a process, and then initiate a call request for the common code corresponding to the target function to the common handler through the created process.

[0064] For example, assume that the common handler is developed using Java, the main package of application a is developed using Java, and the main package of application b is developed using Node.JS. When the main package of application a receives the implementation requirement for a certain target function, the main package can call the process creation class (ProcessBuilder class) in Java to create a process, and then initiate a call request for the common code corresponding to the target function to the common handler through the created process. When the main package of application b receives the implementation requirement for a certain target function, the main package can call the process creation class (Child Process class) in Node.JS to create a process, and then initiate a call request for the common code corresponding to the target function to the common handler through the created process.

[0065] In this embodiment, the main package creates a process by calling the process creation class in the programming language it supports, and initiates a call request to the common handler through the created process, thereby ensuring that the created process is available, and further ensuring that the call request can be successfully sent to the common handler to successfully implement the call of the common code.

[0066] In one embodiment, when the main package of the application is developed using Java, it indicates that Java is the programming language supported by the main package. In this case, the main package creates a process by calling the process creation class in the programming language it supports, specifically by calling the ProcessBuilder class in Java to create a process. When the main package of the application is developed using Node.JS, it indicates that Node.JS is the programming language supported by the main package. In this case, the main package creates a process by calling the process creation class in the programming language it supports, specifically by calling the Child Process class in Node.JS to create a process.

[0067] S302: The common handler executes the common code in response to the call request and returns an execution result to the main package.

[0068] After receiving a call request, the public handler first determines the target common code that matches the call request, then executes the target common code, and returns the execution result to the main package. When the common code is encapsulated as corresponding instructions, the public handler can directly determine the instruction that matches the call request and execute the matching instruction, and at the same time, it is necessary to return the execution result of the instruction to the main package.

[0069] In one embodiment, the public handler can choose to record the execution result in a log and then return the log to the main package. The main package can obtain the execution result from the returned log. The log usually contains a timestamp, which is used to record the generation time of each log. In this embodiment, the generation time of each log corresponds to the generation time of each execution result. This method helps to track the running status of the public handler and the execution status of each instruction through the execution results recorded in the log, so as to quickly troubleshoot and handle exceptions according to the information reflected in the log when problems occur.

[0070] In one embodiment, when the main package of the application obtains the execution result from the received log, it needs to call the input / output stream in its own process creation class to read the execution result from the log. The so-called own process creation class refers to the process creation class in the programming language supported by the main package itself. By using the relevant classes in the programming language supported by the main package to read the execution result, it helps to ensure that the main package can successfully read the execution result and read the accurate execution result, avoiding the situation where the read execution result is garbled.

[0071] In one embodiment, when the main package of the application is developed in Java, it means that Java is the programming language supported by the main package. In this case, when the main package receives the log returned by the public handler, the main package can call the input (inputStream) stream of the ProcessBuilder class in Java to read the execution result from the log. When the main package of the application is developed in Node.JS, it means that Node.JS is the programming language supported by the main package. In this case, when the main package receives the log returned by the public handler, the main package can call the output (stdout) stream of the ChildProcess class in Node.JS to read the execution result from the log.

[0072] In the above embodiments, for application programs developed using different programming languages (the installation packages of these application programs contain the same common function package), when an application program receives a requirement for implementing a target function, it initiates a call request for the common code corresponding to the target function to the common handler in the common function package, so that the common handler executes the common code corresponding to the target function and obtains the corresponding execution result from the common handler. This process enables a set of common code to run in environments of multiple programming languages, effectively promoting interoperability between different programming languages.

[0073] Corresponding to the embodiments of the above-mentioned code sharing method, the present disclosure also provides embodiments of a code sharing device.

[0074] Please refer to Figure 4 , Figure 4 which is a schematic block diagram of a code sharing device provided by an exemplary embodiment. The device may include: a first acquisition module 402, a second acquisition module 404, and a packaging module 406. Among them:

[0075] The first acquisition module 402 is configured to acquire the main packages of multiple application programs. Each main package is developed using a different programming language, and each main package does not contain the common code corresponding to the target function that the multiple application programs need to support;

[0076] The second acquisition module 404 is configured to acquire a common function package. The common function package includes a common handler and the common code corresponding to the target function. The common handler is used to execute the common code after receiving a call request and return an execution result to the requester.

[0077] The packaging module 406 is configured to package the common function package with each main package respectively to obtain the installation packages corresponding to the multiple application programs.

[0078] Optionally, the type of the common code includes at least one of the following: command, function, resource. Among them, the common code of the command type represents a call process execution request, the common code of the function type represents an execution method to obtain an operation result, and the code of the resource type represents the corresponding resource.

[0079] Optionally, the common code is encapsulated into corresponding instructions. The instructions corresponding to any common code include the general call method of the common handler, the any common code and its call function.

[0080] Optionally, the common handler is developed using Java or Node.JS.

[0081] Figure 51 is a schematic block diagram of another code sharing device provided by an exemplary embodiment. The device may include: a request sending module 502 and an execution module 504. Among them:

[0082] The request sending module 502 is configured such that the main package of the application program, in response to the demand for implementing the target function, initiates a call request for the shared code corresponding to the target function to the public processing program in the public function package of the application program; wherein the installation package of the application program is generated by the code sharing method described in any of the above embodiments;

[0083] The execution module 504 is configured as the public processing program to execute the common code in response to the calling request and return the execution result to the main package.

[0084] Optionally, the request sending module 502 is specifically used for: the main package calls the process creation class in the programming language supported by itself to create a process, and initiates a call request for the common code corresponding to the target function to the public processing program through the created process.

[0085] Optionally, when the main package is developed using Java, the main package calls the process creation class in the programming language supported by itself to create a process, including: the main package calls the ProcessBuilder class in Java to create a process; or, when the main package is developed using Node.JS, the main package calls the process creation class in the programming language supported by itself to create a process, including: the main package calls the Child Process class in Node.JS to create a process.

[0086] Optionally, the execution module 504 is specifically used for: the public processing program records the execution result in a log, and returns the log to the main package, so that the main package obtains the execution result from the received log.

[0087] Optionally, the main package obtains the execution result from the received log, including: the main package calls the input / output stream in its own process creation class to read the execution result from the log.

[0088] Optionally, when the main package is developed using Java, the main package calls the input / output stream in the class created by its own process to read the execution result from the log, including: the main package calls the inputStream of the ProcessBuilder class in Java to read the execution result from the log; or, when the main package is developed using Node.JS, the main package calls the input / output stream in the class created by its own process to read the execution result from the log, including: the main package calls the stdout stream of the Child Process class in Node.JS to read the execution result from the log.

[0089] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments of the relevant methods, and will not be elaborated herein.

[0090] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions in the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place, or may be distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present disclosure. A person of ordinary skill in the art can understand and implement it without creative work.

[0091] Figure 6 is a schematic block diagram of an electronic device shown according to an embodiment of the present disclosure. For example, the electronic device 600 can be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0092] Referring to Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.

[0093] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-described methods. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0094] The memory 604 is configured to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, and the like. The memory 604 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, 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, a magnetic disk, or an optical disk.

[0095] The power component 606 provides power to various components of the electronic device 600. The power component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 600.

[0096] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. 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 the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each of the front camera and the rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0097] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 604 or transmitted via the communication component 616. In some embodiments, the audio component 610 further includes a speaker for outputting audio signals.

[0098] The I / O interface 612 provides an interface between the processing component 602 and peripheral interface modules, and the peripheral interface modules may be a keyboard, a click wheel, buttons, and the like. These buttons may include, but are not limited to: a home button, a volume button, a power button, and a lock button.

[0099] The sensor component 614 includes one or more sensors for providing status assessments of various aspects of the electronic device 600. For example, the sensor component 614 can detect the on / off state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600. The sensor component 614 can also detect a change in the position of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and a change in the temperature of the electronic device 600. The sensor component 614 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 614 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 614 can further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0100] The communication component 616 is configured to facilitate communication between the electronic device 600 and other devices in a wired or wireless manner. The electronic device 600 can access a wireless network based on communication standards, such as WiFi, 2G or 3G, 4G LTE, 6G NR, or a combination thereof. In an exemplary embodiment, the communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0101] In an exemplary embodiment, the electronic device 600 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 components for performing the method described in any of the above embodiments.

[0102] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by a processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0103] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed herein. The specification and embodiments are to be considered as exemplary only, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0104] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A code sharing method, characterized in that include: Obtaining main packages of multiple application programs, each main package is developed using a different programming language, and each main package does not contain a common code corresponding to a target function that the multiple application programs need to support; Acquire a public function package, the public function package including a public processing program and a common code corresponding to the target function, the public processing program is used to execute the common code after receiving a call request and return an execution result to the requester; The common function package is packaged with each main package respectively to obtain installation packages corresponding to the multiple application programs respectively.

2. The method according to claim 1, wherein The type of the shared code includes at least one of the following: command, function, resource, wherein the shared code of the command type represents a call process execution request, the shared code of the function type represents an execution method to obtain an operation result, and the code of the resource type represents a corresponding resource.

3. The method according to claim 1, characterized in that The shared codes are encapsulated as corresponding instructions, and the instructions corresponding to any shared code include the general calling method of the public processing program, the shared code and its calling function.

4. The method according to claim 1, characterized in that The public processing program is developed using Java or Node.JS.

5. A code sharing method, characterized in that, include: The main package of the application program, in response to the demand for implementing the target function, initiates a call request for the common code corresponding to the target function to the public processing program in the public function package of the application program; wherein the installation package of the application program is generated by the method according to any one of claims 1 to 4; The common processing program executes the common code in response to the call request and returns the execution result to the main package.

6. The method according to claim 5, characterized in that, The main package initiates a call request for the common code corresponding to the target function to the public processing program in the public function package of the application program, including: The main package calls a process creation class in a programming language supported by the main package to create a process, and initiates a call request for a common code corresponding to the target function to the public processing program through the created process.

7. The method according to claim 6, characterized in that In the case where the main package is developed in Java, the main package calls a process creation class in a programming language supported by the main package to create a process, including: the main package calls the ProcessBuilder class in Java to create a process; or In the case where the main package is developed using Node.JS, the main package calls a process creation class in a programming language supported by itself to create a process, including: the main package calls a Child Process class in Node.JS to create a process.

8. The method according to claim 5, wherein The public processing program returns the execution result to the main package, including: The public processing program records the execution result in a log, and returns the log to the main package, so that the main package obtains the execution result from the received log.

9. The method according to claim 8, wherein The main package obtains the execution result from the received log, including: The main package calls the input / output stream in its own process creation class to read the execution result from the log.

10. The method according to claim 9, wherein when the main package is developed in Java, the main package calls the input / output stream in the class created by its own process to read the execution result from the log, including: the main package calls the inputStream of the ProcessBuilder class in Java to read the execution result from the log; or when the main package is developed in Node.JS, the main package calls the input / output stream in the class created by its own process to read the execution result from the log, including: the main package calls the stdout of the ChildProcess class in Node.JS to read the execution result from the log.

11. A code sharing device, characterized in that, including: a first acquisition module, configured to acquire the main packages of multiple application programs, each main package is developed in a different programming language, and each main package does not include the common code corresponding to the target function that the multiple application programs need to support; a second acquisition module, configured to acquire a common function package, the common function package includes a common processing program and the common code corresponding to the target function, and the common processing program is configured to execute the common code after receiving a call request and return an execution result to the requester; a packaging module, configured to package the common function package with each main package respectively to obtain the installation packages corresponding to the multiple application programs respectively.

12. A code sharing device, characterized in that, including: a request sending module, configured to, in response to a requirement for implementing a target function by the main package of an application program, initiate a call request for the common code corresponding to the target function to the common processing program in the common function package of the application program; wherein, the installation package of the application program is generated by the method according to any one of claims 1-4; an execution module, configured to the common processing program execute the common code in response to the call request and return an execution result to the main package.

13. An electronic device, characterized in that, including: a processor; a memory for storing instructions executable by the processor; wherein, the processor is configured to implement the method according to any one of claims 1 to 10.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the method according to any one of claims 1 to 10.