A component calling implementation method, component calling method and electronic device
By adding interface declaration marks to the first component of distributed applications, generating agents and stubs, the problem of inefficient development in the prior art is solved, and a more efficient component calling process is achieved.
Patent Information
- Application Number
- CN202011573963.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2040-12-25
AI Technical Summary
When developing distributed applications in the prior art, the IDL file template needs to be defined in advance, resulting in low application development efficiency for component calls.
By adding interface declaration marks to the source program of the first component, a proxy and stub of the first component is generated, allowing the second component to directly call the interface of the first component, reducing dependence on the IDL file.
Improve the application development efficiency of component calls, reduce the steps for developers to manually write IDL files, and simplify the calling process between components.
Smart Images

Figure CN114691140B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of distributed application technology, and in particular to a component calling implementation method, a component calling method and an electronic device. Background Art
[0002] With the development of the Internet of Things, IoT devices are becoming more and more diverse. The functions realized based on the collaboration between multiple IoT devices are becoming more and more abundant. For example, a device casts a video played on the device to another device for playback. Distributed applications based on the collaboration between multiple devices require that different components of the application be distributed on multiple devices. In this case, a component on one device needs to call a component on another device to realize the function to be realized by the application.
[0003] Usually, a component on one device needs to call a component on another device through some interfaces. In order to define these interfaces, developers pre-write IDL (Interactive Data Language) files during the development phase; then, the IDL files are compiled by the IDL compiler to generate corresponding C++ / Java interfaces. This interface can enable a component on one device to call a component on another device. However, this development method requires pre-defining an IDL file template, and developers write IDL files based on the IDL file template, resulting in low development efficiency for applications with component calls. Summary of the invention
[0004] The embodiments of the present application provide a component calling implementation method, a component calling method and an electronic device to improve the development efficiency of applications involving component calling.
[0005] In order to achieve the above purpose, this application adopts the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a method for implementing component calling, including:
[0007] Acquire a source program of the first component, the source program including an interface declaration tag, the interface declaration tag is used to declare that a marked interface function is allowed to be called by the second component, and the marked interface function is an interface function marked by the interface declaration tag in the source program of the first component;
[0008] The source program of the first component is compiled to generate a proxy and a stub of the marker interface function of the first component, and the proxy and the stub of the marker interface function of the first component are used to implement the call of the second component to the first component.
[0009] In an embodiment of the present application, a proxy and a stub of the first component are generated through a source program including an interface declaration mark of the first component. The second component can call the first component through the proxy and the stub of the first component. In the development process of components with calling relationships, developers do not need to explicitly write IDL files. Instead, by adding an interface declaration mark to the source program of the first component, the source program including the interface declaration mark of the first component can generate the proxy and the stub of the first component after compilation, thereby improving the development efficiency of applications with component calls.
[0010] In a possible implementation manner of the first aspect, compiling a source program of the first component to generate a proxy and a stub of a marker interface function of the first component includes:
[0011] Compiling the source program of the first component to generate an IDL file of the tag interface function of the first component;
[0012] The IDL file of the marker interface function of the first component is compiled to generate a proxy and a stub of the marker interface function of the first component.
[0013] In a possible implementation manner of the first aspect, compiling a source program of the first component to generate a proxy and a stub of a marker interface function of the first component further includes:
[0014] Check the legality of the parameters of the marker interface function of the first component;
[0015] When the parameters of the marker interface function of the first component are legal, compile the source program of the first component to generate a proxy and a stub of the marker interface function of the first component.
[0016] In a possible implementation manner of the first aspect, checking the legality of parameters of the marking interface function of the first component includes:
[0017] Generate an abstract syntax tree of the first component according to the source program of the first component;
[0018] Perform parameter check of the marked interface function based on the abstract syntax tree to obtain a check result, wherein the check result includes the type of the parameter return value of the marked interface function;
[0019] When the type of the parameter return value meets the preset condition, the parameter of the marking interface function of the first component is legal;
[0020] When the type of the parameter return value does not satisfy the preset condition, the parameter of the marking interface function of the first component is illegal.
[0021] In a possible implementation manner of the first aspect, the type of the parameter return value satisfies a preset condition including:
[0022] The type of the parameter return value is a basic type, or the type of the parameter return value inherits the type of the serial parent class.
[0023] In a possible implementation manner of the first aspect, after obtaining the source program of the first component, the method further includes:
[0024] Compile the source program of the first component and generate metadata of the marking interface function of the first component. The metadata is used to register with the global connection function table. The global connection function table is used for the second component to find the interface of the first component and for the second component to call the agent of the first component through the found interface.
[0025] In a possible implementation of the first aspect, the metadata of the marking interface function of the first component includes: the component name of the first component, the interface name of the marking interface function, the number of parameters of the marking interface function, the parameter type of the marking interface function, and the parameter return value of the marking interface function.
[0026] In a possible implementation manner of the first aspect, after generating metadata of the marking interface function of the first component, the method further includes:
[0027] When the first component is installed on the device, metadata of the marker interface function of the first component is registered to the global connection function table.
[0028] In a possible implementation manner of the first aspect, the method further includes:
[0029] After the second component is installed on the device, the second component applies to the component operation management service for the calling authority to the first component, and the component operation management service is used to manage the calling relationship between components;
[0030] When the signatures of the first component and the second component are the same, the component operation management service records the calling relationship between the second component and the first component, and the calling relationship between the second component and the first component includes: the second component has the authority to call the first component.
[0031] In a possible implementation manner of the first aspect, the interface declaration tag includes a first category tag and a second category tag;
[0032] The first type of tag is used to declare that the tag interface function is allowed to be called by the second component on other devices;
[0033] The second type of tag is used to declare that the tag interface function is allowed to be called by the second component on the device.
[0034] In a second aspect, an embodiment of the present application provides a component calling method, including:
[0035] The second component searches for the interface function of the first component to be called;
[0036] The second component sends a call request to the proxy of the interface function of the first component through the found interface function of the first component, wherein the second component and the proxy of the interface function of the first component are located in the same device;
[0037] The proxy of the interface function of the first component sends first information to the stub of the interface function of the first component based on a call request, wherein the first information is used to instruct the stub of the interface function of the first component to send second information to the first component, and the second information is used to instruct the first component to perform an operation represented by the second information, and the stub of the interface function of the first component and the first component are located in the same device.
[0038] In the embodiment of the present application, the first component and the second component can be developed based on the development method provided in the first aspect of the embodiment of the present application to obtain the proxy and stub of the first component. The second component can call the first component through the proxy and stub of the first component.
[0039] In a possible implementation of the second aspect, the interface function of the first component includes a function marked by an interface declaration tag in the source program of the first component, and the interface declaration tag is used to declare that the function marked by the interface declaration tag is allowed to be called by the second component.
[0040] In a possible implementation manner of the second aspect, the proxy and the stub of the interface function of the first component are obtained by compiling a source program of the first component, and the source program of the first component includes an interface declaration tag.
[0041] In a possible implementation manner of the second aspect, the second component searching for an interface function of the first component to be called includes:
[0042] The second component searches for the interface function of the first component that has a calling relationship with the second component through the component operation management service, wherein the component operation management service records the calling relationship between the second component and the first component and has the ability to query the interface function of the first component.
[0043] In a possible implementation manner of the second aspect, the second component searching, through the component operation management service, for an interface function of the first component that has a calling relationship with the second component includes:
[0044] The second component sends a query instruction to the component operation management service, and the query instruction is used to instruct the component operation management service to search the interface function of the first component that has a calling relationship with the second component from the global connection function table. The global connection function table stores information on the interface function of the first component.
[0045] In a possible implementation manner of the second aspect, when the second component searches, through the component operation management service, for an interface function of the first component that has a calling relationship with the second component, the method further includes:
[0046] The second component determines whether the first component has been installed and started through the component operation management service;
[0047] When the first component is not installed, downloading the first component through the component operation management service and starting the first component;
[0048] When the first component is installed but not started, the first component is started through the component operation management service.
[0049] In a possible implementation manner of the second aspect, the method further includes:
[0050] After the second component completes the call to the first component, the second component closes or uninstalls the first component through the component operation management service.
[0051] In a possible implementation manner of the second aspect, when the first component and the second component are located in different devices, the component operation management service has a function of managing components across devices.
[0052] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0053] A calling function search module is used to search the interface function of the first component to be called through the second component;
[0054] A call request sending module, used to control the second component to send a call request to the proxy of the interface function of the first component through the found interface function of the first component, wherein the proxy of the interface function of the second component and the first component are located in the same device;
[0055] A processing module is used to control the agent of the interface function of the first component to send first information to the stub of the interface function of the first component based on a call request, wherein the first information is used to instruct the stub of the interface function of the first component to send second information to the first component, and the second information is used to instruct the first component to perform an operation represented by the second information, and the stub of the interface function of the first component and the first component are located in the same device.
[0056] In a fourth aspect, an electronic device is provided, comprising a processor, wherein the processor is used to run a computer program stored in a memory to implement any method of the second aspect of the present application.
[0057] In a fifth aspect, a chip system is provided, including a processor, wherein the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement any method of the second aspect of the present application.
[0058] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the method of any one of the second aspects of the present application is implemented.
[0059] In a seventh aspect, an embodiment of the present application provides a computer program product, which, when executed on a device, enables the device to execute any one of the methods in the second aspect.
[0060] It can be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 An implementation method of component calling provided in an embodiment of the present application and an application scenario diagram of the component calling method;
[0062] Figure 2 A schematic diagram of the hardware structure of an electronic device for executing a component calling method provided in an embodiment of the present application;
[0063] Figure 3 A schematic diagram of the technical architecture of the component calling implementation method and the component calling method provided in the embodiment of the present application;
[0064] Figure 4 A schematic diagram of a component intermodulation implementation solution provided in an embodiment of the present application;
[0065] Figure 5 A schematic diagram of a process for implementing a component call provided in an embodiment of the present application;
[0066] Figure 6 A schematic diagram of a method for legality checking provided in an embodiment of the present application;
[0067] Figure 7 A timing diagram of a component calling method provided in an embodiment of the present application;
[0068] Figure 8 A schematic block diagram of a functional architecture module of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0069] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details.
[0070] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0071] It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more than two; "and / or" describes the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0072] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0073] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0074] The embodiment of the present application provides a component call implementation method and a component call method implemented based on the component call implementation method. The component call implementation method and the component call method can be applied in Figure 1 In the application scenario shown, Figure 1 As shown, device A is a television (TV), and device B is a mobile phone. Since the computing power of the processor in the TV is relatively weak, some processing processes with large computational load can be run on the processor of the mobile phone.
[0075] As an example, developers need to develop a set of image processing functions implemented on TV. However, due to the limited computing power of the TV's processor, it is not enough to support the image processing function. In this case, the developer can develop a set of applications (Application, APP), which includes a first component and a second component. Among them, the first component can realize the image processing function, the first component is a component developed for the mobile phone, the first component is installed and runs on the mobile phone; the second component is a component developed for the TV, and the second component runs on the TV. The second component on the TV can call the image processing function of the first component on the mobile phone. After the second component on the mobile phone completes the image processing, it can return the image processing result to the TV, so that the mobile phone assists the TV in realizing the image processing function.
[0076] It should be noted that the above application scenarios are only used as examples. In actual applications, there may be other application scenarios. In these other application scenarios, a component on one device needs to call another component on another device; or a component on one device calls another component on the device. The embodiments of the present application will no longer give examples of these other application scenarios one by one.
[0077] The first component and the second component developed by the implementation method of the component call provided by the embodiment of the present application can be installed and run in the TV and mobile phone in the above-mentioned application scenario, and can also be installed and run in other electronic devices. Correspondingly, the component call method provided by the embodiment of the present application can be applied to the TV and mobile phone in the above-mentioned application scenario, and can also be applied to other electronic devices. As an example, the electronic device that installs and runs the first component and / or the second component to implement the component call method provided by the embodiment of the present application can be: a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, a smart speaker, a TV, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA) and other electronic devices. The embodiment of the present application does not limit the specific type of electronic device.
[0078] Figure 2The schematic diagram of the structure of an electronic device is shown. The electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc. The sensor module 280 may include a gyroscope sensor 280B, an acceleration sensor 280E, a proximity light sensor 280G, a fingerprint sensor 280H, a touch sensor 280K, an ambient light sensor 280L, etc.
[0079] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0080] The processor 210 may include one or more processing units, for example: the processor 210 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. For example, the processor 210 is used to execute the component calling method in the embodiment of the present application.
[0081] The controller may be the nerve center and command center of the electronic device 200. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0082] The processor 210 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory may store instructions or data that the processor 210 has just used or cyclically used. If the processor 210 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0083] The charging management module 240 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 240 may receive charging input from a wired charger through the USB interface 230. In some wireless charging embodiments, the charging management module 240 may receive wireless charging input through a wireless charging coil of the electronic device 200. While the charging management module 240 is charging the battery 242, it may also power the electronic device through the power management module 241.
[0084] The power management module 241 is used to connect the battery 242, the charging management module 240 and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240, and supplies power to the processor 210, the internal memory 221, the external memory, the display screen 294, the camera 293, and the wireless communication module 260. The power management module 241 can also be used to monitor parameters such as battery capacity, battery cycle number, and battery health status (leakage, impedance).
[0085] In some other embodiments, the power management module 241 may also be disposed in the processor 210. In some other embodiments, the power management module 241 and the charging management module 240 may also be disposed in the same device.
[0086] The wireless communication function of the electronic device 200 can be implemented through the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, the modem processor and the baseband processor.
[0087] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 200 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0088] The mobile communication module 250 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 200. The mobile communication module 250 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.
[0089] The wireless communication module 260 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 200. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 210. The wireless communication module 260 can also receive the signal to be sent from the processor 210, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0090] In some embodiments, the antenna 1 of the electronic device 200 is coupled to the mobile communication module 250, and the antenna 2 is coupled to the wireless communication module 260, so that the electronic device 200 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).
[0091] The electronic device 200 implements the display function through a GPU, a display screen 294, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs, which execute program instructions to generate or change display information.
[0092] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 200 may include 1 or N display screens 294, where N is a positive integer greater than 1.
[0093] The electronic device 200 can realize the shooting function through ISP, camera 293, video codec, GPU, display screen 294 and application processor.
[0094] The ISP is used to process the data fed back by the camera 293. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 293.
[0095] The camera 293 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 200 may include 1 or N cameras 293, where N is a positive integer greater than 1.
[0096] The external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200. The external memory card communicates with the processor 210 via the external memory interface 220 to implement a data storage function.
[0097] The internal memory 221 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 210 executes various functional applications and data processing of the electronic device 200 by running the instructions stored in the internal memory 221. The internal memory 221 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system and an application required for at least one function. The data storage area may store data created during the use of the electronic device 200.
[0098] In addition, the internal memory 221 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0099] The electronic device 200 can implement audio functions through the audio module 270, the speaker 270A, the receiver 270B, the microphone 270C, the headphone interface 270D, and the application processor.
[0100] The audio module 270 is used to convert digital audio signals into analog audio signals for output, and is also used to convert analog audio inputs into digital audio signals. The audio module 270 can also be used to encode and decode audio signals. In some embodiments, the audio module 270 can be arranged in the processor 210, or some functional modules of the audio module 270 can be arranged in the processor 210.
[0101] The speaker 270A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 200 can listen to music or listen to a hands-free call through the speaker 270A.
[0102] The receiver 270B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 200 receives a call or voice message, the voice can be received by placing the receiver 270B close to the human ear.
[0103] Microphone 270C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 270C to input the sound signal into the microphone 270C. The electronic device 200 can be provided with at least one microphone 270C. In other embodiments, the electronic device 200 can be provided with two microphones 270C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 200 can also be provided with three, four or more microphones 270C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0104] The earphone interface 270D is used to connect a wired earphone and can be a USB interface 230 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0105] The gyro sensor 280B can be used to determine the motion posture of the electronic device 200. In some embodiments, the angular velocity of the electronic device 200 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 280B. The gyro sensor 280B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 280B detects the angle of the electronic device 200 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 200 through reverse movement to achieve anti-shake. The gyro sensor 280B can also be used for navigation and somatosensory game scenes.
[0106] The acceleration sensor 280E can detect the magnitude of the acceleration of the electronic device 200 in all directions (generally three axes). When the electronic device 200 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0107] The proximity light sensor 280G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 200 emits infrared light outward through the light emitting diode. The electronic device 200 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 200. When insufficient reflected light is detected, the electronic device 200 can determine that there is no object near the electronic device 200. The electronic device 200 can use the proximity light sensor 280G to detect that the user holds the electronic device 200 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 280G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.
[0108] The ambient light sensor 280L is used to sense the ambient light brightness. The electronic device 200 can adaptively adjust the brightness of the display screen 294 according to the perceived ambient light brightness. The ambient light sensor 280L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 280L can also cooperate with the proximity light sensor 280G to detect whether the electronic device 200 is in a pocket to prevent accidental touch.
[0109] The fingerprint sensor 280H is used to collect fingerprints. The electronic device 200 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc.
[0110] The touch sensor 280K is also called a "touch panel". The touch sensor 280K can be set on the display screen 294. The touch sensor 280K and the display screen 294 form a touch screen, also called a "touch screen". The touch sensor 280K is used to detect a touch operation acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 294.
[0111] The key 290 includes a power key, a volume key, etc. The key 290 can be a mechanical key or a touch key. The electronic device 200 can receive key input and generate key signal input related to user settings and function control of the electronic device 200.
[0112] Motor 291 can generate vibration prompts. Motor 291 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 294, motor 291 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0113] Indicator 292 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0114] The SIM card interface 295 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 200 by inserting it into the SIM card interface 295 or pulling it out from the SIM card interface 295. The electronic device 200 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 295 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 295 can also be compatible with different types of SIM cards. The SIM card interface 295 can also be compatible with external memory cards. The electronic device 200 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 200 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 200 and cannot be separated from the electronic device 200.
[0115] The embodiment of the present application does not specifically limit the specific structure of the installation body of the first component and the second component developed by the implementation method of the component call provided by the embodiment of the present application, that is, the embodiment of the present application does not specifically limit the specific structure of the execution body of the component call method provided by the embodiment of the present application. In practical applications, the execution body can also be a processor, a chip, etc.
[0116] The embodiment of the present application provides a technical architecture that can support a component on a device to call a component on the device or another device. Figure 3 The figure shows a technical architecture diagram provided in an embodiment of the present application.
[0117] Taking the two components in two devices that can call each other as an example, the technical structure diagram provided by the embodiment of the present application is described. The first component is installed in the application software of the first device, and the second component is installed in the application software of the second device. The first component can call the second component through the interface of the second component, and the second component can also call the first component through the interface of the first component.
[0118] Figure 3 The first component and the second component in are both model (Model) / view (View) structures.
[0119] The model / view structure includes Model, which is a data object related to business logic and is the model corresponding to the database.
[0120] The model / view structure also includes View, which is the user interface displayed to the user.
[0121] For a component, you can read data from the database and display the read data in the user interface. Of course, you can also receive data based on the user interface and store the received data in the database. However, how to store data from the View to the model, or how to display the data in the model to the View, needs to be implemented through the ViewModel.
[0122] The ViewModel in the model / view structure is the model corresponding to the View. Usually, the database model does not correspond one-to-one to the controls in the user interface. The ViewModel can encapsulate the Model object into a data object that can display and receive data. As long as the data in this data object is modified, the content displayed by the View will be updated accordingly. The relevant operations in the View will cause the data in the data object to be updated accordingly. After the data object is updated, the updated data will also be updated in the Model.
[0123] In practical applications, other components may also be used. The other structure may be a structure without View and ViewModel. The embodiment of the present application does not limit the specific structure of the first component and the second component.
[0124] From the structure of components, we can understand that components are simple encapsulation of data and methods. Components can have their own properties and methods. Properties are simple accessors to data, and methods are some simple functions of components. Multiple components can form a software product. Of course, in actual applications, a component can also be used as an independent software product.
[0125] The first component in the first device and the second component in the second device communicate with each other through a component operation management service and an RPC (Remote Procedure Call) communication module located at a lower layer of the component operation management service.
[0126] The component operation management service is a distributed service that can synchronize data across devices. It also has the function of managing components across devices, for example, it has the function of installing, starting, shutting down, and downloading components across devices. It can also manage the calling relationships between components that have calling relationships. It can also record the relevant information of the interface function of the called component.
[0127] Since the component operation management service belongs to a software module, in actual applications, the component operation management service can be divided into multiple sub-modules based on the functions it has, wherein each sub-module has one or more functions.
[0128] As an example, components running management services include:
[0129] The component association management module records the calling relationships between components, making it easier to manage and check the permissions of components with calling relationships.
[0130] The lifecycle management module can manage the installation, startup, shutdown and uninstallation of called components.
[0131] In addition, a global connection function table may be set, from which the component operation management service or a subcomponent in the component operation management service may query relevant information of the interface function of the called component.
[0132] Of course, in actual applications, the global connection function table can be used as part of the storage information in the component operation management service, or as storage information outside the component operation management service. Regardless of the division method, the component operation management service or the submodule in the component operation management service can find the relevant information of the interface function of the called component from the global connection function table.
[0133] It should be noted that since the component operation management service belongs to a software module, it can also be named in other ways in actual applications, and this application does not impose any restrictions on this.
[0134] The RPC communication module can realize communication between the first device where the first component is located and the second device where the second component is located based on Bluetooth, Wi-Fi, NFC, etc. In practical applications, other communication methods are also possible.
[0135] The RPC communication module converts the communication channel (for example, Figure 3 The Bluetooth, Wi-Fi and NFC) in the system are encapsulated as API interfaces commonly used in the development process. This API interface can provide scenarios such as data sending, remote function calling, and remote function notification callback.
[0136] It should be noted that the API interface provided by the RPC communication module is completely different from the interface function of the called component. The API interface provided by the RPC communication module provides a communication interface that implements communication between two devices, and the interface function of the called component provides an interface called by another component that implements communication between the two components.
[0137] After describing the technical architecture provided by the embodiment of the present application, the component interoperability implementation scheme based on the technical architecture diagram is described. Figure 4 As shown, it is a schematic diagram of the component intermodulation implementation solution provided in an embodiment of the present application.
[0138] The first device contains a first component in the application, and the second device contains a second component in the application. Figure 4 In the mark 3, the first component in the first device can be mapped to the second device, and the mapping of the first component is generated in the second device. Figure 4 In the mark 1, the second component in the second device can be mapped to the first device, and the mapping of the second component is generated in the first device. The first component and the mapping of the first component can communicate through the API interface provided by the RPC communication module, and the second component and the mapping of the second component can communicate through the API interface provided by the RPC communication module.
[0139] In practical applications, the mapping of the second component may be a mapping of an interface function for the first component to call, and the mapping of the first component may be a mapping of an interface function for the second component to call.
[0140] When a first component in a first device calls a second component in a second device, the interface provided by the mapping of the second component can be called in the first device (refer to Figure 4 As mentioned above, the mapping of the second component can communicate with the second component based on the API interface provided by the RPC communication module (refer to Figure 4 The mark 1 in the first device is used to realize the calling of the second component by the first component. The process is just like the first component in the first device calling the local component in the device.
[0141] Similarly, when the second component in the second device calls the first component in the first device, the interface provided by the mapping of the first component can be called in the second device (refer to Figure 4 As mentioned above, the mapping of the first component can communicate with the first component based on the API interface provided by the RPC communication module (refer to Figure 4 3), thereby realizing the calling of the first component by the second component. This process is just like the second component in the second device calling the local component in the present device.
[0142] like Figure 4 As shown, the implementation of the component intermodulation solution not only relies on Figure 3 The technical architecture shown in FIG. 1 also needs to enable the components in one device to be mapped to another device and generate a mapping of the components in the other device. This process can be implemented in the application development phase as follows: Figure 5 Proceed in the manner shown, Figure 5 The example of the second component calling the first component is used for explanation.
[0143] In the writing stage: Figure 5 As shown, class A is the second component written. Class B is the first component written. The second component can be called directly using a function as the caller. The first component is the called component, and the source program has an interface declaration mark, which is used to declare that a certain interface function is allowed to be called by other components. For the convenience of description, the interface function marked with the interface declaration mark is recorded as a marked interface function. The interface declaration mark can be a self-defined mark that can be recognized in the compilation stage. Of course, in practical applications, it is also possible to use an existing recognizable mark as an interface declaration mark in the embodiment of the present application.
[0144] As an example, a java / js annotation can be added to the source program of the called component, such as "@ExportDevice" in the source program of classB. This annotation is used to mark the interface function (sendMsg()) in classB to allow it to be discovered and called by other components on other devices. In actual applications, "@ExportLocal" can also be used to mark the interface function (sendMsg()) in classB to allow it to be discovered and called by other components on this device. Of course, for the sake of ease of description, the interface declaration tag used to declare that the marked interface function is allowed to be called by other components on other devices can also be recorded as a first-class tag, and the interface declaration tag used to declare that the marked interface function is allowed to be called by other components on this device can be recorded as a second-class tag.
[0145] The following are the source programs related to the calling relationship in the second component. The source program of class A in the following example is a part of the source program in class A. This part of the source program in class A indicates that class A wants to call the sendMsg() function in class B.
[0146]
[0147] The following is the source program related to the interface declaration mark and the marked interface function in the first component. The source program of class B in the following example is also a part of the source program in class B. This part of the source program in class B indicates that the sendMsg() function in class B is marked by the interface declaration mark, which can also be understood as the sendMsg() function being a marked interface function. The specific source program of the marked interface function is not shown in the embodiment of the present application.
[0148]
[0149] In the compilation stage: compile the source program of classB through the compilation tool to generate the IDL file of the label interface function of classB (refer to Figure 5 idl file of the first component in ); then generate the proxy of classB according to the IDL file of the tag interface function of classB (see Figure 5 The proxy of the first component in ) and the stub (see Figure 5 Of course, in practical applications, it is also possible to directly compile the source program of classB without going through the step of generating an IDL file, thereby generating a proxy and a stub of classB; the embodiment of the present application does not limit the method of generating the proxy and the stub of the first component.
[0150] Usually, a proxy and a stub appear in pairs. The proxy and the stub have a one-to-one corresponding interface method. The proxy interface can be provided to the client program (for example, class A) for calling. The proxy packages the call related information and passes the packaged information to the stub. In specific implementation, the proxy can be Figure 3 The RPC communication module in the technical architecture shown passes the packaged information to the stub, and the stub acts on the server program (for example, classB). The stub can control the corresponding server program. Therefore, the call of classA to classB can be realized in the above manner.
[0151] In practical applications, the proxy and stub that implement the above functions may also be named in other ways, and the embodiments of the present application do not limit this.
[0152] According to the above description, Figure 4 The mapping of the first component in may be a proxy of the first component, and more specifically a proxy of a marking interface function in the first component that is called by the second component. Figure 4 The mapping of the second component in may be a proxy of the second component, more specifically a proxy of the marking interface function in the second component that is called by the first component. Figure 4The stub of the first component is not shown, nor is the stub of the second component.
[0153] Of course, if class A calls classB, such as Figure 5 As shown, the agents of class A and classB need to be installed and run on the same device, and the stub of classB and classB need to be installed and run on the same device. If the agent of classB and the stub of classB are located on different devices, the agent of classB and the stub of classB need to communicate across devices based on the RPC communication module. If the agent of classB and the stub of classB are located on the same device, the agent of classB and the stub of classB do not need to communicate based on the RPC communication module.
[0154] In addition, before compiling the source program of the first component, it is also necessary to check the legality of the marker interface function in the first component. If it is determined that the marker interface function is legal, then generate the IDL file of classB to generate the proxy and stub of classB based on the IDL file; or, if it is determined that the marker interface function is legal, then generate the proxy and stub of classB.
[0155] As an example, when checking the legality of the marked interface function in classB, you can use the following Figure 6 The scheme shown:
[0156] First, according to the source program of the first component, an abstract syntax tree of the first component is generated;
[0157] Perform parameter check of the marked interface function based on the abstract syntax tree to obtain a check result, wherein the check result includes the type of the parameter return value of the marked interface function;
[0158] When the type of the parameter return value meets the preset condition, determining that the parameter of the marking interface function of the first component is legal;
[0159] When the type of the parameter return value does not satisfy the preset condition, it is determined that the parameter of the marking interface function of the first component is illegal.
[0160] The types of parameter return values that meet the preset conditions include:
[0161] The type of the parameter return value is a basic type, or the type of the parameter return value inherits the type of the serial parent class.
[0162] The types of parameter return values that do not meet the preset conditions include:
[0163] The type of the parameter return value is neither a basic type nor inherits the type of the serial parent class.
[0164] It should be noted that when generating the Abstract Syntax Tree (AST) of the first component, the Abstract Syntax Tree of the labeled interface function can be generated only for the source program of the labeled interface function in the first component, and then parameter checking can be performed on the obtained Abstract Syntax Tree. It is also possible to generate an Abstract Syntax Tree for the source program of the first component, and then perform parameter checking on the portion of the Abstract Syntax Tree corresponding to the labeled interface function; the embodiment of the present application does not limit the specific method of performing parameter checking.
[0165] In addition, one purpose of checking the legitimacy of the tagged interface function is to determine whether the parameters of the tagged interface function can be serialized. When serializing data, if the parent class implements serialization, the child class can also be serialized. Therefore, if the parent class can be serialized, the child class can also be serialized if it inherits the type of the serial parent class. Therefore, during the legitimacy check, if the parameter return value inherits the type of the serial parent class, it also means that the type of the high parameter return value meets the preset conditions.
[0166] When it is determined that the marked interface function is legal, the source program of classB can be used to generate the proxy and stub of classB through the compilation tool.
[0167] First, get the GetInstance sample code of classB. The GetInstance sample code means: get remoteHandler through GetInstance(), and then use remoteHandler to find the marker interface function sendMsg() of classB. The GetInstance sample code is as follows:
[0168]
[0169] Then, based on the obtained GetInstance sample code, the proxy of classB is generated. The sample code of the proxy of classB represents the process of data serialization, that is, after the proxy of classB receives the call request of classA, it needs to package the data carried in the call request and then send the packaged data to the stub of classB. The proxy of classB is as follows:
[0170]
[0171]
[0172] Generate the stub of classB based on the obtained GetInstance sample code. After receiving the packaged data sent by the proxy of classA, the stub of classB needs to deserialize. The deserialization process is the opposite of the serialization process, which is equivalent to parsing the packaged data to obtain the original data. After the stub of classB deserializes the data, it can use the Lookup() function to find the address of the marker interface function of classB itself (not the proxy of classB or the stub of classB).
[0173]
[0174] Through the above writing and compiling process, developers can obtain classA, classB, and the proxy and stub of classB.
[0175] Developers can use the proxy of classA and classB as the application of the second device, for the second device to download and install. ClassB and the stub of classB are used as the application of the first device, for the first device to download and install. In addition, the signatures of both the installation package provided for the first device and the installation package provided for the second device need to be consistent, so that only components with consistent signatures can call each other, which can avoid the problem of poor security caused by components on one device being arbitrarily called by components on other devices.
[0176] During the compilation phase, it is also necessary to compile and generate metadata for the marker interface function of classB. Metadata is used to describe information about data attributes and can be an electronic directory. For example, metadata can include the name of the component that is allowed to be called, the interface name of the marker interface function of the component that is allowed to be called, the number of parameters of the marker interface function, the parameter type of the marker interface function, and the parameter return value of the marker interface function. The metadata of the marker interface function is used to register in the global connection function table, such as Figure 3 As described in the technical architecture shown, the global connection function table is used for classA to search for the interface of classB so that classA can call the proxy of classA through the found interface.
[0177] Of course, the embodiment of the present application names the format or document storing the relevant information of the marker interface function of the called component in the form of a "table". In practical applications, other forms can also be used to store the relevant information of the marker interface function of the called component. The embodiment of the present application does not limit this.
[0178] After compilation, when classB is first installed and run on the device, the metadata of classB will be injected into the global connection function table, which is Figure 3 The technical architecture shown is a table for storing relevant information of the marker interface function of the called component.
[0179] In the specific implementation process, when classB is installed and run on the device for the first time, the metadata of classB generated by the compilation tool can be scanned, and then the metadata of classB can be registered in the global connection function table by calling publishAbility(IBinder token,Component.metadata).
[0180] Among them, Token is a string of characters generated on the server side (for example, the first device where classB is located), which can be used as a token for request by the client (for example, the second device where classA is located). When the second device accesses the first device for the first time, the first device generates a token, and the first device returns the token to the second device. In the subsequent access process, the second device can carry the token to request matters.
[0181] IBinder is an interface that defines some constants, such as the first transaction code and the last transaction code, which indicate the maximum number of transaction codes.
[0182] As mentioned above, the global connection function table stores the information of the marked interface function of classB. After classA, classB, the agent of classB and the stub of classB are installed on the corresponding devices, during the running stage of classA, if classA needs to call classB, classA needs to send a call information to the agent of classB. The call information is performed in the form of calling the marked interface function in the agent of classB. Therefore, classA needs to first search for the marked interface function of classB. The embodiment of the present application provides Lookup (component name. API name) to find the address of the marked interface function in classB.
[0183] When classA is first installed and run on a device, classA applies to the component operation management service for the calling permission of classB. As mentioned above, the component operation management service is used to manage the calling relationship between components that have a calling relationship.
[0184] When the signatures of classA and classB are the same, the component operation management service records the calling relationship between classA and classB, and the calling relationship includes: classA has the authority to call classB.
[0185] In addition, there may be some situations, for example, classA has been installed on the second device, and the developer needs to expand the function of classA, so the developer develops classB and generates the agent and stub of classB. The developer can put the agent of classB as an installation package in the application market, and put classB and the stub of classB as an installation package in the application market. When classA is updated, the agent of classB is downloaded from the application market or the user downloads the agent of classB by himself. After the agent of classB is successfully installed or when classA is run for the first time after the agent of classB is successfully installed, classA needs to apply to the component operation management service for classA's call permission to classB.
[0186] From the user's perspective, the user does not care whether the device where classA is located needs to call classB in another device. Therefore, there may also be a situation where the second device used by the user has the agents of classA and classB installed, so the second device has the function of calling classB. When the user uses a certain function in the second device, the function needs to call classB in the first device. However, classB and the stub of classB may not be installed in the first device. In this case, the second device can control the first device to install classB and the stub of classB.
[0187] In the specific implementation, before classA in the second device calls classB in the first device, classA needs to search the component operation management service for the address of the marking interface function of classB. Since the component operation management service is a distributed service, the component operation management service can determine whether classB and the stub of classB exist in the first device. If classB and the stub of classB do not exist in the first device, the component operation management service communicates with the cloud platform to control the first device to download classB and the stub of classB from the cloud platform. After the first device successfully downloads classB and the stub of classB, the component operation management service can also control the startup of classB in the first device. Of course, if classB and the stub of classB have been installed in the first device, but classB has not been started, when classA in the second device searches the component operation management service for the marking interface function of classB, the component operation management service can also start classB in the first device.
[0188] It should be noted that the present application embodiment uses the example of classA in the second device calling classB in the first device to describe the development process of developers. In actual applications, classB in the first device can also call classA in the second device. The specific development process can refer to the above description. Of course, it can also be described according to Figure 4 In the example shown, classA in the second device and classB in the first device can call each other.
[0189] It can be understood from the above description that developers do not need to explicitly write the IDL file of the called component, but add an interface declaration mark in the source program of the called component to mark the interface function allowed to be called by other components, and generate the IDL file of the interface function according to the source program of the called component. Of course, the proxy and stub of the called component can also be directly generated by the source program of the called component. In addition, developers do not need to explicitly write the data declaration (metadata of the marked interface function) of the interface of the called component, but generate it according to the source program containing the marked interface function. As the component of the caller, when it is installed and run for the first time, the component of the caller applies to the component operation management service for the calling authority of the called component, and when the signature of the caller's component and the called component are the same, the component operation management service records the calling relationship between the two. Therefore, the technical architecture and component intercommunication scheme provided by the embodiment of the present application provide developers with a simple and efficient development method of component calling, and ensure the safety of the called component.
[0190] The above describes the technical architecture provided by the embodiment of the present application and the process of developers developing a component intercommunication implementation solution based on the technical architecture. The following describes how to implement a component on one device to call a component on another device based on the component intercommunication implementation solution provided by the embodiment of the present application from the perspective of the device.
[0191] Taking the second component in the second device as an example, the timing diagram of the component calling method is described. For details, please refer to Figure 7 shown.
[0192] like Figure 7 As shown, there is a second component in the second device, which is an agent of the first component. There is also a component operation management service in the system of the second device, and the second RPC communication module in the second device provides an API interface, which is used to transmit information across devices. There are a first component and a stub of the first component in the first device. The component operation management service is not shown in the first device, and the first RPC communication module is shown.
[0193] like Figure 7 As shown, during the operation of the second component in the second device, the first component in the first device needs to be called.
[0194] The second component in the second device obtains the interface function of the first component by sending a query instruction to the component operation management service. Since the component operation management service only allows the calling component that has applied for the calling permission (as mentioned above, applying for the calling permission when it is first installed and run) to discover and call the called component, the component operation management service can return the address of the interface of the first component only when it is determined that the second component has the calling permission to the first component. As mentioned above, when the second component is first installed and run on the device, the second component can only successfully apply to the component operation management service for the permission to call the first component if the signatures of the second component and the first component are consistent. This ensures that only components with the same signature can call each other or one-way calls.
[0195] The component operation management service in the second device queries the interface of the first component from the stored global connection function table to obtain the interface address of the interface of the first component. The interface function represented by the interface address is the interface function marked by the interface declaration mark in the development stage.
[0196] The component execution management service in the second device returns the interface address of the first component to the second component.
[0197] The second component in the second device sends a call request to the agent of the first component according to the queried interface address.
[0198] After receiving the call request, the agent of the first component in the second device sends a call instruction of the API interface to the second RPC communication module.
[0199] The second RPC communication module in the second device sends the first information to the first RPC communication module of the first device based on Bluetooth, Wi-Fi, NFC, etc.
[0200] After receiving the first information, the first RPC communication module in the first device sends the first information to the stub of the first component in the first device.
[0201] The stub of the first component in the first device sends second information to the first component based on the first information.
[0202] The first component in the first device performs an operation corresponding to the second information.
[0203] The operation performed by the first component in the first device corresponding to the second information is related to the function to be implemented by the second component of the second device calling the first component in the first device.
[0204] For example, when the second device is a mobile phone and the first device is a microwave oven, the second component in the second device calls the first component in the first device to realize the function of the mobile phone controlling the microwave oven to heat for 3 minutes, and the first component in the first device performs the operation corresponding to the second information as follows: the first component in the microwave oven controls the microwave oven to heat for 3 minutes. Of course, in actual applications, the first component of the microwave oven may also send a message to other components or applications of the microwave oven to control the microwave oven to heat for 3 minutes.
[0205] As another example, Figure 1 Taking the application scenario shown as an example, the TV (second device) needs to call the mobile phone (first device) to implement the image processing function. The first information sent by the TV to the mobile phone can carry the image to be processed, and the first component in the mobile phone processes the image to be processed to obtain the processing result. The first component in the mobile phone can also send the processing result along the Figure 7 The dotted line in the figure feeds back to a second component in the TV.
[0206] In addition, Figure 7 In the interactive flow chart shown, the call request, the call instruction, the first information and the second information adopt different data naming methods. In practical applications, a certain subsequent data can be generated based on the previous data of the subsequent data, and a certain subsequent data can also be the same as the previous data of the subsequent data.
[0207] As mentioned above, the component operation management service also has a function: to manage the startup and uninstallation of the called component. That is, when the caller's component calls the interface (for example, when querying the component operation management service for the interface address of the called component), the component operation management service determines whether the called component exists in this device or another device. If it does not exist, the download of the called component is controlled. When the called component already exists but has not been started, the called component is started through the component operation management service. Of course, after completing this call, the component operation management service can decide whether to close and uninstall the called component based on the memory usage / interface usage information.
[0208] In actual applications, if classA needs to call classB multiple times during operation, after the first call, classB is neither closed nor uninstalled according to the usage of the marker interface function. After the last call, classB is closed according to the usage of the marker interface function. Of course, after the last call, if the storage space usage of the device where classB is located exceeds a certain value, classB can be uninstalled from the device. The above examples are only for examples. In actual applications, there may be other decision conditions to decide whether to keep classB running, close classB, or uninstall classB.
[0209] Finally, it should be noted that the embodiment of the present application uses the example of the first component and the second component being located in different devices to describe the cross-device call between components. In actual applications, when the first component and the second component are located in the same device, the call on the same device can also be realized. The difference is: there are differences in the interface declaration tags in the development stage; when calling across devices, the proxy and stub of the called component need to communicate based on the RPC communication module, and when calling on the same device, the proxy and stub of the called component do not need to communicate based on the RPC communication module.
[0210] It should be understood that the writing order of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0211] The embodiment of the present application can divide the functional modules of the electronic device that installs and runs the caller's components according to the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation. The following is an example of dividing each functional module corresponding to each function:
[0212] Reference Figure 8 , the electronic device 800 comprises:
[0213] A calling function search module 801 is used to search the interface function of the first component to be called through the second component;
[0214] A call request sending module 802, used to control the second component to send a call request to the proxy of the interface function of the first component through the found interface function of the first component, wherein the second component and the proxy of the interface function of the first component are located in the same device;
[0215] The first processing module 803 is used to control the agent of the interface function of the first component to send first information to the stub of the interface function of the first component based on a call request, wherein the first information is used to instruct the stub of the interface function of the first component to send second information to the first component, and the second information is used to instruct the first component to perform the operation represented by the second information, and the stub of the interface function of the first component and the first component are located in the same device.
[0216] As another embodiment of the present application, the interface function of the first component includes a function marked by an interface declaration tag in the source program of the first component, and the interface declaration tag is used to declare that the function marked by the interface declaration tag is allowed to be called by the second component.
[0217] As another embodiment of the present application, the proxy and stub of the interface function of the first component are obtained by compiling the source program of the first component, and the source program of the first component includes an interface declaration tag.
[0218] As another embodiment of the present application, the calling function search module 801 is further used for:
[0219] The second component is controlled to search the interface function of the first component which has a calling relationship with the second component through the component operation management service, wherein the component operation management service records the calling relationship between the second component and the first component and has the ability to query the interface function of the first component.
[0220] As another embodiment of the present application, the calling function search module 801 is further used for:
[0221] Control the second component to send a query instruction to the component operation management service, the query instruction is used to instruct the component operation management service to search the interface function of the first component that has a calling relationship with the second component from the global connection function table, and the global connection function table stores the information of the interface function of the first component.
[0222] As another embodiment of the present application, the calling function search module 801 is further used for:
[0223] Control the second component to determine whether the first component has been installed and started through the component operation management service;
[0224] When the first component is not installed, downloading the first component through the component operation management service and starting the first component;
[0225] When the first component is installed but not started, the first component is started through the component operation management service.
[0226] As another embodiment of the present application, the electronic device 800 further includes:
[0227] The second processing module is used to control the second component to close or uninstall the first component through the component operation management service after the second component completes the call to the first component.
[0228] As another embodiment of the present application, when the first component and the second component are located in different devices, the component operation management service has the function of managing components across devices.
[0229] It should be noted that the information interaction, execution process, etc. between the above-mentioned electronic devices / modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0230] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional modules as needed, that is, the internal structure of the electronic device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiment can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. In addition, the specific names of the functional modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the modules in the above-mentioned electronic device can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0231] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0232] The embodiment of the present application also provides a computer program product. When the computer program product is executed on a first device, the first device can implement the steps in the above-mentioned method embodiments.
[0233] If the integrated module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0234] The embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0235] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0236] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0237] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for implementing component calling, characterized in that: include: Acquire a source program of a first component, wherein the source program includes an interface declaration mark, wherein the interface declaration mark is used to declare that a marked interface function is allowed to be called by a second component, and the marked interface function is an interface function marked by the interface declaration mark in the source program of the first component; Compile the source program of the first component to generate a proxy and a stub of the marker interface function of the first component, wherein the proxy and the stub of the marker interface function of the first component are used to implement the call of the second component to the first component.
2. The implementation method according to claim 1, characterized in that: The compiling the source program of the first component to generate a proxy and a stub of the marker interface function of the first component includes: Compiling the source program of the first component to generate an IDL file of the marking interface function of the first component; Compile the IDL file of the marker interface function of the first component to generate a proxy and a stub of the marker interface function of the first component.
3. The implementation method according to claim 1, characterized in that: The compiling the source program of the first component to generate a proxy and a stub of the marker interface function of the first component also includes: Checking the legality of parameters of the marking interface function of the first component; When the parameters of the marker interface function of the first component are legal, the source program of the first component is compiled to generate a proxy and a stub of the marker interface function of the first component.
4. The implementation method according to claim 3, characterized in that: The checking of the parameter legitimacy of the marking interface function of the first component includes: generating an abstract syntax tree of the first component according to the source program of the first component; Perform parameter check of the tag interface function based on the abstract syntax tree to obtain a check result, wherein the check result includes the type of the parameter return value of the tag interface function; When the type of the parameter return value meets the preset condition, the parameter of the marking interface function of the first component is legal; When the type of the parameter return value does not satisfy a preset condition, the parameter of the marking interface function of the first component is illegal.
5. The implementation method according to claim 4, characterized in that: The type of the parameter return value that meets the preset conditions includes: The type of the parameter return value is a basic type, or the type of the parameter return value inherits the type of the serial parent class.
6. The implementation method according to any one of claims 1 to 5, characterized in that: After obtaining the source program of the first component, the method further includes: Compile the source program of the first component and generate metadata of the marking interface function of the first component, wherein the metadata is used to register with the global connection function table, and the global connection function table is used for the second component to search for the interface of the first component and for the second component to call the agent of the first component through the found interface.
7. The implementation method according to claim 6, characterized in that: The metadata of the marking interface function of the first component includes: the component name of the first component, the interface name of the marking interface function, the number of parameters of the marking interface function, the parameter type of the marking interface function, and the parameter return value of the marking interface function.
8. The implementation method according to claim 6, characterized in that: After generating metadata of the marking interface function of the first component, the method further includes: In case the first component is installed on a device, metadata of the marker interface function of the first component is registered to a global connection function table.
9. The implementation method according to any one of claims 1 to 5, characterized in that: Also includes: After the second component is installed on the device, the second component applies to the component operation management service for a calling permission to the first component, and the component operation management service is used to manage the calling relationship between components; When the signatures of the first component and the second component are the same, the component operation management service records the calling relationship between the second component and the first component, and the calling relationship between the second component and the first component includes: the second component has the authority to call the first component.
10. The implementation method according to any one of claims 1 to 5, characterized in that: The interface declaration mark includes a first type of mark and a second type of mark; The first type of mark is used to declare that the mark interface function is allowed to be called by the second component on other devices; The second type of tag is used to declare that the tag interface function is allowed to be called by the second component on the device.
11. A component calling method, characterized in that: include: The second component searches for the interface function of the first component to be called; The second component sends a call request to the proxy of the interface function of the first component through the found interface function of the first component, wherein the second component and the proxy of the interface function of the first component are located in the same device; The proxy of the interface function of the first component sends first information to the stub of the interface function of the first component based on the call request, wherein the first information is used to instruct the stub of the interface function of the first component to send second information to the first component, the second information is used to instruct the first component to perform an operation represented by the second information, and the stub of the interface function of the first component and the first component are located in the same device; The interface function of the first component includes a function marked by an interface declaration tag in the source program of the first component, and the interface declaration tag is used to declare that the function marked by the interface declaration tag is allowed to be called by the second component.
12. The component calling method according to claim 11, characterized in that: The proxy and stub of the interface function of the first component are obtained by compiling the source program of the first component, and the source program of the first component includes the interface declaration mark.
13. The component calling method according to any one of claims 11 to 12, characterized in that: The second component searches for the interface function of the first component to be called, including: The second component searches for the interface function of the first component that has a calling relationship with the second component through the component operation management service, wherein the component operation management service records the calling relationship between the second component and the first component and has the ability to query the interface function of the first component.
14. The component calling method according to claim 13, characterized in that: The second component searches for an interface function of the first component that has a calling relationship with the second component through the component operation management service, including: The second component sends a query instruction to the component operation management service, and the query instruction is used to instruct the component operation management service to search the interface function of the first component that has a calling relationship with the second component from the global connection function table, and the global connection function table stores the information of the interface function of the first component.
15. The component calling method according to claim 13, characterized in that: When the second component searches for the interface function of the first component that has a calling relationship with the second component through the component operation management service, the method further includes: The second component determines, through the component operation management service, whether the first component has been installed and started; When the first component is not installed, downloading the first component through the component operation management service and starting the first component; When the first component has been installed but not started, the first component is started through the component operation management service.
16. The component calling method according to claim 15, characterized in that: Also includes: After the second component completes the call to the first component, the second component closes or uninstalls the first component through the component operation management service.
17. The component calling method according to claim 13, characterized in that: When the first component and the second component are located in different devices, the component operation management service has the function of managing components across devices.
18. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to run a computer program stored in a memory to implement the method according to any one of claims 11 to 17.
19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a processor, the method according to any one of claims 11 to 17 is implemented.
Citation Information
Patent Citations
Method and device for creating and executing integrated executable program in different sorts of systems structure
CN1499369A
Type server caching the proxy / stub generation
US20060259540A1