WO2021051982A1 - Method for calling hardware interface and electronic device - Google Patents
Method for calling hardware interface and electronic device Download PDFInfo
- Publication number
- WO2021051982A1 WO2021051982A1 PCT/CN2020/102280 CN2020102280W WO2021051982A1 WO 2021051982 A1 WO2021051982 A1 WO 2021051982A1 CN 2020102280 W CN2020102280 W CN 2020102280W WO 2021051982 A1 WO2021051982 A1 WO 2021051982A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- hardware interface
- hardware
- electronic device
- interface
- indication information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
Definitions
- This application relates to the field of electronic devices, and more specifically, to a method for invoking a hardware interface and an electronic device.
- This application provides a method and electronic device for invoking a hardware interface, with the purpose of facilitating application developers to develop application programs.
- a method for invoking a hardware interface including: reading first indication information in a code of a first application, where the first indication information is used to indicate related information of a first hardware interface set, and
- the first hardware interface set includes hardware interfaces of multiple electronic devices, and any two hardware interfaces in the first hardware interface set are of the same type, or part of any two hardware interfaces in the first hardware interface set Or all functions are the same; determine at least one first hardware interface of the electronic device from the first hardware interface set according to the first indication information; call the at least one first hardware interface.
- the first application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on.
- the first application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the first application.
- the first set of hardware interfaces includes hardware interfaces of multiple electronic devices.
- the types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
- the types of the hardware interface may include one or more of a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
- the functions of the hardware interface may include one or more of a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a data transmission function, and a function of capturing scenes around the electronic device.
- the first application indicates the first hardware interface set through the first indication information, and the electronic device can confirm according to its own parameters (such as version number, electronic device type, etc.) what the first application should actually call Real hardware interface parameters. Therefore, the first application does not need to know in advance the actual hardware interface of the electronic device executing the first application. Moreover, when the first application indicates the first set of hardware interfaces, the first application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
- the first indication information includes information indicating a second hardware interface, and the electronic device does not have the second hardware interface, and in accordance with the Before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: according to the first instruction information, assigning the second hardware interface to The set of hardware interfaces is determined to be the first set of hardware interfaces.
- the first indication information may indicate the hardware interface of other electronic devices. Therefore, according to the function or type of the hardware interface of the other electronic device, the electronic device executing the first application can determine that it has Hardware interfaces with the same or similar functions or types, so the first application that was originally specially applied to a specific electronic device can be applied to multiple electronic devices across devices.
- the first indication information includes information indicating the first function of the hardware interface that the first application needs to call, and in accordance with the first indication Information, before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: according to the first indication information, matching a hardware interface with the first function The set is determined as the first hardware interface set.
- the first indication information may indicate the function of the hardware interface that needs to be invoked; according to the function, the electronic device may determine the first set of hardware interfaces that matches the function.
- the application developer who develops the first application also only needs to understand the function of the hardware interface code, and does not need to develop an application program for a specific electronic device, so the burden of the application developer can be reduced.
- the first indication information includes information indicating the first type of the hardware interface that the first application needs to call, and according to the first indication information, Before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first type Is the first set of hardware interfaces.
- the first indication information may indicate the type of hardware interface that needs to be called; according to the type, the electronic device can determine the first set of hardware interfaces that matches the type.
- the application developer who develops the first application also only needs to understand the type of hardware interface code, and does not need to develop an application program for a specific electronic device, so the burden of the application developer can be reduced.
- the method further includes: reading second indication information in the code of the second application, where the second indication information is used to indicate a second set of hardware interfaces Related information; in the case that the electronic device does not have any hardware interface in the second set of hardware interfaces, call the preset target interface.
- the preset target interface can be a virtual interface or a physical interface.
- the call feedback result that the electronic device cannot call the hardware interface will not be obtained, and it will not cause the second application to fail to run (such as the second application running crash or unlimited times). Loop error).
- the method further includes: reading second indication information in the code of the second application, where the second indication information is used to indicate a second set of hardware interfaces Related information; in the case that the electronic device does not have any hardware interface in the second set of hardware interfaces, presenting alarm information.
- the presenting alarm information includes presenting alarm information that matches the type or function of the second hardware interface set.
- the electronic device can learn the type or function of the hardware interface that the first application needs to call, and the alarm information and the type or function of the hardware interface Correspondingly, it is possible to provide users who use the second application with more accurate hardware interface error reporting information.
- the determining from the first hardware interface set according to the first indication information that the electronic device has at least one first hardware interface includes: The at least one first hardware interface is determined from the first hardware interface set according to the type of the electronic device and the first indication information.
- determining the hardware interface according to the type of the electronic device can improve the efficiency of calling the hardware interface.
- the first indication information further includes information indicating the version number of the interface that the first application needs to call.
- the hardware interface is determined according to the version number of the hardware interface, which can improve the efficiency of calling the hardware interface.
- a method for invoking a hardware interface includes: reading third indication information in a code of a third application, where the third indication information is used to indicate the hardware interface that the third application needs to call. Function or type; according to the type of the electronic device and the third indication information, at least one third hardware interface of the electronic device is determined from a plurality of hardware interfaces, and the plurality of hardware interfaces includes the Have a hardware interface; call the at least one third hardware interface.
- the third application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on.
- the third application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the third application.
- the third set of hardware interfaces includes the hardware interfaces of multiple electronic devices.
- the types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
- the types of hardware interfaces may include: one or more of a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
- the functions of the hardware interface may include one or more of a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a data transmission function, and a function of capturing scenes around the electronic device.
- the third application indicates the type or function of the hardware interface that needs to be called through the third indication information, and the electronic device can confirm the third application according to its own parameters (such as version number, electronic device type, etc.) The actual hardware interface parameters that should actually be called. Therefore, the third application does not need to know the real hardware interface of the electronic device executing the third application in advance.
- the third application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
- the method further includes: reading fourth indication information in the code of the fourth application, where the fourth indication information is used to indicate a fourth hardware interface set Related information; in the case that the electronic device does not have any hardware interface in the fourth hardware interface set, call the preset target interface.
- the preset target interface can be a virtual interface or a physical interface.
- the electronic device since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the hardware interface, and it will not cause the fourth application to fail to run (such as the fourth application crashing or unlimited times. Loop error).
- the method further includes: reading fourth indication information in the code of the fourth application, where the fourth indication information is used to indicate a fourth hardware interface set Related information; in the case that the electronic device does not have any hardware interface in the fourth hardware interface set, alarm information is presented.
- the presenting alarm information includes presenting alarm information that matches the type or function of the second hardware interface set.
- the electronic device since the fourth indication information indicates the fourth hardware interface set, the electronic device can learn the type or function of the hardware interface that the fourth application needs to call, and the alarm information and the type or function of the hardware interface Correspondingly, it is possible to provide users who use the fourth application with more accurate hardware interface error reporting information.
- the method further includes: the third indication information further includes information indicating the version number of the interface that the third application needs to call.
- the hardware interface is determined according to the version number of the hardware interface, which can improve the efficiency of calling the hardware interface.
- an electronic device including: a memory, configured to store a program; a processor, configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute the following Process: Read the first indication information in the code of the first application, where the first indication information is used to indicate related information of a first hardware interface set, and the first hardware interface set includes hardware interfaces of multiple electronic devices, Any two hardware interfaces in the first hardware interface set are of the same type, or any two hardware interfaces in the first hardware interface set have part or all of the same functions; according to the first instruction information, from At least one first hardware interface of the electronic device is determined in the first hardware interface set; and the at least one first hardware interface is invoked.
- the first indication information includes information indicating a second hardware interface
- the electronic device does not have the second hardware interface
- the processor also uses Before determining at least one first hardware interface of the electronic device from the first hardware interface set according to the first instruction information, it is applied to the second hardware interface according to the first instruction information.
- the hardware interface set to which the hardware interface belongs is determined as the first hardware interface set.
- the first indication information includes information indicating the first function of the hardware interface that the first application needs to call
- the processor is further configured to According to the first instruction information, before at least one first hardware interface of the electronic device is determined from the first hardware interface set, it is applied according to the first instruction information to communicate with the first function
- the matched hardware interface set is determined as the first hardware interface set.
- the first indication information includes information indicating the first type of the hardware interface that the first application needs to call
- the processor is further configured to The first indication information is applied to the one that matches the first type according to the first indication information before determining at least one first hardware interface possessed by the electronic device from the first hardware interface set.
- the set of hardware interfaces is determined to be the first set of hardware interfaces.
- the processor is further configured to read the second indication information in the code of the second application, and the second indication information is used to indicate the second hardware Related information of the interface set; the processor is further configured to call a preset target interface when the electronic device does not have any hardware interface in the second hardware interface set.
- the processor is further configured to read the second indication information in the code of the second application, and the second indication information is used to indicate the second hardware Related information of the interface set; the processor is further configured to be applied to present alarm information when the electronic device does not have any hardware interface in the second hardware interface set.
- the processor is specifically configured to determine from the first hardware interface set according to the type of the electronic device and the first indication information At least one first hardware interface.
- the first indication information further includes information indicating the version number of the interface that the first application needs to call.
- an electronic device including: a memory, configured to store a program; a processor, configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute The following process: read the third indication information in the code of the third application, where the third indication information is used to indicate the function or type of the hardware interface that the third application needs to call; according to the type of electronic device and the first Three indication information, determining at least one third hardware interface of the electronic device from multiple hardware interfaces, the multiple hardware interfaces including hardware interfaces of the multiple electronic devices; calling the at least one third hardware interface.
- the processor is further configured to read fourth indication information in the code of the fourth application, and the fourth indication information is used to indicate the fourth hardware Related information of the interface set; the processor is further configured to call the preset target interface when the electronic device does not have any hardware interface in the fourth hardware interface set.
- the third indication information further includes information indicating the version number of the interface that the third application needs to call.
- a computer-readable medium stores program code for device execution, and the program code includes a method for executing any one of the first aspect to the second aspect. .
- a computer program product containing instructions is provided.
- the computer program product runs on a computer, the computer executes the method in any one of the foregoing first aspect to the second aspect.
- a chip in a seventh aspect, includes a processor and a data interface.
- the processor reads instructions stored in a memory through the data interface, and executes any one of the first aspect to the second aspect described above. The method in the implementation mode.
- the chip may further include a memory in which instructions are stored, and the processor is configured to execute instructions stored on the memory.
- the processor is configured to execute the method in any one of the implementation manners of the first aspect to the second aspect.
- FIG. 1 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
- Fig. 2 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
- Fig. 3 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
- Fig. 4 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
- Fig. 5 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
- Fig. 6 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
- Fig. 7 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
- Fig. 8 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
- Fig. 9 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
- FIG. 10 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
- FIG. 11 is a schematic diagram of a software structure of a hardware interface layer provided by an embodiment of the present application.
- Fig. 12 is a schematic block diagram of an electronic device provided by an embodiment of the present application.
- references described in this specification to "one embodiment” or “some embodiments”, etc. mean that one or more embodiments of the present application include a specific feature, structure, or characteristic described in conjunction with the embodiment. Therefore, the sentences “in one embodiment”, “in some embodiments”, “in some other embodiments”, “in some other embodiments”, etc. appearing in different places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless it is specifically emphasized otherwise.
- the terms “including”, “including”, “having” and their variations all mean “including but not limited to”, unless otherwise specifically emphasized.
- the electronic device may be a portable electronic device that also contains other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, and a wearable electronic device with wireless communication function (such as a smart watch) , Video player, etc.
- portable electronic devices include, but are not limited to, carrying Or portable electronic devices with other operating systems.
- the above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer (Laptop) and the like. It should also be understood that, in some other embodiments, the above-mentioned electronic device may not be a portable electronic device, but a desktop computer, a TV, or a notebook computer.
- FIG. 1 shows a schematic structural diagram of an electronic device 100.
- the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2.
- Mobile communication module 150 wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195, etc.
- SIM Subscriber identification module
- the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100.
- the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
- the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
- the processor 110 may include one or more processing units.
- the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc.
- different processing units may be independent components, or may be integrated in one or more processors.
- the electronic device 101 may also include one or more processors 110.
- the controller can generate operation control signals according to the instruction operation code and timing signals, and complete the control of fetching instructions and executing instructions.
- a memory may also be provided in the processor 110 for storing instructions and data.
- the memory in the processor 110 may be a cache memory.
- the memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. In this way, repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the electronic device 101 in processing data or executing instructions is improved.
- the processor 110 may include one or more interfaces.
- the interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, and a universal asynchronous transceiver (universal asynchronous transceiver) interface.
- asynchronous receiver/transmitter, UART) interface mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, SIM card interface, and/or USB interface, etc.
- the USB interface 130 is an interface that complies with the USB standard specification, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, and so on.
- the USB interface 130 can be used to connect a charger to charge the electronic device 101, and can also be used to transfer data between the electronic device 101 and peripheral devices.
- the USB interface 130 can also be used to connect earphones and play audio through the earphones.
- the interface connection relationship between the modules illustrated in the embodiment of the present application is merely a schematic description, and does not constitute a structural limitation of the electronic device 100.
- the electronic device 100 may also adopt different interface connection modes in the foregoing embodiments, or a combination of multiple interface connection modes.
- the charging management module 140 is used to receive charging input from the charger.
- the charger can be a wireless charger or a wired charger.
- the charging management module 140 may receive the charging input of the wired charger through the USB interface 130.
- the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While the charging management module 140 charges the battery 142, it can also supply power to the electronic device through the power management module 141.
- the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
- the power management module 141 receives input from the battery 142 and/or the charge management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160.
- the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
- the power management module 141 may also be provided in the processor 110.
- the power management module 141 and the charging management module 140 may also be provided in the same device.
- the wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor.
- the antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals.
- Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
- Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
- the antenna can be used in combination with a tuning switch.
- the mobile communication module 150 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the electronic device 100.
- the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
- the mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering, amplifying and transmitting the received electromagnetic waves to the modem processor for demodulation.
- the mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic wave radiation via the antenna 1.
- at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110.
- at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
- the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites.
- WLAN wireless local area networks
- BT wireless fidelity
- GNSS global navigation satellite system
- FM frequency modulation
- NFC near field communication technology
- infrared technology infrared, IR
- the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
- the wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110.
- the wireless communication module 160 may also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves to radiate through the antenna 2.
- the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
- the GPU is a microprocessor for image processing, connected to the display 194 and the application processor.
- the GPU is used to perform mathematical and geometric calculations for graphics rendering.
- the processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
- the display screen 194 is used to display images, videos, and the like.
- the display screen 194 includes a display panel.
- the display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
- LCD liquid crystal display
- OLED organic light-emitting diode
- active-matrix organic light-emitting diode active-matrix organic light-emitting diode
- AMOLED flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
- the electronic device 100 may include one or more display screens 194.
- the display screen 194 of the electronic device 100 may be a flexible screen.
- the flexible screen has attracted much attention due to its unique characteristics and great potential.
- flexible screens have the characteristics of strong flexibility and bendability, and can provide users with new interactive methods based on bendable characteristics, which can meet users' more needs for electronic devices.
- the foldable display screen on the electronic device can be switched between a small screen in a folded configuration and a large screen in an unfolded configuration at any time. Therefore, users use the split screen function on electronic devices equipped with foldable display screens more and more frequently.
- the electronic device 100 can realize a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
- the ISP is used to process the data fed back by the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
- ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
- the ISP may be provided in the camera 193.
- the camera 193 is used to capture still images or videos.
- the object generates an optical image through the lens and is projected to the photosensitive element.
- the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
- CMOS complementary metal-oxide-semiconductor
- the photosensitive element converts the optical signal into an electrical signal, and then transfers the electrical signal to the ISP to convert it into a digital image signal.
- ISP outputs digital image signals to DSP for processing.
- DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
- the electronic device 100 may include one or more cameras 193.
- Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
- Video codecs are used to compress or decompress digital video.
- the electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
- MPEG moving picture experts group
- MPEG2 MPEG2, MPEG3, MPEG4, and so on.
- NPU is a neural-network (NN) computing processor.
- NN neural-network
- applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, and so on.
- the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
- the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
- the internal memory 121 may be used to store one or more computer programs, and the one or more computer programs include instructions.
- the processor 110 can execute the above-mentioned instructions stored in the internal memory 121 to enable the electronic device 101 to execute the off-screen display method provided in some embodiments of the present application, as well as various applications and data processing.
- the internal memory 121 may include a storage program area and a storage data area. Among them, the storage program area can store the operating system; the storage program area can also store one or more applications (such as photo galleries, contacts, etc.) and so on.
- the data storage area can store data (such as photos, contacts, etc.) created during the use of the electronic device 101.
- the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage components, flash memory components, universal flash storage (UFS), and the like.
- the processor 110 may execute the instructions stored in the internal memory 121 and/or the instructions stored in the memory provided in the processor 110 to cause the electronic device 101 to execute the instructions provided in the embodiments of the present application.
- the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. For example, music playback, recording, etc.
- the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and an ambient light sensor 180L, bone conduction sensor 180M, etc.
- the pressure sensor 180A is used to sense a pressure signal, and can convert the pressure signal into an electrical signal.
- the pressure sensor 180A may be provided on the display screen 194.
- the capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes.
- the electronic device 100 determines the intensity of the pressure according to the change in capacitance.
- the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
- the electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
- touch operations that act on the same touch position but have different touch operation strengths may correspond to different operation instructions. For example, when a touch operation whose intensity of the touch operation is less than the first pressure threshold is applied to the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
- the gyro sensor 180B may be used to determine the movement posture of the electronic device 100.
- the angular velocity of the electronic device 100 around three axes ie, X, Y, and Z axes
- the gyro sensor 180B can be used for image stabilization.
- the gyro sensor 180B detects the shake angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to counteract the shake of the electronic device 100 through reverse movement to achieve anti-shake.
- the gyro sensor 180B can also be used for navigation and somatosensory game scenes.
- the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of electronic devices, and apply to applications such as horizontal and vertical screen switching, pedometers and so on.
- the ambient light sensor 180L is used to sense the brightness of the ambient light.
- the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived brightness of the ambient light.
- the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
- the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touch.
- the fingerprint sensor 180H is used to collect fingerprints.
- the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photographs, fingerprint answering calls, and so on.
- the temperature sensor 180J is used to detect temperature.
- the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection.
- the electronic device 100 when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature.
- the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
- Touch sensor 180K also called “touch panel”.
- the touch sensor 180K may be disposed on the display screen 194, and the touch screen is composed of the touch sensor 180K and the display screen 194, which is also called a “touch screen”.
- the touch sensor 180K is used to detect touch operations 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.
- the visual output related to the touch operation can be provided through the display screen 194.
- the touch sensor 180K may also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
- the button 190 includes a power-on button, a volume button, and so on.
- the button 190 may be a mechanical button. It can also be a touch button.
- the electronic device 100 may receive key input, and generate key signal input related to user settings and function control of the electronic device 100.
- FIG. 2 is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
- the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
- the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and the system library. As shown in Figure 2, each layer in the software architecture can call the hardware layer, and the hardware layer can include multiple pieces of hardware in Figure 1.
- the application layer can include a series of application packages. As shown in Figure 2, the application package may include applications such as music playback, video playback, reading applications, application market, gallery, calendar, call, map, and navigation.
- applications such as music playback, video playback, reading applications, application market, gallery, calendar, call, map, and navigation.
- the application framework layer provides application programming interfaces (application programming interface, API) and programming frameworks for applications at the application layer.
- the application framework layer includes some predefined functions.
- the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager.
- the window manager is used to manage window programs.
- the window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc.
- the content provider is used to store and retrieve data, and make these data accessible to applications.
- the data may include videos, images, audios, phone calls made and received, browsing history and bookmarks, phone book, etc.
- the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
- the view system can be used to build applications.
- the display interface can be composed of one or more views.
- a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures.
- the phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call status (including connecting, hanging up, etc.).
- the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
- the notification manager allows the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, and so on.
- the notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or a scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text messages are prompted in the status bar, prompt sounds, electronic devices vibrate, and indicator lights flash.
- Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
- the core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
- the application layer and the application framework layer run in a virtual machine.
- the virtual machine executes the java files of the application layer and the application framework layer as binary files.
- the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
- the system library can include multiple functional modules. For example: surface manager (surface manager), media library (media libraries), 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
- the surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
- the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
- the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
- the 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
- the 2D graphics engine is a drawing engine for 2D drawing.
- the hardware layer may include multiple hardware, such as the display screen 194, the camera 193, the audio module 170, and the sensor module in FIG. 1, where the sensor module may include, for example, the gyroscope sensor 180B, the fingerprint sensor 180H, etc. in FIG.
- the application layer, the application framework layer, the Android runtime and the system library can all call the hardware in the hardware layer by calling the hardware interface.
- the application layer calls the display screen 194 by calling the display interface.
- a hardware interface layer may also be included between the system layer and the hardware layer, and the hardware interface layer includes multiple interfaces for driving the hardware.
- the interface that drives the display screen the interface that drives the camera, the interface that drives the audio module, the interface that drives the gyroscope sensor, the interface that drives the fingerprint sensor, and so on.
- the processor or chip inside the electronic device When the processor or chip inside the electronic device reads the code of the application in the application layer, it can call the hardware interface to drive the hardware in the hardware layer and perform corresponding operations.
- the antenna used for mobile communication can be driven by calling the mobile communication interface, and the uplink and downlink communication data can be transmitted through the antenna used for mobile communication.
- the processor or chip when running the call application, it can read the code in the call application, so that the mobile communication interface can be called, and the voice call function can be realized by driving the antenna for mobile communication.
- the display screen can be driven by calling the screen display interface, and images can be displayed on the display screen.
- the processor or chip when the processor or chip is running a video playback application, it can read the code in the video playback application, so that it can call the screen display interface and play the video on the display screen.
- the speaker can be driven by calling the speaker interface, and sound can be played through the speaker; or, the earphone (connected externally) can be driven by calling the earphone interface, and the sound can be played through the earphone.
- the processor or chip when the processor or chip is running an audio playback application, it can read the code in the audio playback application, so that it can call the speaker interface and play audio files through the speaker, or it can call the headphone interface and pass the (externally connected) The headset plays audio files.
- the fingerprint identification module can be driven by calling the fingerprint identification interface, and the fingerprint can be identified by the fingerprint identification module.
- the processor or chip when the processor or chip is running a security application, it can read the code in the security application, so that the fingerprint identification interface can be called, and when the fingerprint fed back by the fingerprint identification module matches the preset fingerprint information, the current electronic device's The operation is safe.
- a global positioning system (GPS) antenna can be driven by calling a position positioning interface, and the current position of the electronic device can be determined through the GPS antenna.
- GPS global positioning system
- the processor or chip when the processor or chip is running a map navigation application, it can read the code in the map navigation application, so that the positioning interface can be called, and the driving route can be planned through the positioning information fed back by the GPS antenna.
- the Bluetooth antenna can be driven by calling the wireless communication interface, and data can be received from other electronic devices through the Bluetooth antenna, or data can be sent to other electronic devices.
- the processor or chip when the processor or chip is running a file transfer application, it can read the code in the file transfer application, so that it can call the wireless communication interface, and send a file to or receive a file from a neighboring electronic device through a Bluetooth antenna. document.
- the camera can be driven by calling the shooting interface, and an image or video can be captured by the camera.
- the processor or the chip when the processor or the chip is running the shooting application, it can read the code in the shooting application, so that the front-facing shooting interface can be called, and a portrait can be taken through the front-facing camera.
- Figure 3 shows the schematic diagram of the development software for two different types of equipment.
- the types of devices in FIG. 3 may include, for example, mobile phones, tablet computers, wearable electronic devices with wireless communication functions (such as smart watches), video player desktop computers, TVs, notebook computers, and so on.
- the first device in FIG. 3 may be a mobile phone
- the second device may be a TV.
- the hardware interface one of device one can call hardware one.
- the hardware interface two of the device two can call the hardware two.
- the hardware interface one is different from the hardware interface two, so the same program cannot be used.
- Implement the call of hardware interface one and implement the call of hardware interface two.
- both the mobile phone’s display screen and the TV’s screen can be used to play videos and display pictures.
- the mobile phone’s display screen and the TV’s screen can be produced by different screen manufacturers, so the interface of the mobile phone’s display screen is different from that of the TV screen. That is, the same program cannot be used to call the interface of the mobile phone display screen and the interface of the TV screen as well.
- the system software is usually a program installed and loaded on the electronic device by the device manufacturer before the electronic device leaves the factory. Since the hardware interface one of the device one is different from the hardware interface two of the device two, the system software of the device one is different from the system software of the device two.
- SDK software development kits
- an application developer wants to develop a set of applications, such as video playback software, map navigation software, call software, system applications, etc.
- this set of applications In order to implement the functions of this set of applications on both device one and device two (as shown in Figure 3), it is necessary to develop two different applications of the same type for device one and device two respectively.
- video playback software 1 for mobile phones
- video playback software 2 for TVs.
- the two different applications of the same type may refer to that the two applications may include application one for device one and application two for device two, and the functions of application one and application two are the same or the main functions are the same; but
- the code, interface and/or function used by application one and application two are different, so application one usually cannot be applied to device two, and application two usually cannot be applied to device First, application one and application two are two different applications.
- Fig. 4 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
- Read first indication information in a code of a first application where the first indication information is used to indicate related information of a first hardware interface set, where the first hardware interface set includes hardware interfaces of multiple electronic devices.
- the types of any two hardware interfaces in the first hardware interface set are the same, or part or all of the functions of any two hardware interfaces in the first hardware interface set are the same.
- the first application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on.
- the first application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the first application.
- the first set of hardware interfaces includes hardware interfaces of multiple electronic devices.
- the types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
- the hardware when the first application calls the hardware interface, the hardware may be driven by code. Therefore, the first set of hardware interfaces may be stored in the processor or memory in the form of code.
- the hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface.
- a hardware interface definition language HDL
- HIDL language can be used to call java format code to implement the call of the hardware interface.
- the electronic device may include a software module or a hard-wired module for identifying the type of the device.
- the electronic device can use the version number, model, etc. of the electronic device to call the hardware of the electronic device.
- the hardware interface of a mobile phone is different from that of a watch
- the hardware interface of a watch is different from that of a TV.
- the hardware interface is different from the hardware interface of the TV.
- the hardware interfaces of different electronic devices of the same type may be the same or different.
- two mobile phones with the same version number may have the same hardware interfaces
- two mobile phones with the same version number may have different hardware interfaces.
- the electronic device can identify the type of the chip, so as to call the hardware including the chip, or determine the hardware interface of the hardware including the chip. For another example, the electronic device can identify the version number or model of the hardware to determine whether to call the hardware or determine the hardware interface of the hardware.
- any two hardware interfaces in the first set of hardware interfaces are of the same type.
- all the hardware interfaces in the first hardware interface set are mobile communication interfaces.
- all hardware interfaces in the first hardware interface set are screen display interfaces.
- all the hardware interfaces in the first hardware interface set are speaker interfaces.
- all the hardware interfaces in the first hardware interface set are earphone interfaces.
- all hardware interfaces in the first hardware interface set are fingerprint identification interfaces.
- all hardware interfaces in the first hardware interface set are positioning interfaces.
- all hardware interfaces in the first hardware interface set are wireless communication interfaces.
- all hardware interfaces in the first set of hardware interfaces are shooting interfaces.
- the type of the first hardware interface set is the same as the type of any hardware interface in the first hardware interface set.
- all hardware interfaces in the first hardware interface set are mobile communication interfaces, and the type of the first hardware interface set may be mobile communication interfaces.
- Part of the functions of any two hardware interfaces in the first hardware interface set are the same.
- all hardware interfaces in the first hardware interface set can be used for voice calls, and due to different mobile communication standards, the first part of the hardware interfaces in the first hardware interface set can be used in global system for mobile communications, GSM) system
- the second part of the hardware interface in the first set of hardware interfaces can work in the global system for mobile communications (GSM) system, or in code division multiple access , CDMA) system.
- GSM global system for mobile communications
- CDMA code division multiple access
- all hardware interfaces in the first hardware interface set can be used for Bluetooth file transfer, and due to different wireless communication standards, the first part of the hardware interfaces in the first hardware interface set can be used to drive Bluetooth 2.0.
- the second part of the hardware interface set can be used to drive Bluetooth 4.0.
- all hardware interfaces in the first hardware interface set can be used to play audio, and the interfaces used to play audio include a speaker interface for driving speakers and a headphone interface for driving headphones. Therefore, the first hardware interface The first part of the hardware interface in the set can be used to drive speakers, and the second part of the hardware interface can be used to drive headphones.
- all the hardware interfaces in the first hardware interface set can be used for video input, while the high definition multimedia interface (HDMI) can be used for audio input and video input, and the video graphics array (video graphics array, The VGA) interface is only used for video input. Therefore, the first part of the hardware interface in the first hardware interface set can be the interface only for video input, and the second part of the hardware interface can be used for both audio input and video input.
- HDMI high definition multimedia interface
- VGA video graphics array
- all the hardware interfaces in the first hardware interface set can be used to capture images or videos, and the cameras are divided into front cameras and rear cameras, so the first part of the hardware interfaces in the first hardware interface set can be used for Drive the front camera, the second part of the hardware interface can be used to drive the rear camera.
- the function of the first hardware interface set includes the function of any hardware interface in the first hardware interface set.
- all hardware interfaces in the first hardware interface set can be used for voice calls, and the functions of the first hardware interface set include voice calls.
- All functions of any two hardware interfaces in the first hardware interface set are the same.
- all the hardware interfaces in the first set of hardware interfaces can be used for voice calls, and all can work in the global system for mobile communications (GSM) system, or in code division multiple access (code division multiple access).
- Division multiple access (CDMA) system works, and all functions implemented by any hardware interface in the first hardware interface set can also be implemented by other hardware interfaces in the first hardware interface set.
- GSM global system for mobile communications
- CDMA code division multiple access
- all hardware interfaces in the first hardware interface set can be used to drive Bluetooth 4.0.
- all the hardware interfaces in the first set of hardware interfaces can be used to play audio, and all of them can be used to drive headphones.
- all the hardware interfaces in the first hardware interface set can be used for video input, and all can be used for audio input.
- all the hardware interfaces in the first hardware interface set can be used to capture images or videos, and all are used to drive the front camera.
- the function of the first hardware interface set is the same as the function of any hardware interface in the first hardware interface set.
- all hardware interfaces in the first hardware interface set can be used for voice calls, and the function of the first hardware interface set is voice calls.
- any two hardware interfaces are of the same type, and the functions that can be implemented by the any two hardware interfaces are usually the same or similar.
- the first set of hardware interfaces may include multiple hardware interfaces of a certain type of electronic device.
- the electronic device includes a front camera and a rear camera
- the first set of hardware interfaces may include a hardware interface 1 for driving the front camera and a hardware interface 2 for driving the rear camera.
- the electronic device includes multiple multimedia transmission interfaces, which are respectively used to support different multimedia transmission standards (such as HDMI and VGA).
- Fig. 5 is a schematic diagram of the hardware interfaces in the first set of hardware interfaces.
- the first set of hardware interfaces includes hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4.
- the hardware interface 1 and the hardware interface 2 are hardware interfaces of the electronic device 501.
- the hardware interface 3 is a hardware interface of the electronic device 502.
- the hardware interface 3 and the hardware interface 4 are hardware interfaces of the electronic device 503.
- the hardware interfaces of different electronic devices can be the same.
- mobile phone 1 with version number 1 uses hardware 1
- mobile phone 2 with version number 2 uses hardware 2
- hardware 1 and hardware 2 are from the same hardware manufacturer
- hardware 1 and hardware 2 are the same type of hardware. Therefore, the mobile phone 1 and the mobile phone 2 may have the same hardware interface.
- the first set of hardware interfaces may include multiple hardware interfaces of the same type, and include hardware interfaces of multiple electronic devices.
- the hardware interface 1, the hardware interface 2, the hardware interface 3, and the hardware interface 4 may all be shooting interfaces.
- the electronic device 501 may be a mobile phone, the electronic device 502 may be a watch, and the electronic device 503 may be a tablet computer.
- the hardware interface 1 of the electronic device 501 may be a shooting interface for calling a front camera, and the hardware interface 2 of the electronic device 501 may be a shooting interface for calling a rear camera.
- the hardware interface 3 of the electronic device 503 may be a shooting interface for calling a front camera, and the hardware interface 4 of the electronic device 503 may be a shooting interface for calling a rear camera.
- the hardware interface 3 of the electronic device 502 is the same as the hardware interface 3 of the electronic device 503.
- the first set of hardware interfaces may include a plurality of hardware interfaces with part or all of the same functions, and include hardware interfaces of a plurality of electronic devices.
- the first indication information includes information indicating a second hardware interface, and the electronic device does not have the second hardware interface, and the first hardware interface is collected from the first hardware interface according to the first indication information.
- the method further includes: determining, according to the first indication information, the set of hardware interfaces to which the second hardware interface belongs as the first hardware interface set.
- the electronic device may store related information of the first hardware interface set, and the related information includes the identification of the first hardware interface set and the information of multiple hardware interfaces in the first hardware interface set (such as the identification of each hardware interface, the call parameter Etc.), the multiple hardware interfaces include the second hardware interface.
- the identification of the first hardware interface set shown in FIG. 5 and the identification of hardware interface 1, the identification of hardware interface 2, the identification of hardware interface 3, the identification of hardware interface 4, and the identification of the first hardware interface set can be saved, respectively.
- the electronic device 501 since the electronic device 501 does not have the hardware interface 3, the electronic device 501 cannot call the hardware Interface 3, and the electronic device 501 can determine that there is a correspondence between the hardware interface 3 and the first hardware interface set according to the first indication information and the related information of the first hardware interface set, so as to determine the first hardware interface set.
- Figure 6 shows a schematic diagram of a set of multiple hardware interfaces.
- the electronic device may store related information of multiple hardware interface sets, and the multiple hardware interface sets include the hardware interface set 601 and the hardware interface set 602 shown in FIG. 6.
- the type of the hardware interface set 601 is type 1
- the type of the hardware interface set 602 is type 2.
- the first indication information includes information indicating the first type of the hardware interface that the first application needs to call. According to the first indication information, it is determined from the first hardware interface set that the electronic device has at least Before a first hardware interface, the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first type as the first hardware interface set.
- the first hardware interface set matches the first type, and a possible situation is that the type of the first hardware interface set is the first type.
- the type of the hardware interface set has been described in detail above, and will not be repeated here.
- Another possible situation is that the function of the first hardware interface set is the same or similar to the function implemented by the first type.
- the type indicated by the first indication information is a mobile communication interface
- the function of the first hardware interface set includes a voice call function
- the mobile communication interface can also implement the voice call function, so the first hardware interface set matches the first type .
- the type indicated by the first indication information is a screen display interface
- the functions of the first set of hardware interfaces include the function of displaying images on the screen
- the screen display interface can also realize the function of displaying images on the screen.
- a set of hardware interfaces matches the first type.
- the type indicated by the first indication information is a speaker interface
- the function of the first hardware interface set includes a sound playback function
- the speaker interface can also implement the sound playback function, so the first hardware interface set matches the first type.
- the type indicated by the first indication information is a headphone interface
- the function of the first hardware interface set includes a sound playing function
- the headphone interface can also implement the sound playing function, so the first hardware interface set matches the first type.
- the type indicated by the first indication information is a fingerprint identification interface
- the function of the first hardware interface set includes a fingerprint identification function
- the fingerprint identification interface can also implement the fingerprint identification function. Therefore, the first hardware interface set and the first type match.
- the type indicated by the first indication information is a positioning interface
- the function of the first hardware interface set includes a positioning function
- the positioning interface can also implement the positioning function, so the first hardware interface set matches the first type.
- the type indicated by the first indication information is a wireless communication interface
- the function of the first hardware interface set includes a data transmission function
- the wireless communication interface can also implement the data transmission function. Therefore, the first hardware interface set and the first type match.
- the type indicated by the first indication information is a shooting interface
- the function of the first hardware interface set includes capturing the scene around the electronic device, and the shooting interface can also realize the function of capturing the scene around the electronic device. Therefore, the first hardware interface set Matches the first type.
- the electronic device may determine the first set of hardware interfaces matching the first type according to the first type.
- the function of the hardware interface set 601 includes function 1, and the function of the hardware interface set 602 includes function 2.
- the first indication information includes information indicating the first function of the hardware interface that the first application needs to call, and the first function is determined from the first hardware interface set according to the first indication information
- the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first function as the first set of hardware interfaces.
- the first hardware interface set matches the first function, and a possible situation is that the function of the first hardware interface set includes the first type.
- the functions of the various hardware interface sets have been described in detail above, and will not be repeated here.
- Another possible situation is that the function of the first hardware interface set is the same or similar to the function implemented by the first type.
- the function indicated by the first indication information is a voice call function
- the type of the first hardware interface set is a mobile communication interface
- the mobile communication interface can implement the voice call function, so the first hardware interface set matches the first type .
- the function indicated by the first indication information is the function of displaying images on the screen
- the type of the first hardware interface set is the screen display interface
- the screen display interface can realize the function of displaying images on the screen.
- a set of hardware interfaces matches the first type.
- the function indicated by the first indication information is a sound playback function
- the type of the first hardware interface set is a speaker interface or a headphone interface
- the speaker interface or the headphone interface can realize the sound playback function, so the first hardware interface set Matches the first type.
- the function indicated by the first indication information is a fingerprint recognition function
- the type of the first hardware interface set is a fingerprint recognition interface
- the fingerprint recognition interface can realize the fingerprint recognition function, so the first hardware interface set is the same as the first type match.
- the function indicated by the first indication information is a positioning function
- the type of the first hardware interface set is a positioning interface
- the positioning interface can implement the positioning function, so the first hardware interface set matches the first type.
- the function indicated by the first indication information is a data transmission function
- the type of the first hardware interface set is a wireless communication interface
- the wireless communication interface can realize the data transmission function. Therefore, the first hardware interface set is the same as the first type. match.
- the function indicated by the first indication information is the function of capturing the scene around the electronic device
- the type of the first hardware interface set is the shooting interface
- the shooting interface can realize the function of capturing the scene around the electronic device, so the first hardware The set of interfaces matches the first type.
- the electronic device may determine the first hardware interface set matching the first function according to the first function.
- the electronic device can select one or more hardware interfaces of the electronic device in the first hardware interface set, that is, the electronic device can select one or more hardware interfaces that the electronic device can call correctly.
- a hardware interface is, the electronic device can select one or more hardware interfaces that the electronic device can call correctly.
- the electronic device 501 can determine the hardware interface 1 and the hardware interface 2 from the first hardware interface set, and use both the hardware interface 1 and the hardware interface 2 as the first hardware interface.
- the electronic device can try the hardware interfaces in the first hardware interface set one by one according to the information of the hardware interfaces in the first hardware interface set, and when the call result is successful, it can determine the at least one first hardware interface. interface.
- the electronic device 501 can sequentially try from the first hardware interface set whether hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4 can be successfully called.
- Interface 3 and hardware interface 4 are not hardware interfaces of electronic device 501, and electronic device 501 cannot be called correctly, while hardware interface 1 and hardware interface 2 are hardware interfaces of electronic device 501, so electronic device 501 can correctly call hardware interface 1 , Hardware interface 2, so that both hardware interface 1 and hardware interface 2 can be determined as the first hardware interface.
- the electronic device may determine at least one first hardware interface possessed by the electronic device from the first hardware interface set according to the type of the electronic device.
- the determining at least one first hardware interface of the electronic device from the first hardware interface set according to the first indication information includes: according to the type of the electronic device and the first hardware interface Indication information, determining the at least one first hardware interface from the first hardware interface set.
- the first hardware interface set includes hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4.
- the hardware interface 1 and the hardware interface 2 are hardware interfaces of the electronic device 501.
- the hardware interface 3 is a hardware interface of the electronic device 502.
- the hardware interface 3 and the hardware interface 4 are hardware interfaces of the electronic device 503.
- the electronic device 501 may determine both the hardware interface 1 and the hardware interface 2 as the first hardware interface according to its own device type.
- the first indication information further includes information indicating the version number of the interface that the first application needs to call.
- the interface corresponding to the Bluetooth antenna of the Bluetooth 2.0 version is different from the interface corresponding to the Bluetooth antenna of the Bluetooth 4.0 version.
- the electronic device can ignore the Bluetooth 2.0 version.
- Corresponding interface For example, hardware interface 1 in Figure 5 is a Bluetooth interface of Bluetooth 2.0 version, and hardware interface 2 in Figure 5 is a Bluetooth interface of Bluetooth 4.0 version.
- the first indication information indicates the Bluetooth 4.0 version, and the electronic device can follow the instructions in the first indication information.
- the version number of the hardware interface 2 is determined as the first hardware interface.
- multimedia transmission interface (version number can be HDMI, VGA, etc.), headphone jack (version number can be 2.5mm, 3.5mm, USB-C, etc.), mobile communication interface (version number can be GSM, CDMA, etc.) may also have version numbers.
- Invoking the first hardware interface may refer to driving the hardware corresponding to the first hardware interface through the first hardware interface.
- the electronic device reads the first indication information in the code of the call application, and the first indication information is used to indicate the first set of hardware interfaces whose type is a mobile communication interface or whose function is a language call.
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a mobile communication interface according to the type of the interface, or the function of the at least one first hardware interface Both include voice calls.
- the electronic device invokes the at least one first hardware interface, and realizes the voice call function by driving the antenna for mobile communication.
- the electronic device reads the first instruction information in the code of the video playback application, and the first instruction information is used to indicate the first set of hardware interfaces whose type is a screen display interface, or whose function is to display images on the screen.
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a screen display interface according to the type of the interface, or the function of the at least one first hardware interface Both include displaying an image on the screen, so that the electronic device calls the at least one first hardware interface and plays the video on the display screen.
- the electronic device reads the first indication information in the code of the audio playback application, and the first indication information is used to indicate the first hardware interface set whose type is the speaker interface, or the first hardware interface whose function is to play sound set.
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a speaker interface according to the type, or the function of the at least one first hardware interface is all It includes playing a sound, so that the electronic device calls the at least one first hardware interface and plays the audio file through the speaker.
- the electronic device reads the first indication information in the code of the audio playback application, and the first indication information is used to indicate the first hardware interface set whose type is the headphone interface, or the first hardware interface whose function is to play sound set.
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a headphone interface according to the type, or the function of the at least one first hardware interface is all It includes playing a sound, so that the electronic device calls the at least one first hardware interface and plays the audio file through the earphone.
- the electronic device reads the first indication information in the code of the security application, and the first indication information is used to indicate the first hardware interface set whose type is fingerprint recognition interface, or the first hardware interface whose function is fingerprint recognition set.
- the electronic device can determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a fingerprint recognition interface according to the type of the interface, or the function of the at least one first hardware interface Both include fingerprint recognition, so that the electronic device calls the at least one first hardware interface, and when the fingerprint fed back by the fingerprint recognition module matches the preset fingerprint information, the current operation of the electronic device is considered to be safe.
- the electronic device reads the first indication information in the code of the map navigation application, and the first indication information is used to indicate the first hardware interface set whose type is positioning interface, or the first hardware interface set whose function is positioning .
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a positioning interface according to the type of the interface, or the function of the at least one first hardware interface is all Including positioning, so that the electronic device invokes the at least one first hardware interface, and plans the driving route through the positioning information fed back by the GPS antenna.
- the electronic device reads the first indication information in the code of the file transfer application, and the first indication information is used to indicate the first hardware interface set whose type is a wireless communication interface, or the first hardware whose function is data transmission. Interface collection.
- the electronic device can determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a wireless communication interface according to the type of the interface, or the function of the at least one first hardware interface Both include data transmission, so that the electronic device calls the at least one first hardware interface, and sends a file to or receives a file sent by a nearby electronic device through a Bluetooth antenna.
- the electronic device reads the first indication information in the code of the shooting application, the first indication information is used to indicate the first set of hardware interfaces whose type is the shooting interface, or the function is to capture the first part of the scene around the electronic device.
- the electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a shooting interface according to the type, or the function of the at least one first hardware interface is all It includes capturing the scene around the electronic device, so that the electronic device calls the at least one first hardware interface, calls the front-facing interface, and shoots the portrait through the front-facing camera.
- the hardware call mode can also be determined according to the hardware type of the electronic device.
- the size of the mobile phone display is 5 inches
- the watch screen size is 40mm, which is different from the mobile phone display size, and you can select hardware call mode 2 for small screens
- the screen size is 50 inches, which is different from the size of the mobile phone display and the size of the watch screen. You can choose the hardware call mode 3 for the super large screen.
- the size of the mobile phone display screen includes 4.8 inches, 5 inches, and 5.1 inches. Therefore, different mobile phones can choose different hardware calling modes adapted to different sizes of screens.
- the first application indicates the first hardware interface set through the first indication information, and the electronic device can confirm according to its own parameters (such as version number, electronic device type, etc.) what the first application should actually call Real hardware interface parameters. Therefore, the first application does not need to know in advance the actual hardware interface of the electronic device executing the first application. Moreover, when the first application indicates the first set of hardware interfaces, the first application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
- Fig. 7 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
- Read second indication information in a code of a second application where the second indication information is used to indicate related information of a second hardware interface set, where the second hardware interface set includes hardware interfaces of multiple electronic devices.
- the types of any two hardware interfaces in the second hardware interface set are the same, or part or all of the functions of any two hardware interfaces in the second hardware interface set are the same.
- the second application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on.
- the second application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the second application.
- the second set of hardware interfaces includes hardware interfaces of multiple electronic devices.
- the types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
- the hardware interface of a mobile phone is different from that of a watch
- the hardware interface of a watch is different from that of a TV.
- the hardware interface is different from the hardware interface of the TV.
- the hardware interfaces of different electronic devices of the same type may be the same or different.
- two mobile phones with the same version number may have the same hardware interfaces
- two mobile phones with the same version number may have different hardware interfaces.
- step 701 For the specific implementation of step 701, reference may be made to step 401 in the embodiment shown in FIG. 4, which is not repeated here.
- the second hardware interface set includes hardware interface 5, hardware interface 6, and hardware interface 7, where hardware interface 5, hardware interface 6, and hardware interface 7 are not hardware interfaces of electronic devices.
- the type of the second hardware interface set is the second type.
- the electronic device does not have any hardware interface in the second hardware interface set, so the electronic device There is no interface belonging to the second type, or no interface matching the second type.
- the function of the second hardware interface set is the second function, and in the case that the second application instructs to call the interface with the second function, the electronic device does not have any hardware interface in the second hardware interface set, so The electronic device does not have an interface that can implement the second function, or does not have an interface that matches the second function.
- the preset target interface can be a virtual interface or a physical interface.
- the electronic device is a watch
- the second indication information indicates to call the USB interface
- the watch does not have a USB interface.
- the electronic device can call the earphone interface for charging, and the earphone interface is the target interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the USB interface, and it will not cause the second application to fail because the electronic device does not have a USB interface (such as the second application running crash or unlimited Cycle error).
- the electronic device is a TV
- the second indication information indicates to call a mobile communication interface
- the TV does not have a mobile communication interface.
- the electronic device can call a preset virtual interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the mobile communication interface, and it will not cause the second application to fail because the electronic device does not have a mobile communication interface (for example, the second application crashes. Or an infinite loop error).
- the warning information may be, for example, displaying symbols such as " ⁇ " on the screen.
- the alarm information is presented, and the alarm information that matches the type or function of the second hardware interface set may be presented.
- the type of the second hardware interface set is a mobile communication interface
- the displayed alarm information may be "the machine does not have the voice call function”.
- the type of the second hardware interface set is a fingerprint identification interface
- the displayed alarm information may be "fingerprint information cannot be obtained”.
- the type of the second hardware interface set is a positioning interface
- the displayed alarm information may be "cannot obtain current location information, whether to manually input current location information".
- the type of the second hardware interface set is a Bluetooth interface
- the displayed alarm information may be "No Bluetooth device connectable”.
- the type of the second hardware interface set is the front camera interface
- the presented warning information may be "An error occurred when calling the front camera, whether to call the rear camera".
- FIG. 8 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
- the third application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on.
- the third application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the third application.
- the third set of hardware interfaces includes the hardware interfaces of multiple electronic devices.
- the types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
- the hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface.
- a hardware interface definition language HDL
- the HIDL language can be used to call the code in the java format to implement the call of the hardware interface.
- different types of electronic devices have different hardware interfaces. For example, the hardware interface of a mobile phone is different from that of a watch, and the hardware interface of a watch is different from that of a TV. The hardware interface is different from the hardware interface of the TV.
- the hardware interfaces of different electronic devices of the same type may be the same or different.
- two mobile phones with the same version number may have the same hardware interfaces
- two mobile phones with the same version number may have different hardware interfaces.
- the function of the hardware interface may be, for example, a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a file transfer function, a function of capturing scenes around the electronic device, and so on.
- the type of the hardware interface may be, for example, a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
- the electronic device determines at least one third hardware interface possessed by the electronic device from a plurality of hardware interfaces, and the plurality of hardware interfaces include those possessed by the plurality of electronic devices.
- Hardware interface determines at least one third hardware interface possessed by the electronic device from a plurality of hardware interfaces, and the plurality of hardware interfaces include those possessed by the plurality of electronic devices.
- the function of the hardware interface to be called by the third application indicated by the third indication information is the third function
- the type of the hardware interface to be called by the third application indicated by the third indication information is the third type. That is, according to the third type indicated by the third indication information, at least one third hardware interface that can be successfully called by the electronic device is determined, and the type or function of the third hardware interface is the same as the third type indicated by the third indication information. Type match. Or, according to the third function indicated by the third indication information, determine at least one third hardware interface that the electronic device can successfully call, and the type or function of the third hardware interface matches the third function indicated by the third indication information .
- the electronic device may store related information of the multiple hardware interfaces, and the related information includes the function or type of each hardware interface of the multiple hardware interfaces.
- the related information also includes various parameters required for invoking each hardware interface.
- the related information also includes the information of the electronic device to which each hardware interface belongs.
- the related information may also include the identification of each hardware interface. Therefore, after the electronic device reads the third indication information, it can select at least one third hardware interface that meets the requirements from the multiple hardware interfaces according to the type, parameter, model, etc. of the electronic device itself.
- the electronic device can find at least one third hardware interface from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, and the at least one third hardware interface and the third indication The third function indicated by the information matches.
- the at least one third hardware interface matches the third function indicated by the third indication information, which may mean that the functions of the at least one third hardware interface are the same as the third function, or that the at least one The type of the third hardware interface matches the third function.
- the function of the hardware interface indicated by the third indication information is a voice call function
- the electronic device can find out from multiple hardware interfaces that the electronic device has the ability to implement language calls based on the relevant information of the multiple hardware interfaces.
- the functional hardware interface for example, the mobile communication interface of the electronic device can be found from multiple hardware interfaces.
- the function of the hardware interface indicated by the third indication information is the function of displaying an image on the screen
- the electronic device can find out from the multiple hardware interfaces the The hardware interface that can realize the function of displaying images on the screen, for example, the screen display interface of the electronic device can be found from multiple hardware interfaces.
- the function of the hardware interface indicated by the third indication information is a sound playback function
- the electronic device can find out from the multiple hardware interfaces that the electronic device has the function of sound playback according to the related information of the multiple hardware interfaces.
- the functional hardware interface for example, the speaker interface and earphone interface of the electronic device can be found from multiple hardware interfaces.
- the function of the hardware interface indicated by the third indication information is the positioning function
- the electronic device can find out from the multiple hardware interfaces the functions of the electronic device that can realize the positioning function according to the related information of the multiple hardware interfaces.
- the hardware interface for example, the positioning interface of the electronic device can be found from multiple hardware interfaces.
- the function of the hardware interface indicated by the third indication information is a wireless communication function
- the electronic device can find out from the multiple hardware interfaces that the electronic device has the wireless communication function according to the related information of the multiple hardware interfaces.
- the functional hardware interface for example, the Bluetooth interface of the electronic device can be found from multiple hardware interfaces.
- the function of the hardware interface indicated by the third indication information is the shooting function
- the electronic device can find out from the multiple hardware interfaces the functions of the electronic device that can realize the shooting function according to the related information of the multiple hardware interfaces.
- the hardware interface for example, the front camera interface and the rear camera interface of the electronic device can be found from multiple hardware interfaces.
- the electronic device can find at least one third hardware interface from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, and the at least one third hardware interface and the third indication information The indicated third type matches.
- the at least one third hardware interface matches the third type indicated by the third indication information, which may mean that the type of the at least one third hardware interface is the same as the third type, or that the at least one The functions that the third hardware interface can implement match the third type.
- the third indication information indicates a mobile communication interface
- the electronic device can find the mobile communication interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from the multiple hardware interfaces Find the hardware interface of the electronic device that can realize the language call function.
- the third indication information indicates the screen display interface
- the electronic device can find the screen display interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from the multiple hardware interfaces Find the hardware interface of the electronic device that can realize the function of displaying images on the screen.
- the third indication information indicates a speaker interface
- the electronic device can find the speaker interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the sound playback function.
- the third indication information indicates a headphone interface
- the electronic device can find the headphone interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the sound playback function.
- the third indication information indicates the positioning interface
- the electronic device can find the positioning interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the positioning function.
- the third indication information indicates the Bluetooth interface
- the electronic device can find the Bluetooth interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the wireless communication function.
- the third indication information indicates the front camera interface
- the electronic device can find the front camera interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from multiple hardware interfaces. Find the hardware interface of the electronic device that can realize the shooting function in the hardware interface.
- determining at least one third hardware interface of the electronic device from a plurality of hardware interfaces includes: determining, according to the type of the electronic device, the A third set of hardware interfaces matching the type of the electronic device, where the multiple hardware interfaces include hardware interfaces in the third set of hardware interfaces; according to the third indication information, determine at least from the third set of hardware interfaces A third hardware interface.
- the third hardware interface set matches the type of the electronic device, which may mean that the third hardware interface set includes part or all of the hardware interfaces of the electronic device, and does not include hardware interfaces that the electronic device does not have.
- the third hardware interface set does not include hardware interfaces that the electronic device does not have.
- the third hardware interface set may include hardware interfaces of other types of electronic devices. For example, if the third hardware interface matches the mobile phone, then the hardware interfaces in the third hardware interface set are all the hardware interfaces of the mobile phone, and the third hardware interface set will not include hardware interfaces that are not the mobile phone, for example, it will not include the hardware interfaces of the watch. , It will not include the hardware interface of the TV.
- hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4 in hardware interface set 901 are all hardware interfaces of electronic device 1, and hardware interface 5, hardware interface in hardware interface set 902 6.
- the hardware interface 7 is the hardware interface of the electronic device 2.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- Hardware interface; the function of the hardware interface indicated by the third indication information is the voice call function, and the electronic device can determine the hardware interface that can realize the language call function from the third hardware interface set according to the third indication information, or from the third The mobile communication interface is determined in the hardware interface set.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- Hardware interface; the function of the hardware interface indicated by the third instruction information is the sound playback function; the electronic device can determine the hardware interface that can realize the sound playback function from the third hardware interface set according to the third instruction information, or from the third The speaker interface and headphone interface are determined in the hardware interface set.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- Hardware interface; the function of the hardware interface indicated by the third indication information is the positioning function; the electronic device can determine the hardware interface that can realize the positioning function from the third hardware interface set according to the third indication information, or from the third hardware interface Determine the positioning interface in the collection.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- Hardware interface; the function of the hardware interface indicated by the third indication information is a wireless communication function; the electronic device can determine a hardware interface that can realize the wireless communication function from the third hardware interface set according to the third indication information, or from the third The Bluetooth interface is determined in the hardware interface set.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- Hardware interface; the function of the hardware interface indicated by the third instruction information is the shooting function; the electronic device can determine the hardware interface that can realize the shooting function from the third hardware interface set according to the third instruction information, or from the third hardware interface
- the front camera interface and the rear camera interface are determined in the collection.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the third instruction information indicates the mobile communication interface.
- the electronic device can determine the mobile communication interface from the third hardware interface set according to the third instruction information, or determine the mobile communication interface from the third hardware interface set that can realize the language call function Hardware interface.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the third indication information indicates the headphone interface; the electronic device can determine the headphone interface from the third hardware interface set according to the third indication information, or determine the hardware interface that can realize the sound playback function from the third hardware interface set .
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the third instruction information indicates the positioning interface; the electronic device can determine the positioning interface from the third hardware interface set or determine the hardware interface that can implement the positioning function from the third hardware interface set according to the third instruction information.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- the third instruction information indicates Bluetooth; the electronic device can determine the Bluetooth interface from the third hardware interface set, or determine the hardware interface that can realize the wireless communication function from the third hardware interface set according to the third instruction information.
- the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device.
- step 803 For the specific implementation of step 803, refer to step 403 in the embodiment shown in FIG. 4, which is not repeated here.
- the method further includes: reading fourth indication information in the code of the fourth application, the fourth function of the hardware interface that the fourth application needs to call; In the case of hardware interfaces that match the four functions, the preset target interface is called, or alarm information is presented.
- the method further includes: reading fourth indication information in the code of the fourth application, the fourth type of hardware interface that the fourth application needs to call; In the case of hardware interfaces that match the four types, the preset target interface is called, or alarm information is presented.
- the preset target interface can be a virtual interface or a physical interface.
- the electronic device is a watch
- the second indication information indicates to call the USB interface
- the watch does not have a USB interface.
- the electronic device can call the earphone interface for charging, and the earphone interface is the target interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the USB interface, and it will not cause the second application to fail because the electronic device does not have a USB interface (such as the second application crashing or infinite Cycle error).
- the electronic device is a TV
- the second indication information indicates to call a mobile communication interface
- the TV does not have a mobile communication interface.
- the electronic device can call a preset virtual interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the mobile communication interface, and it will not cause the second application to fail because the electronic device does not have a mobile communication interface (for example, the second application crashes. Or an infinite loop error).
- the warning information may be, for example, displaying symbols such as " ⁇ " on the screen.
- the presented alarm information may be determined according to the type or function of the second hardware interface set indicated by the second indication information.
- the type of the second hardware interface set is a mobile communication interface
- the displayed alarm information may be "the machine does not have the voice call function”.
- the type of the second hardware interface set is a fingerprint identification interface
- the displayed alarm information may be "fingerprint information cannot be obtained”.
- the type of the second hardware interface set is a positioning interface
- the displayed alarm information may be "cannot obtain current location information, whether to manually input current location information".
- the type of the second hardware interface set is a Bluetooth interface
- the displayed alarm information may be "No Bluetooth device connectable”.
- the type of the second hardware interface set is the front camera interface
- the presented warning information may be "An error occurred when calling the front camera, whether to call the rear camera".
- the third indication information further includes information indicating the version number of the interface that the third application needs to call.
- FIG. 10 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application.
- the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
- the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and the system library.
- each layer in the software architecture can call the hardware layer through the hardware interface layer, and the hardware layer may include multiple pieces of hardware in FIG. 1.
- the application layer, the application framework layer, the Android runtime, the system library, and the hardware layer can refer to the example shown in FIG. 2 and will not be repeated here.
- a hardware interface layer may also be included between the system layer and the hardware layer.
- the hardware interface layer includes hardware interfaces of multiple electronic devices, and each hardware interface can drive the hardware of one electronic device. For example, it includes a mobile phone interface for driving a display screen, a watch interface for driving a display screen, a TV interface for driving a display screen, and a mobile phone interface for driving a camera.
- the processor or chip inside the electronic device When the processor or chip inside the electronic device reads the code of the application program layer, application framework layer, Android runtime, and system library, it can find the hardware interface that the electronic device can call through the hardware interface layer, so as to drive the hardware layer Hardware, and perform the corresponding operations.
- the hardware interface layer includes the hardware that can be called by the mobile phone, the hardware that can be called by the watch, and the hardware that can be called by the TV.
- the mobile phone can find the hardware interface that the mobile phone can call in the hardware interface layer to drive the hardware in the hardware layer and execute The corresponding operation.
- FIG. 11 shows a block diagram of the internal structure of the hardware interface layer.
- the hardware interface layer may include a hardware interface proxy layer, a hardware interface adaptation layer, and a hardware interface access control layer.
- the hardware interface proxy layer may include authority control, which is used to confirm whether the hardware interface access request is safe, and can also be used to confirm whether the access object has the authority to access the hardware interface.
- authority control which is used to confirm whether the hardware interface access request is safe, and can also be used to confirm whether the access object has the authority to access the hardware interface.
- the hardware interface agent layer can realize safe and reasonable access to the hardware interface layer.
- the hardware interface adaptation layer includes multiple hardware interfaces.
- the hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface.
- a hardware interface definition language HDL
- the HIDL language can be used to call the code in the java format to implement the call of the hardware interface.
- the hardware interface adaptation layer includes the multiple hardware interfaces, and the functions that the multiple hardware interfaces can implement are different from each other.
- Figure 11 shows an example in which the hardware interface adaptation layer includes multiple different types of hardware interfaces.
- the hardware interface adaptation layer includes a type 1 hardware interface and a type 2 hardware interface.
- Multiple hardware interfaces in the hardware interface adaptation layer are virtual interfaces.
- the multiple hardware interfaces in the hardware interface adaptation layer may be used to represent at least one of the above-mentioned first hardware interface set, second hardware interface set, third hardware interface set, and fourth hardware interface set.
- the hardware interface access control layer is used to determine the hardware interface that the electronic device can call or perform preset operations according to the calling situation of the hardware interface in the hardware interface adaptation layer.
- the electronic device may include a software module or a hard-wired module for identifying the type of the device. For example, the electronic device can call the hardware of the electronic device or determine the hardware interface of the electronic device by using the version number, model, etc. of the electronic device.
- the electronic device may include a software module or a hard-wired module for identifying the type of hardware. For example, the electronic device can identify the type of the chip, so as to call the hardware including the chip, or determine the hardware interface of the hardware including the chip. For another example, the electronic device can identify the version number or model of the hardware to determine whether to call the hardware or determine the hardware interface of the hardware.
- Each hardware interface in the hardware interface adaptation layer has a corresponding relationship with the hardware interfaces of at least two electronic devices.
- the type 1 hardware interface has a corresponding relationship with the hardware interface 1, the hardware interface 2 of the device 2, and the hardware interface 3 of the device 3.
- the type 2 hardware interface has a corresponding relationship with the hardware interface 4 of the device 1 and the hardware interface 5 of the device 2.
- the device 1 can call the hardware interface 1 according to the instruction information.
- the device 3 can call a preset target interface or present alarm information.
- the multiple hardware interfaces in the hardware interface access control layer can be used to represent multiple hardware interfaces in the above hardware interface set.
- the hardware interface access control layer can drive the hardware in the hardware layer to perform corresponding operations according to the code in the application program.
- FIG. 12 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
- the electronic device 1200 shown in FIG. 12 includes a memory 1201, a processor 1202, a communication interface 1203, and a bus 1204.
- the memory 1201, the processor 1202, and the communication interface 1203 implement communication connections between each other through the bus 1204.
- the memory 1201 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
- the memory 1201 may store a program.
- the processor 1202 is configured to execute each step of the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application.
- the processor 1202 may adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more
- the integrated circuit is used to execute related programs to implement the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application.
- the processor 1202 may also be an integrated circuit chip with signal processing capability.
- each step of the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 1202 or instructions in the form of software.
- the above-mentioned processor 1202 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, Discrete gates or transistor logic devices, discrete hardware components.
- DSP digital signal processing
- ASIC application-specific integrated circuit
- FPGA field programmable gate array
- the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
- the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
- the software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
- the storage medium is located in the memory 1201, and the processor 1202 reads the information in the memory 1201, and combines its hardware to complete the functions required by the units included in the electronic device of the embodiment of the present application, or executes Figures 4 and 7 in the embodiment of the present application. Or the image processing method shown in 8.
- the communication interface 1203 uses a transceiving device such as but not limited to a transceiver to implement communication between the electronic device 1200 and other devices or a communication network.
- a transceiving device such as but not limited to a transceiver to implement communication between the electronic device 1200 and other devices or a communication network.
- the information of the neural network to be constructed and the training data required in the process of constructing the neural network can be obtained through the communication interface 1203 (the image to be processed in the embodiment shown in FIG. 4, 7 or 8).
- the bus 1204 may include a path for transferring information between various components of the electronic device 1200 (for example, the memory 1201, the processor 1202, and the communication interface 1203).
- the acquisition module in the electronic device may be equivalent to the communication interface 1203 in the electronic device 1200; the processing module in the electronic device may be equivalent to the processor 1202.
- the disclosed system, device, and method may be implemented in other ways.
- the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
- the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
- the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
- the function 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.
- the technical solution of the present application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
- the aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disks or optical disks and other media that can store program codes. .
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Telephone Function (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
Description
本申请要求于2019年9月18日提交中国专利局、申请号为201910883684.7、申请名称为“调用硬件接口的方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on September 18, 2019, the application number is 201910883684.7, and the application name is "Method and Electronic Device for Calling Hardware Interface", the entire content of which is incorporated into this application by reference in.
本申请涉及电子设备领域,并且更具体地,涉及一种调用硬件接口的方法及电子设备。This application relates to the field of electronic devices, and more specifically, to a method for invoking a hardware interface and an electronic device.
市场上常见的电子设备有手机、平板电脑、手表、电视、汽车上的人机交互装置等,且不同的电子设备的生产厂家可以不同,因此不同的电子设备的硬件接口可以不同。运行应用时需要调用电子设备上的硬件接口。例如运行视频播放程序时需要调用电子设备上的显示屏的接口和麦克风的接口。由于不同的设备的硬件接口可以不同,为了可以在多种电子设备上运行应用,并成功调用相关的硬件接口,应用开发公司至少需要设计两款应用,才能实现应用成功运行在硬件接口不同的两个设备上。例如,应用开发公司需要针对手机和手表分别设计两款应用。而市场上主流硬件接口的数量繁多,应用公司需要针对多种硬件接口分别设计多种不同的应用,无疑会加重应用开发人员的负担。Common electronic devices in the market include mobile phones, tablet computers, watches, TVs, human-computer interaction devices in automobiles, etc., and different electronic device manufacturers can be different, so the hardware interfaces of different electronic devices can be different. When running the application, it is necessary to call the hardware interface on the electronic device. For example, when running a video playback program, it is necessary to call the interface of the display screen and the interface of the microphone on the electronic device. Since the hardware interfaces of different devices can be different, in order to run applications on a variety of electronic devices and successfully call related hardware interfaces, application development companies need to design at least two applications to successfully run applications on two different hardware interfaces. Devices. For example, an application development company needs to design two applications for mobile phones and watches. However, there are so many mainstream hardware interfaces on the market, and application companies need to design a variety of different applications for multiple hardware interfaces, which will undoubtedly increase the burden on application developers.
发明内容Summary of the invention
本申请提供一种调用硬件接口的方法及电子设备,目的在于便利应用开发人员开发应用程序。This application provides a method and electronic device for invoking a hardware interface, with the purpose of facilitating application developers to develop application programs.
第一方面,提供了一种调用硬件接口的方法,包括:读取第一应用的代码中的第一指示信息,所述第一指示信息用于指示第一硬件接口集合的相关信息,所述第一硬件接口集合包括多个电子设备的硬件接口,所述第一硬件接口集合中的任意两个硬件接口的类型相同,或者,所述第一硬件接口集合中的任意两个硬件接口的部分或全部功能相同;根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口;调用所述至少一个第一硬件接口。In a first aspect, a method for invoking a hardware interface is provided, including: reading first indication information in a code of a first application, where the first indication information is used to indicate related information of a first hardware interface set, and The first hardware interface set includes hardware interfaces of multiple electronic devices, and any two hardware interfaces in the first hardware interface set are of the same type, or part of any two hardware interfaces in the first hardware interface set Or all functions are the same; determine at least one first hardware interface of the electronic device from the first hardware interface set according to the first indication information; call the at least one first hardware interface.
在本申请中,第一应用例如可以是通话应用、视频播放应用、音频播放应用、安全应用、地图导航应用、文件传输应用、拍摄应用等。第一应用还可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等。本申请对第一应用的具体类型不作限定。In this application, the first application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on. The first application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the first application.
第一硬件接口集合包括多个电子设备的硬件接口,该多个电子设备的类型例如可以包括手机、平板电脑、智能手表、视频播放器、膝上型计算机(Laptop)、台式计算机、电视、笔记本电脑中的至少两个。The first set of hardware interfaces includes hardware interfaces of multiple electronic devices. The types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
硬件接口的类型可以包括:移动通信接口、屏幕显示接口、扬声器接口、耳机接口、 指纹识别接口、定位接口、无线通信接口、拍摄接口等中的一个或多个。The types of the hardware interface may include one or more of a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
硬件接口的功能可以包括:语音通话功能、在屏幕上显示图像的功能、声音播放功能、指纹识别功能、定位功能、数据传输功能、捕捉电子设备周围场景的功能等中的一个或多个。The functions of the hardware interface may include one or more of a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a data transmission function, and a function of capturing scenes around the electronic device.
在本申请实施例中,第一应用通过第一指示信息指示第一硬件接口集合,该电子设备可以根据其自身参数(如版本号、电子设备类型等信息)确认该第一应用实际应当调用的真实硬件接口参数。因此,第一应用无需预先获知执行该第一应用的电子设备所具有的真实硬件接口。并且,该第一应用在指示第一硬件接口集合的情况下,该第一应用可以在多个电子设备上被执行。所以本申请实施例提供的方法可以降低应用开发人员的负担。In this embodiment of the application, the first application indicates the first hardware interface set through the first indication information, and the electronic device can confirm according to its own parameters (such as version number, electronic device type, etc.) what the first application should actually call Real hardware interface parameters. Therefore, the first application does not need to know in advance the actual hardware interface of the electronic device executing the first application. Moreover, when the first application indicates the first set of hardware interfaces, the first application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
结合第一方面,在第一方面的某些实现方式中,第一指示信息包括指示第二硬件接口的信息,且所述电子设备不具有所述第二硬件接口,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将所述第二硬件接口所属于的硬件接口集合确定为所述第一硬件接口集合。With reference to the first aspect, in some implementations of the first aspect, the first indication information includes information indicating a second hardware interface, and the electronic device does not have the second hardware interface, and in accordance with the Before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: according to the first instruction information, assigning the second hardware interface to The set of hardware interfaces is determined to be the first set of hardware interfaces.
在本申请实施例中,第一指示信息可以指示其他电子设备所具有的硬件接口,因此,根据该其他电子设备所具有的硬件接口的功能或类型,执行该第一应用的电子设备可以确定具有相同或相似功能或类型的硬件接口,因此原本被特殊地应用在一个特定电子设备的第一应用可以跨设备地被应用在多个电子设备上。In the embodiment of the present application, the first indication information may indicate the hardware interface of other electronic devices. Therefore, according to the function or type of the hardware interface of the other electronic device, the electronic device executing the first application can determine that it has Hardware interfaces with the same or similar functions or types, so the first application that was originally specially applied to a specific electronic device can be applied to multiple electronic devices across devices.
结合第一方面,在第一方面的某些实现方式中,所述第一指示信息包括指示所述第一应用需要调用的硬件接口的第一功能的信息,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将与所述第一功能匹配的硬件接口集合确定为所述第一硬件接口集合。With reference to the first aspect, in some implementations of the first aspect, the first indication information includes information indicating the first function of the hardware interface that the first application needs to call, and in accordance with the first indication Information, before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: according to the first indication information, matching a hardware interface with the first function The set is determined as the first hardware interface set.
在本申请实施例中,第一指示信息可以指示需要调用的硬件接口的功能;根据该功能,电子设备可以确定与该功能匹配的第一硬件接口集合。开发该第一应用的应用开发人员也只需要了解硬件接口代码的功能,无需针对特定的电子设备开发应用程序,因此可以降低应用开发人员的负担。In the embodiment of the present application, the first indication information may indicate the function of the hardware interface that needs to be invoked; according to the function, the electronic device may determine the first set of hardware interfaces that matches the function. The application developer who develops the first application also only needs to understand the function of the hardware interface code, and does not need to develop an application program for a specific electronic device, so the burden of the application developer can be reduced.
结合第一方面,在第一方面的某些实现方式中,第一指示信息包括指示所述第一应用需要调用的硬件接口的第一类型的信息,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将与所述第一类型匹配的硬件接口集合确定为所述第一硬件接口集合。With reference to the first aspect, in some implementations of the first aspect, the first indication information includes information indicating the first type of the hardware interface that the first application needs to call, and according to the first indication information, Before determining at least one first hardware interface of the electronic device from the first hardware interface set, the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first type Is the first set of hardware interfaces.
在本申请实施例中,第一指示信息可以指示需要调用的硬件接口的类型;根据该类型,电子设备可以确定与该类型匹配的第一硬件接口集合。开发该第一应用的应用开发人员也只需要了解硬件接口代码的类型,无需针对特定的电子设备开发应用程序,因此可以降低应用开发人员的负担。In the embodiment of the present application, the first indication information may indicate the type of hardware interface that needs to be called; according to the type, the electronic device can determine the first set of hardware interfaces that matches the type. The application developer who develops the first application also only needs to understand the type of hardware interface code, and does not need to develop an application program for a specific electronic device, so the burden of the application developer can be reduced.
结合第一方面,在第一方面的某些实现方式中,所述方法还包括:读取第二应用的代码中的第二指示信息,所述第二指示信息用于指示第二硬件接口集合的相关信息;在所述电子设备不具有所述第二硬件接口集合中的任一硬件接口的情况下,调用预设的目标接口。With reference to the first aspect, in some implementations of the first aspect, the method further includes: reading second indication information in the code of the second application, where the second indication information is used to indicate a second set of hardware interfaces Related information; in the case that the electronic device does not have any hardware interface in the second set of hardware interfaces, call the preset target interface.
预设的目标接口,可以是虚拟接口或是物理接口。The preset target interface can be a virtual interface or a physical interface.
在本申请实施例中,由于电子设备可以调用目标接口,因此不会得到电子设备无法调用硬件接口的调用反馈结果,也就不会导致第二应用运行失败(如第二应用运行崩溃或无限次的循环错误)。In the embodiment of the present application, since the electronic device can call the target interface, the call feedback result that the electronic device cannot call the hardware interface will not be obtained, and it will not cause the second application to fail to run (such as the second application running crash or unlimited times). Loop error).
结合第一方面,在第一方面的某些实现方式中,所述方法还包括:读取第二应用的代码中的第二指示信息,所述第二指示信息用于指示第二硬件接口集合的相关信息;在所述电子设备不具有所述第二硬件接口集合中的任一硬件接口的情况下,呈现告警信息。With reference to the first aspect, in some implementations of the first aspect, the method further includes: reading second indication information in the code of the second application, where the second indication information is used to indicate a second set of hardware interfaces Related information; in the case that the electronic device does not have any hardware interface in the second set of hardware interfaces, presenting alarm information.
可选的,所述呈现告警信息,包括呈现与第二硬件接口集合的类型或功能匹配的告警信息。Optionally, the presenting alarm information includes presenting alarm information that matches the type or function of the second hardware interface set.
在本申请实施例中,由于第二指示信息指示第二硬件接口集合,因此电子设备可以获知该第一应用需要调用的硬件接口的类型或功能,而该告警信息与该硬件接口的类型或功能对应,从而可以为使用该第二应用的用户提供更加准确的硬件接口报错信息。In the embodiment of the present application, since the second indication information indicates the second set of hardware interfaces, the electronic device can learn the type or function of the hardware interface that the first application needs to call, and the alarm information and the type or function of the hardware interface Correspondingly, it is possible to provide users who use the second application with more accurate hardware interface error reporting information.
结合第一方面,在第一方面的某些实现方式中,所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口,包括:根据所述电子设备的类型以及所述第一指示信息,从所述第一硬件接口集合中确定所述至少一个第一硬件接口。With reference to the first aspect, in some implementations of the first aspect, the determining from the first hardware interface set according to the first indication information that the electronic device has at least one first hardware interface includes: The at least one first hardware interface is determined from the first hardware interface set according to the type of the electronic device and the first indication information.
在本申请实施例中,由于不同电子设备所具有的硬件接口不同,在电子设备类型较多时,根据电子设备类型确定硬件接口,可以提高调用硬件接口的效率。In the embodiments of the present application, since different electronic devices have different hardware interfaces, when there are many types of electronic devices, determining the hardware interface according to the type of the electronic device can improve the efficiency of calling the hardware interface.
结合第一方面,在第一方面的某些实现方式中,所述第一指示信息还包括指示所述第一应用需要调用的接口的版本号的信息。With reference to the first aspect, in some implementations of the first aspect, the first indication information further includes information indicating the version number of the interface that the first application needs to call.
在本申请实施例中,由于不同的硬件接口的版本号可能不同,在硬件接口的版本号较多时,根据硬件接口的版本号确定硬件接口,可以提高调用硬件接口的效率。In the embodiment of the present application, since the version numbers of different hardware interfaces may be different, when the version numbers of the hardware interfaces are large, the hardware interface is determined according to the version number of the hardware interface, which can improve the efficiency of calling the hardware interface.
第二方面,提供了一种调用硬件接口的方法,包括:读取第三应用的代码中的第三指示信息,所述第三指示信息用于指示所述第三应用需要调用的硬件接口的功能或类型;根据电子设备的类型以及所述第三指示信息,从多个硬件接口中确定所述电子设备所具有的至少一个第三硬件接口,所述多个硬件接口包括多个电子设备所具有的硬件接口;调用所述至少一个第三硬件接口。In a second aspect, a method for invoking a hardware interface is provided, which includes: reading third indication information in a code of a third application, where the third indication information is used to indicate the hardware interface that the third application needs to call. Function or type; according to the type of the electronic device and the third indication information, at least one third hardware interface of the electronic device is determined from a plurality of hardware interfaces, and the plurality of hardware interfaces includes the Have a hardware interface; call the at least one third hardware interface.
在本申请中,第三应用例如可以是通话应用、视频播放应用、音频播放应用、安全应用、地图导航应用、文件传输应用、拍摄应用等。第三应用还可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等。本申请对第三应用的具体类型不作限定。In this application, the third application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on. The third application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the third application.
第三硬件接口集合包括多个电子设备的硬件接口,该多个电子设备的类型例如可以包括手机、平板电脑、智能手表、视频播放器、膝上型计算机(Laptop)、台式计算机、电视、笔记本电脑中的至少两个。The third set of hardware interfaces includes the hardware interfaces of multiple electronic devices. The types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
硬件接口的类型可以包括:移动通信接口、屏幕显示接口、扬声器接口、耳机接口、指纹识别接口、定位接口、无线通信接口、拍摄接口等中的一个或多个。The types of hardware interfaces may include: one or more of a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
硬件接口的功能可以包括:语音通话功能、在屏幕上显示图像的功能、声音播放功能、指纹识别功能、定位功能、数据传输功能、捕捉电子设备周围场景的功能等中的一个或多个。The functions of the hardware interface may include one or more of a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a data transmission function, and a function of capturing scenes around the electronic device.
在本申请实施例中,第三应用通过第三指示信息指示需要调用的硬件接口的类型或功能,该电子设备可以根据其自身参数(如版本号、电子设备类型等信息)确认该第三应用实际应当调用的真实硬件接口参数。因此,第三应用无需预先获知执行该第三应用的电子设备所具有的真实硬件接口。并且,该第三应用在指示需要调用的硬件接口的类型或功能的情况下,该第三应用可以在多个电子设备上被执行。所以本申请实施例提供的方法可以降低应用开发人员的负担。In the embodiment of the present application, the third application indicates the type or function of the hardware interface that needs to be called through the third indication information, and the electronic device can confirm the third application according to its own parameters (such as version number, electronic device type, etc.) The actual hardware interface parameters that should actually be called. Therefore, the third application does not need to know the real hardware interface of the electronic device executing the third application in advance. In addition, when the third application indicates the type or function of the hardware interface that needs to be called, the third application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
结合第二方面,在第二方面的某些实现方式中,所述方法还包括:读取第四应用的代码中的第四指示信息,所述第四指示信息用于指示第四硬件接口集合的相关信息;在所述电子设备不具有所述第四硬件接口集合中的任一硬件接口的情况下,调用预设的目标接口。With reference to the second aspect, in some implementations of the second aspect, the method further includes: reading fourth indication information in the code of the fourth application, where the fourth indication information is used to indicate a fourth hardware interface set Related information; in the case that the electronic device does not have any hardware interface in the fourth hardware interface set, call the preset target interface.
预设的目标接口,可以是虚拟接口或是物理接口。The preset target interface can be a virtual interface or a physical interface.
在本申请实施例中,由于电子设备可以调用目标接口,因此不会得到电子设备无法调用硬件接口的调用反馈结果,也就不会导致第四应用运行失败(如第四应用运行崩溃或无限次的循环错误)。In the embodiment of the present application, since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the hardware interface, and it will not cause the fourth application to fail to run (such as the fourth application crashing or unlimited times. Loop error).
结合第二方面,在第二方面的某些实现方式中,所述方法还包括:读取第四应用的代码中的第四指示信息,所述第四指示信息用于指示第四硬件接口集合的相关信息;在所述电子设备不具有所述第四硬件接口集合中的任一硬件接口的情况下,,呈现告警信息。With reference to the second aspect, in some implementations of the second aspect, the method further includes: reading fourth indication information in the code of the fourth application, where the fourth indication information is used to indicate a fourth hardware interface set Related information; in the case that the electronic device does not have any hardware interface in the fourth hardware interface set, alarm information is presented.
可选的,所述呈现告警信息,包括呈现与第二硬件接口集合的类型或功能匹配的告警信息。Optionally, the presenting alarm information includes presenting alarm information that matches the type or function of the second hardware interface set.
在本申请实施例中,由于第四指示信息指示第四硬件接口集合,因此电子设备可以获知该第四应用需要调用的硬件接口的类型或功能,而该告警信息与该硬件接口的类型或功能对应,从而可以为使用该第四应用的用户提供更加准确的硬件接口报错信息。In the embodiment of the present application, since the fourth indication information indicates the fourth hardware interface set, the electronic device can learn the type or function of the hardware interface that the fourth application needs to call, and the alarm information and the type or function of the hardware interface Correspondingly, it is possible to provide users who use the fourth application with more accurate hardware interface error reporting information.
结合第二方面,在第二方面的某些实现方式中,所述方法还包括:所述第三指示信息还包括指示所述第三应用需要调用的接口的版本号的信息。With reference to the second aspect, in some implementations of the second aspect, the method further includes: the third indication information further includes information indicating the version number of the interface that the third application needs to call.
在本申请实施例中,由于不同的硬件接口的版本号可能不同,在硬件接口的版本号较多时,根据硬件接口的版本号确定硬件接口,可以提高调用硬件接口的效率。In the embodiment of the present application, since the version numbers of different hardware interfaces may be different, when the version numbers of the hardware interfaces are large, the hardware interface is determined according to the version number of the hardware interface, which can improve the efficiency of calling the hardware interface.
第三方面,提供一种电子设备,包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行以下过程:读取第一应用的代码中的第一指示信息,所述第一指示信息用于指示第一硬件接口集合的相关信息,所述第一硬件接口集合包括多个电子设备的硬件接口,所述第一硬件接口集合中的任意两个硬件接口的类型相同,或者,所述第一硬件接口集合中的任意两个硬件接口的部分或全部功能相同;根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口;调用所述至少一个第一硬件接口。In a third aspect, there is provided an electronic device, including: a memory, configured to store a program; a processor, configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute the following Process: Read the first indication information in the code of the first application, where the first indication information is used to indicate related information of a first hardware interface set, and the first hardware interface set includes hardware interfaces of multiple electronic devices, Any two hardware interfaces in the first hardware interface set are of the same type, or any two hardware interfaces in the first hardware interface set have part or all of the same functions; according to the first instruction information, from At least one first hardware interface of the electronic device is determined in the first hardware interface set; and the at least one first hardware interface is invoked.
结合第三方面,在第三方面的某些实现方式中,第一指示信息包括指示第二硬件接口的信息,且所述电子设备不具有所述第二硬件接口,所述处理器,还用于在根据所述第一指示信息,从所述第一硬件接口集合中确定所述电子设备所具有的至少一个第一硬件接口之前,应用于根据所述第一指示信息,将所述第二硬件接口所属于的硬件接口集合确定为所述第一硬件接口集合。With reference to the third aspect, in some implementations of the third aspect, the first indication information includes information indicating a second hardware interface, and the electronic device does not have the second hardware interface, and the processor also uses Before determining at least one first hardware interface of the electronic device from the first hardware interface set according to the first instruction information, it is applied to the second hardware interface according to the first instruction information. The hardware interface set to which the hardware interface belongs is determined as the first hardware interface set.
结合第三方面,在第三方面的某些实现方式中,所述第一指示信息包括指示所述第一 应用需要调用的硬件接口的第一功能的信息,所述处理器,还用于在根据所述第一指示信息,从所述第一硬件接口集合中确定所述电子设备所具有的至少一个第一硬件接口之前,应用于根据所述第一指示信息,将与所述第一功能匹配的硬件接口集合确定为所述第一硬件接口集合。With reference to the third aspect, in some implementation manners of the third aspect, the first indication information includes information indicating the first function of the hardware interface that the first application needs to call, and the processor is further configured to According to the first instruction information, before at least one first hardware interface of the electronic device is determined from the first hardware interface set, it is applied according to the first instruction information to communicate with the first function The matched hardware interface set is determined as the first hardware interface set.
结合第三方面,在第三方面的某些实现方式中,第一指示信息包括指示所述第一应用需要调用的硬件接口的第一类型的信息,所述处理器,还用于在根据所述第一指示信息,从所述第一硬件接口集合中确定所述电子设备所具有的至少一个第一硬件接口之前,应用于根据所述第一指示信息,将与所述第一类型匹配的硬件接口集合确定为所述第一硬件接口集合。With reference to the third aspect, in some implementations of the third aspect, the first indication information includes information indicating the first type of the hardware interface that the first application needs to call, and the processor is further configured to The first indication information is applied to the one that matches the first type according to the first indication information before determining at least one first hardware interface possessed by the electronic device from the first hardware interface set. The set of hardware interfaces is determined to be the first set of hardware interfaces.
结合第三方面,在第三方面的某些实现方式中,所述处理器,还用于读取第二应用的代码中的第二指示信息,所述第二指示信息用于指示第二硬件接口集合的相关信息;所述处理器,还用于在所述电子设备不具有所述第二硬件接口集合中的任一硬件接口的情况下,应用于调用预设的目标接口。With reference to the third aspect, in some implementations of the third aspect, the processor is further configured to read the second indication information in the code of the second application, and the second indication information is used to indicate the second hardware Related information of the interface set; the processor is further configured to call a preset target interface when the electronic device does not have any hardware interface in the second hardware interface set.
结合第三方面,在第三方面的某些实现方式中,所述处理器,还用于读取第二应用的代码中的第二指示信息,所述第二指示信息用于指示第二硬件接口集合的相关信息;所述处理器,还用于在所述电子设备不具有所述第二硬件接口集合中的任一硬件接口的情况下,应用于呈现告警信息。With reference to the third aspect, in some implementations of the third aspect, the processor is further configured to read the second indication information in the code of the second application, and the second indication information is used to indicate the second hardware Related information of the interface set; the processor is further configured to be applied to present alarm information when the electronic device does not have any hardware interface in the second hardware interface set.
结合第三方面,在第三方面的某些实现方式中,所述处理器具体用于,根据所述电子设备的类型以及所述第一指示信息,从所述第一硬件接口集合中确定所述至少一个第一硬件接口。With reference to the third aspect, in some implementations of the third aspect, the processor is specifically configured to determine from the first hardware interface set according to the type of the electronic device and the first indication information At least one first hardware interface.
结合第三方面,在第三方面的某些实现方式中,所述第一指示信息还包括指示所述第一应用需要调用的接口的版本号的信息。With reference to the third aspect, in some implementation manners of the third aspect, the first indication information further includes information indicating the version number of the interface that the first application needs to call.
第四方面,提供了一种电子设备,包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行以下过程:读取第三应用的代码中的第三指示信息,所述第三指示信息用于指示所述第三应用需要调用的硬件接口的功能或类型;根据电子设备的类型以及所述第三指示信息,从多个硬件接口中确定所述电子设备所具有的至少一个第三硬件接口,所述多个硬件接口包括多个电子设备所具有的硬件接口;调用所述至少一个第三硬件接口。In a fourth aspect, an electronic device is provided, including: a memory, configured to store a program; a processor, configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute The following process: read the third indication information in the code of the third application, where the third indication information is used to indicate the function or type of the hardware interface that the third application needs to call; according to the type of electronic device and the first Three indication information, determining at least one third hardware interface of the electronic device from multiple hardware interfaces, the multiple hardware interfaces including hardware interfaces of the multiple electronic devices; calling the at least one third hardware interface.
结合第四方面,在第四方面的某些实现方式中,所述处理器,还用于读取第四应用的代码中的第四指示信息,所述第四指示信息用于指示第四硬件接口集合的相关信息;所述处理器,还用于在所述电子设备不具有所述第四硬件接口集合中的任一硬件接口的情况下,应用于调用预设的目标接口。With reference to the fourth aspect, in some implementation manners of the fourth aspect, the processor is further configured to read fourth indication information in the code of the fourth application, and the fourth indication information is used to indicate the fourth hardware Related information of the interface set; the processor is further configured to call the preset target interface when the electronic device does not have any hardware interface in the fourth hardware interface set.
结合第四方面,在第四方面的某些实现方式中,所述第三指示信息还包括指示所述第三应用需要调用的接口的版本号的信息。With reference to the fourth aspect, in some implementation manners of the fourth aspect, the third indication information further includes information indicating the version number of the interface that the third application needs to call.
第五方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面至第二方面中的任意一种实现方式中的方法。In a fifth aspect, a computer-readable medium is provided, and the computer-readable medium stores program code for device execution, and the program code includes a method for executing any one of the first aspect to the second aspect. .
第六方面,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述第一方面至第二方面中的任意一种实现方式中的方法。In a sixth aspect, a computer program product containing instructions is provided. When the computer program product runs on a computer, the computer executes the method in any one of the foregoing first aspect to the second aspect.
第七方面,提供一种芯片,所述芯片包括处理器与数据接口,所述处理器通过所述数 据接口读取存储器上存储的指令,执行上述第一方面至第二方面中的任意一种实现方式中的方法。In a seventh aspect, a chip is provided. The chip includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface, and executes any one of the first aspect to the second aspect described above. The method in the implementation mode.
可选地,作为一种实现方式,所述芯片还可以包括存储器,所述存储器中存储有指令,所述处理器用于执行所述存储器上存储的指令,当所述指令被执行时,所述处理器用于执行第一方面至第二方面中的任意一种实现方式中的方法。Optionally, as an implementation manner, the chip may further include a memory in which instructions are stored, and the processor is configured to execute instructions stored on the memory. When the instructions are executed, the The processor is configured to execute the method in any one of the implementation manners of the first aspect to the second aspect.
图1是本申请实施例提供的一种电子设备的硬件结构示意图。FIG. 1 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
图2是本申请实施例提供的一种电子设备的软件结构示意图。Fig. 2 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
图3是本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 3 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
图4是本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 4 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
图5是本申请实施例提供的一种硬件接口集合的示意性框图。Fig. 5 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
图6是本申请实施例提供的一种硬件接口集合的示意性框图。Fig. 6 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
图7是本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 7 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
图8是本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 8 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the present application.
图9是本申请实施例提供的一种硬件接口集合的示意性框图。Fig. 9 is a schematic block diagram of a set of hardware interfaces provided by an embodiment of the present application.
图10是本申请实施例提供的一种电子设备的软件结构示意图。FIG. 10 is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
图11是本申请实施例提供的一种硬件接口层的软件结构示意图。FIG. 11 is a schematic diagram of a software structure of a hardware interface layer provided by an embodiment of the present application.
图12是本申请实施例提供的电子设备的示意性框图。Fig. 12 is a schematic block diagram of an electronic device provided by an embodiment of the present application.
下面将结合附图,对本申请中的技术方案进行描述。The technical solution in this application will be described below in conjunction with the accompanying drawings.
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个、两个或两个以上。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to limit the application. As used in the specification and appended claims of this application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also This includes expressions such as "one or more" unless the context clearly indicates to the contrary. It should also be understood that in the following embodiments of the present application, "at least one" and "one or more" refer to one, two, or more than two. The term "and/or" is used to describe the association relationship of associated objects, indicating that there can be three types of relationships; for example, A and/or B can mean: A alone exists, A and B exist at the same time, and B exists alone. Among them, A and B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in an "or" relationship.
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。References described in this specification to "one embodiment" or "some embodiments", etc. mean that one or more embodiments of the present application include a specific feature, structure, or characteristic described in conjunction with the embodiment. Therefore, the sentences "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless it is specifically emphasized otherwise. The terms "including", "including", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
以下介绍了本申请实施例提供的电子设备、用于这样的电子设备的用户界面、和用于使用这样的电子设备的实施例。在一些实施例中,电子设备可以是还包含其它功能诸如个人数字助理和/或音乐播放器功能的便携式电子设备,诸如手机、平板电脑、具备无线通 讯功能的可穿戴电子设备(如智能手表)、视频播放器等。便携式电子设备的示例性实施例包括但不限于搭载 或者其它操作系统的便携式电子设备。上述便携式电子设备也可以是其它便携式电子设备,诸如膝上型计算机(Laptop)等。还应当理解的是,在其他一些实施例中,上述电子设备也可以不是便携式电子设备,而是台式计算机、电视、笔记本电脑。 The following introduces the electronic device provided by the embodiments of the present application, the user interface used for such electronic device, and the embodiments for using such electronic device. In some embodiments, the electronic device may be a portable electronic device that also contains other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, and a wearable electronic device with wireless communication function (such as a smart watch) , Video player, etc. Exemplary embodiments of portable electronic devices include, but are not limited to, carrying Or portable electronic devices with other operating systems. The above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer (Laptop) and the like. It should also be understood that, in some other embodiments, the above-mentioned electronic device may not be a portable electronic device, but a desktop computer, a TV, or a notebook computer.
示例性的,图1示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。Exemplarily, FIG. 1 shows a schematic structural diagram of an
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的部件,也可以集成在一个或多个处理器中。在一些实施例中,电子设备101也可以包括一个或多个处理器110。其中,控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。在其他一些实施例中,处理器110中还可以设置存储器,用于存储指令和数据。示例性地,处理器110中的存储器可以为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。这样就避免了重复存取,减少了处理器110的等待时间,因而提高了电子设备101处理数据或执行指令的效率。The
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路间(inter-integrated circuit,I2C)接口,集成电路间音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,SIM卡接口,和/或USB接口等。其中,USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备101充电,也可以用于电子设备101与外围设备之间传输数据。该USB接口130也可以用于连接耳机,通过耳机播放音频。In some embodiments, the
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present application is merely a schematic description, and does not constitute a structural limitation of the
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used to connect the battery 142, the
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或多个显示屏194。The display screen 194 is used to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode). AMOLED, flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc. In some embodiments, the
电子设备100的显示屏194可以是一种柔性屏,目前,柔性屏以其独特的特性和巨大的潜力而备受关注。柔性屏相对于传统屏幕而言,具有柔韧性强和可弯曲的特点,可以给用户提供基于可弯折特性的新交互方式,可以满足用户对于电子设备的更多需求。对于配置有可折叠显示屏的电子设备而言,电子设备上的可折叠显示屏可以随时在折叠形态下的小屏和展开形态下大屏之间切换。因此,用户在配置有可折叠显示屏的电子设备上使用分屏功能,也越来越频繁。The display screen 194 of the
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye. ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或多个摄像头193。The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and is projected to the photosensitive element. The photosensitive element may 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 transfers the electrical signal to the ISP to convert it into a digital image signal. ISP outputs digital image signals to DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals. In some embodiments, the
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, for example, the transfer mode between human brain neurons, it can quickly process input information, and it can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The
内部存储器121可以用于存储一个或多个计算机程序,该一个或多个计算机程序包括指令。处理器110可以通过运行存储在内部存储器121的上述指令,从而使得电子设备101执行本申请一些实施例中所提供的灭屏显示的方法,以及各种应用以及数据处理等。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统; 该存储程序区还可以存储一个或多个应用(比如图库、联系人等)等。存储数据区可存储电子设备101使用过程中所创建的数据(比如照片,联系人等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如一个或多个磁盘存储部件,闪存部件,通用闪存存储器(universal flash storage,UFS)等。在一些实施例中,处理器110可以通过运行存储在内部存储器121的指令,和/或存储在设置于处理器110中的存储器的指令,来使得电子设备101执行本申请实施例中所提供的灭屏显示的方法,以及其他应用及数据处理。电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The internal memory 121 may be used to store one or more computer programs, and the one or more computer programs include instructions. The
传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and an ambient light sensor 180L,
其中,压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。Among them, the pressure sensor 180A is used to sense a pressure signal, and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be provided on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors and so on. The capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,X,Y和Z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B may be used to determine the movement posture of the
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。The acceleration sensor 180E can detect the magnitude of the acceleration of the
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。The ambient light sensor 180L is used to sense the brightness of the ambient light. The
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。The fingerprint sensor 180H is used to collect fingerprints. The
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。The temperature sensor 180J is used to detect temperature. In some embodiments, the
触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Touch sensor 180K, also called "touch panel". The touch sensor 180K may be disposed on the display screen 194, and the touch screen is composed of the touch sensor 180K and the display screen 194, which is also called a “touch screen”. The touch sensor 180K is used to detect touch operations 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. The visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K may also be disposed on the surface of the
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The button 190 includes a power-on button, a volume button, and so on. The button 190 may be a mechanical button. It can also be a touch button. The
图2是本申请实施例的电子设备100的软件结构框图。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用层,应用框架层,安卓运行时(Android runtime)和系统库。如图2所示,软件架构中的各层可以调用硬件层,硬件层可以包括图1中的多个硬件。FIG. 2 is a software structure block diagram of the
应用层可以包括一系列应用包。如图2所示,应用包可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等应用。The application layer can include a series of application packages. As shown in Figure 2, the application package may include applications such as music playback, video playback, reading applications, application market, gallery, calendar, call, map, and navigation.
应用框架层为应用层的应用提供应用编程接口(application programming interface,API)和编程框架。应用框架层包括一些预先定义的函数。如图2所示,应用框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。内容提供器用来存放和获取数据,并使这些数据可以被应用访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。资源管理器为应用提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。通知管理器使应用可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The application framework layer provides application programming interfaces (application programming interface, API) and programming frameworks for applications at the application layer. The application framework layer includes some predefined functions. As shown in Figure 2, the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager. The window manager is used to manage window programs. The window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc. The content provider is used to store and retrieve data, and make these data accessible to applications. The data may include videos, images, audios, phone calls made and received, browsing history and bookmarks, phone book, etc. The view system includes visual controls, such as controls that display text, controls that display pictures, and so on. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures. The phone manager is used to provide the communication function of the
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。 核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。应用层和应用框架层运行在虚拟机中。虚拟机将应用层和应用框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system. The core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android. The application layer and the application framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(media libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。表面管理器用于对显示子系统进行管理,并且为多个应用提供了2D和3D图层的融合。媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。2D图形引擎是2D绘图的绘图引擎。The system library can include multiple functional modules. For example: surface manager (surface manager), media library (media libraries), 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc. The surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.
硬件层可以包括多个硬件,例如图1中的显示屏194、摄像头193、音频模块170、传感器模块,其中传感器模块可以包括例如图1中的陀螺仪传感器180B、指纹传感器180H等。应用层、应用框架层、安卓运行时(Android runtime)和系统库均可以通过调用硬件接口来调用硬件层中的硬件。例如,应用层通过调用显示接口调用显示屏194。The hardware layer may include multiple hardware, such as the display screen 194, the camera 193, the
在系统层与硬件层之间还可以包括硬件接口层,硬件接口层包括用于驱动硬件的多个接口。例如驱动显示屏的接口、驱动摄像头的接口、驱动音频模块的接口、驱动陀螺仪传感器的接口、驱动指纹传感器的接口等。A hardware interface layer may also be included between the system layer and the hardware layer, and the hardware interface layer includes multiple interfaces for driving the hardware. For example, the interface that drives the display screen, the interface that drives the camera, the interface that drives the audio module, the interface that drives the gyroscope sensor, the interface that drives the fingerprint sensor, and so on.
当电子设备内部的处理器或芯片读取应用程序层中的应用的代码时,可以通过调用硬件接口,从而驱动硬件层中的硬件,并执行相应的操作。When the processor or chip inside the electronic device reads the code of the application in the application layer, it can call the hardware interface to drive the hardware in the hardware layer and perform corresponding operations.
在一个示例中,可以通过调用移动通信接口从而驱动用于移动通信的天线,并可以通过该用于移动通信的天线传输上下行通信数据。例如,处理器或芯片在运行通话应用时,可以读取该通话应用中的代码,从而可以调用移动通信接口,通过驱动用于移动通信的天线,实现语音通话功能。In an example, the antenna used for mobile communication can be driven by calling the mobile communication interface, and the uplink and downlink communication data can be transmitted through the antenna used for mobile communication. For example, when the processor or chip is running the call application, it can read the code in the call application, so that the mobile communication interface can be called, and the voice call function can be realized by driving the antenna for mobile communication.
在一个示例中,可以通过调用屏幕显示接口从而驱动显示屏,并可以在显示屏上显示图像。例如,处理器或芯片在运行视频播放应用时,可以读取该视频播放应用中的代码,从而可以调用屏幕显示接口,并在显示屏上播放视频。In an example, the display screen can be driven by calling the screen display interface, and images can be displayed on the display screen. For example, when the processor or chip is running a video playback application, it can read the code in the video playback application, so that it can call the screen display interface and play the video on the display screen.
在一个示例中,可以通过调用扬声器接口从而驱动扬声器,并可以通过扬声器播放声音;或者,可以通过调用耳机接口,从而驱动(外部连接的)耳机,并可以通过该耳机播放声音。例如,处理器或芯片在运行音频播放应用时,可以读取该音频播放应用中的代码,从而可以调用扬声器接口,并通过扬声器播放音频文件,或者可以调用耳机接口,并通过(外部连接的)耳机播放音频文件。In one example, the speaker can be driven by calling the speaker interface, and sound can be played through the speaker; or, the earphone (connected externally) can be driven by calling the earphone interface, and the sound can be played through the earphone. For example, when the processor or chip is running an audio playback application, it can read the code in the audio playback application, so that it can call the speaker interface and play audio files through the speaker, or it can call the headphone interface and pass the (externally connected) The headset plays audio files.
在一个示例中,可以通过调用指纹识别接口从而驱动指纹识别模块,并可以通过指纹识别模块识别指纹。例如,处理器或芯片在运行安全应用时,可以读取该安全应用中的代码,从而可以调用指纹识别接口,并在指纹识别模块反馈的指纹与预设指纹信息匹配时,认为当前电子设备的操作是安全的。In an example, the fingerprint identification module can be driven by calling the fingerprint identification interface, and the fingerprint can be identified by the fingerprint identification module. For example, when the processor or chip is running a security application, it can read the code in the security application, so that the fingerprint identification interface can be called, and when the fingerprint fed back by the fingerprint identification module matches the preset fingerprint information, the current electronic device's The operation is safe.
在一个示例中,可以通过调用位置定位接口从而驱动全球定位系统(global positioning system,GPS)天线,并可以通过该GPS天线确定电子设备的当前位置。例如,处理器或芯片在运行地图导航应用时,可以读取该地图导航应用中的代码,从而可以调用定位接口, 并通过GPS天线反馈的定位信息规划行车路径。In an example, a global positioning system (GPS) antenna can be driven by calling a position positioning interface, and the current position of the electronic device can be determined through the GPS antenna. For example, when the processor or chip is running a map navigation application, it can read the code in the map navigation application, so that the positioning interface can be called, and the driving route can be planned through the positioning information fed back by the GPS antenna.
在一个示例中,可以通过调用无线通信接口从而驱动蓝牙天线,并可以通过该蓝牙天线从其他电子设备接收数据,或向其他电子设备发送数据。例如,处理器或芯片在运行文件传输应用时,可以读取该文件传输应用中的代码,从而可以调用无线通信接口,并通过蓝牙天线向邻近的电子设备发送文件,或者接收邻近的电子设备发送的文件。In an example, the Bluetooth antenna can be driven by calling the wireless communication interface, and data can be received from other electronic devices through the Bluetooth antenna, or data can be sent to other electronic devices. For example, when the processor or chip is running a file transfer application, it can read the code in the file transfer application, so that it can call the wireless communication interface, and send a file to or receive a file from a neighboring electronic device through a Bluetooth antenna. document.
在一个示例中,可以通过调用拍摄接口从而驱动摄像头,并可以通过摄像头捕捉图像或拍摄视频。例如,处理器或芯片在运行拍摄应用时,可以读取该拍摄应用中的代码,从而可以调用前置拍摄接口,并通过前置摄像头拍摄人像。In one example, the camera can be driven by calling the shooting interface, and an image or video can be captured by the camera. For example, when the processor or the chip is running the shooting application, it can read the code in the shooting application, so that the front-facing shooting interface can be called, and a portrait can be taken through the front-facing camera.
图3所示为针对两种不同类型设备的开发软件的架构示意图。图3中的设备的类型例如可以包括手机、平板电脑、具备无线通讯功能的可穿戴电子设备(如智能手表)、视频播放器台式计算机、电视、笔记本电脑等。例如,图3中的设备一可以是手机,设备二可以是电视。Figure 3 shows the schematic diagram of the development software for two different types of equipment. The types of devices in FIG. 3 may include, for example, mobile phones, tablet computers, wearable electronic devices with wireless communication functions (such as smart watches), video player desktop computers, TVs, notebook computers, and so on. For example, the first device in FIG. 3 may be a mobile phone, and the second device may be a TV.
设备一的硬件接口一可以调用硬件一。设备二的硬件接口二可以调用硬件二。但由于各种原因(例如不同设备的硬件通常是来自不同的硬件生产厂商,或者不同电子设备的针对硬件接口的设计方案不同),硬件接口一与硬件接口二不同,因此不能使用同样的程序既实现硬件接口一的调用,又实现硬件接口二的调用。例如,手机的显示屏和电视的屏幕均可以用于播放视频、显示图片,然而手机的显示屏和电视的屏幕可以由不同的屏幕生产厂商生产,因此手机显示屏的接口与电视屏幕的接口不同,即不能使用同样的程序既实现手机显示屏的接口的调用,又实现电视屏幕的接口的调用。The hardware interface one of device one can call hardware one. The hardware interface two of the device two can call the hardware two. However, due to various reasons (for example, the hardware of different devices is usually from different hardware manufacturers, or the design schemes for hardware interfaces of different electronic devices are different), the hardware interface one is different from the hardware interface two, so the same program cannot be used. Implement the call of hardware interface one, and implement the call of hardware interface two. For example, both the mobile phone’s display screen and the TV’s screen can be used to play videos and display pictures. However, the mobile phone’s display screen and the TV’s screen can be produced by different screen manufacturers, so the interface of the mobile phone’s display screen is different from that of the TV screen. That is, the same program cannot be used to call the interface of the mobile phone display screen and the interface of the TV screen as well.
系统软件通常是设备生产厂商在电子设备出厂前就安装并加载在电子设备上的程序。由于设备一的硬件接口一与设备二的硬件接口二不同,因此设备一的系统软件与设备二的系统软件不同。The system software is usually a program installed and loaded on the electronic device by the device manufacturer before the electronic device leaves the factory. Since the hardware interface one of the device one is different from the hardware interface two of the device two, the system software of the device one is different from the system software of the device two.
设备厂商为了便利应用开发商,通常将软件开发工具包(software development kit,SDK)开放给应用开发商,便于应用开发商针对设备类型开发应用软件。其中,SDK就包含了快捷调用硬件接口的代码。由于设备一的硬件接口一与设备二的硬件接口二不同,因此设备一的SDK与设备二的SDK不同。In order to facilitate application developers, device manufacturers usually open software development kits (SDK) to application developers to facilitate application developers to develop application software for device types. Among them, the SDK contains the code to quickly call the hardware interface. Since the hardware interface 1 of the device one is different from the hardware interface two of the device two, the SDK of the device one is different from the SDK of the device two.
假设某个应用开发商希望开发一套应用,例如视频播放软件、地图导航软件、通话软件、系统应用等。为了可以在设备一和设备二(如图3)上均可以实现该套应用的功能,需要针对设备一和设备二,分别开发相同类型的两个不同的应用。例如,用于手机的视频播放软件1,和用于电视的视频播放软件2。其中,该相同类型的两个不同的应用可以指,该两个应用可以包括用于设备一的应用一和用于设备二的应用二,应用一与应用二的功能相同或者主要功能相同;但在实现该相同功能或相同的主要功能时,应用一与应用二所使用的代码、调用的接口和/或函数等不同,因此应用一通常不能应用在设备二上,应用二通常不能应用在设备一上,应用一与应用二是两个不同的应用。Suppose an application developer wants to develop a set of applications, such as video playback software, map navigation software, call software, system applications, etc. In order to implement the functions of this set of applications on both device one and device two (as shown in Figure 3), it is necessary to develop two different applications of the same type for device one and device two respectively. For example, video playback software 1 for mobile phones, and video playback software 2 for TVs. Wherein, the two different applications of the same type may refer to that the two applications may include application one for device one and application two for device two, and the functions of application one and application two are the same or the main functions are the same; but When implementing the same function or the same main function, the code, interface and/or function used by application one and application two are different, so application one usually cannot be applied to device two, and application two usually cannot be applied to device First, application one and application two are two different applications.
应用开发商通常希望有多数用户可以使用该应用开发商所开发的应用,因此应用开发商必须兼顾市面上的主流设备,针对多种类型的设备分别设计应用包。本申请提供一种方法,目的在于提升应用开发的便捷性。Application developers usually hope that most users can use the applications developed by the application developers. Therefore, application developers must take into account the mainstream devices on the market and design application packages for multiple types of devices. This application provides a method aimed at improving the convenience of application development.
图4为本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 4 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
401,读取第一应用的代码中的第一指示信息,所述第一指示信息用于指示第一硬件 接口集合的相关信息,所述第一硬件接口集合包括多个电子设备的硬件接口,所述第一硬件接口集合中的任意两个硬件接口的类型相同,或者,所述第一硬件接口集合中的任意两个硬件接口的部分或全部功能相同。401. Read first indication information in a code of a first application, where the first indication information is used to indicate related information of a first hardware interface set, where the first hardware interface set includes hardware interfaces of multiple electronic devices. The types of any two hardware interfaces in the first hardware interface set are the same, or part or all of the functions of any two hardware interfaces in the first hardware interface set are the same.
在本申请中,第一应用例如可以是通话应用、视频播放应用、音频播放应用、安全应用、地图导航应用、文件传输应用、拍摄应用等。第一应用还可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等。本申请对第一应用的具体类型不作限定。In this application, the first application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on. The first application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the first application.
第一硬件接口集合包括多个电子设备的硬件接口,该多个电子设备的类型例如可以包括手机、平板电脑、智能手表、视频播放器、膝上型计算机(Laptop)、台式计算机、电视、笔记本电脑中的至少两个。The first set of hardware interfaces includes hardware interfaces of multiple electronic devices. The types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
应理解,第一应用调用硬件接口时可以通过代码驱动硬件,因此,第一硬件接口集合可以通过代码的形式存储在处理器或存储器中。硬件接口可以通过代码实现硬件调用,因此,可以使用代码来定义硬件接口。例如,在安卓系统中,可以使用硬件接口定义语言(hardware interface definition language,HIDL)定义硬件接口。又如,可以使用HIDL语言调用java格式的代码,实现硬件接口的调用。It should be understood that when the first application calls the hardware interface, the hardware may be driven by code. Therefore, the first set of hardware interfaces may be stored in the processor or memory in the form of code. The hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface. For example, in the Android system, a hardware interface definition language (HDL) can be used to define a hardware interface. For another example, HIDL language can be used to call java format code to implement the call of the hardware interface.
电子设备可以包括用于识别设备类型的软件模块或硬结模块。例如,电子设备可以电子设备的版本号、型号等,从而调用该电子设备的硬件。The electronic device may include a software module or a hard-wired module for identifying the type of the device. For example, the electronic device can use the version number, model, etc. of the electronic device to call the hardware of the electronic device.
通常情况下,不同类型的电子设备所具有的硬件接口通常不同,如手机所具有的硬件接口与手表所具有的硬件接口不同,手表所具有的硬件接口与电视所具有的硬件接口不同,手机所具有的硬件接口与电视所具有的硬件接口不同。Under normal circumstances, different types of electronic devices have different hardware interfaces. For example, the hardware interface of a mobile phone is different from that of a watch, and the hardware interface of a watch is different from that of a TV. The hardware interface is different from the hardware interface of the TV.
相同类型的不同电子设备所具有的硬件接口可以相同,也可以不同。例如,相同版本号的两个手机所具有的硬件接口可以相同,版本号的两个手机所具有的硬件接口可以不同。The hardware interfaces of different electronic devices of the same type may be the same or different. For example, two mobile phones with the same version number may have the same hardware interfaces, and two mobile phones with the same version number may have different hardware interfaces.
电子设备可以识别芯片的类型,从而调用包括该芯片的硬件,或者确定包括该芯片的硬件的硬件接口。又如,电子设备可以识别硬件的版本号或型号,从而确定是否调用该硬件,或者确定该硬件的硬件接口。The electronic device can identify the type of the chip, so as to call the hardware including the chip, or determine the hardware interface of the hardware including the chip. For another example, the electronic device can identify the version number or model of the hardware to determine whether to call the hardware or determine the hardware interface of the hardware.
在一个示例中,第一硬件接口集合中的任意两个硬件接口的类型相同。例如,第一硬件接口集合中的所有硬件接口均为移动通信接口。又如,第一硬件接口集合中的所有硬件接口均为屏幕显示接口。又如,第一硬件接口集合中的所有硬件接口均为扬声器接口。又如,第一硬件接口集合中的所有硬件接口均为耳机接口。又如,第一硬件接口集合中的所有硬件接口均为指纹识别接口。又如,第一硬件接口集合中的所有硬件接口均为定位接口。又如,第一硬件接口集合中的所有硬件接口均为无线通信接口。又如,第一硬件接口集合中的所有硬件接口均为拍摄接口。In an example, any two hardware interfaces in the first set of hardware interfaces are of the same type. For example, all the hardware interfaces in the first hardware interface set are mobile communication interfaces. For another example, all hardware interfaces in the first hardware interface set are screen display interfaces. For another example, all the hardware interfaces in the first hardware interface set are speaker interfaces. In another example, all the hardware interfaces in the first hardware interface set are earphone interfaces. For another example, all hardware interfaces in the first hardware interface set are fingerprint identification interfaces. For another example, all hardware interfaces in the first hardware interface set are positioning interfaces. For another example, all hardware interfaces in the first hardware interface set are wireless communication interfaces. In another example, all hardware interfaces in the first set of hardware interfaces are shooting interfaces.
在第一硬件接口集合中的任意两个硬件接口的类型相同的情况下,第一硬件接口集合的类型与第一硬件接口集合中的任一硬件接口的类型相同。例如,第一硬件接口集合中的所有硬件接口均为移动通信接口,第一硬件接口集合的类型可以是移动通信接口。In the case that any two hardware interfaces in the first hardware interface set are of the same type, the type of the first hardware interface set is the same as the type of any hardware interface in the first hardware interface set. For example, all hardware interfaces in the first hardware interface set are mobile communication interfaces, and the type of the first hardware interface set may be mobile communication interfaces.
第一硬件接口集合中的任意两个硬件接口的部分功能相同。例如,第一硬件接口集合中的所有硬件接口均可以用于语音通话,而由于移动通信标准不同,该第一硬件接口集合中的第一部分硬件接口可以在全球移动通信(global system for mobile communications, GSM)系统中工作,该第一硬件接口集合中的第二部分硬件接口既可以在全球移动通信(global system for mobile communications,GSM)系统中工作,也可以在码分多址(code division multiple access,CDMA)系统中工作。又如,第一硬件接口集合中的所有硬件接口均可以用于蓝牙文件传输,而由于无线通信标准不同,该第一硬件接口集合中的第一部分硬件接口可以用于驱动蓝牙2.0,该第一硬件接口集合中的第二部分硬件接口可以用于驱动蓝牙4.0。又如,第一硬件接口集合中的所有硬件接口均可以用于播放音频,而用于播放音频的接口包括用于驱动扬声器的扬声器接口,和用于驱动耳机的耳机接口,因此第一硬件接口集合中的第一部分硬件接口可以用于驱动扬声器,第二部分硬件接口可以用于驱动耳机。又如,第一硬件接口集合中的所有硬件接口均可以用于视频输入,而高清多媒体接口(high definition multimedia interface,HDMI)可以用于音频输入与视频输入,而视频图形阵列(video graphics array,VGA)接口仅用于视频输入,因此第一硬件接口集合中的第一部分硬件接口可以是仅用于视频输入的接口,第二部分硬件接口可以是既用于音频输入,又用于视频输入的接口。又如,第一硬件接口集合中的所有硬件接口均可以用于拍摄图像或视频,而摄像头又分为前置摄像头和后置摄像头,因此第一硬件接口集合中的第一部分硬件接口可以用于驱动前置摄像头,第二部分硬件接口可以用于驱动后置摄像头。Part of the functions of any two hardware interfaces in the first hardware interface set are the same. For example, all hardware interfaces in the first hardware interface set can be used for voice calls, and due to different mobile communication standards, the first part of the hardware interfaces in the first hardware interface set can be used in global system for mobile communications, GSM) system, the second part of the hardware interface in the first set of hardware interfaces can work in the global system for mobile communications (GSM) system, or in code division multiple access , CDMA) system. For another example, all hardware interfaces in the first hardware interface set can be used for Bluetooth file transfer, and due to different wireless communication standards, the first part of the hardware interfaces in the first hardware interface set can be used to drive Bluetooth 2.0. The second part of the hardware interface set can be used to drive Bluetooth 4.0. For another example, all hardware interfaces in the first hardware interface set can be used to play audio, and the interfaces used to play audio include a speaker interface for driving speakers and a headphone interface for driving headphones. Therefore, the first hardware interface The first part of the hardware interface in the set can be used to drive speakers, and the second part of the hardware interface can be used to drive headphones. For another example, all the hardware interfaces in the first hardware interface set can be used for video input, while the high definition multimedia interface (HDMI) can be used for audio input and video input, and the video graphics array (video graphics array, The VGA) interface is only used for video input. Therefore, the first part of the hardware interface in the first hardware interface set can be the interface only for video input, and the second part of the hardware interface can be used for both audio input and video input. interface. For another example, all the hardware interfaces in the first hardware interface set can be used to capture images or videos, and the cameras are divided into front cameras and rear cameras, so the first part of the hardware interfaces in the first hardware interface set can be used for Drive the front camera, the second part of the hardware interface can be used to drive the rear camera.
在第一硬件接口集合中的任意两个硬件接口的部分功能相同的情况下,第一硬件接口集合的功能包括第一硬件接口集合中的任一硬件接口的功能。例如,第一硬件接口集合中的所有硬件接口均可以用于语音通话,第一硬件接口集合的功能包括语音通话。In the case where the partial functions of any two hardware interfaces in the first hardware interface set are the same, the function of the first hardware interface set includes the function of any hardware interface in the first hardware interface set. For example, all hardware interfaces in the first hardware interface set can be used for voice calls, and the functions of the first hardware interface set include voice calls.
第一硬件接口集合中的任意两个硬件接口的全部功能相同。例如,第一硬件接口集合中的所有硬件接口均可以用于语音通话,且均可以既可以在全球移动通信(global system for mobile communications,GSM)系统中工作,又可以在码分多址(code division multiple access,CDMA)系统中工作,且第一硬件接口集合中的任一硬件接口所实现的全部功能,也能够被第一硬件接口集合中的其他硬件接口实现。又如,第一硬件接口集合中的所有硬件接口都可以用于驱动蓝牙4.0。又如,第一硬件接口集合中的所有硬件接口均可以用于播放音频,且均用于驱动耳机。又如,第一硬件接口集合中的所有硬件接口均可以用于视频输入,且均可以用于音频输入。又如,第一硬件接口集合中的所有硬件接口均可以用于拍摄图像或视频,且均用于驱动前置摄像头。All functions of any two hardware interfaces in the first hardware interface set are the same. For example, all the hardware interfaces in the first set of hardware interfaces can be used for voice calls, and all can work in the global system for mobile communications (GSM) system, or in code division multiple access (code division multiple access). Division multiple access (CDMA) system works, and all functions implemented by any hardware interface in the first hardware interface set can also be implemented by other hardware interfaces in the first hardware interface set. For another example, all hardware interfaces in the first hardware interface set can be used to drive Bluetooth 4.0. For another example, all the hardware interfaces in the first set of hardware interfaces can be used to play audio, and all of them can be used to drive headphones. For another example, all the hardware interfaces in the first hardware interface set can be used for video input, and all can be used for audio input. For another example, all the hardware interfaces in the first hardware interface set can be used to capture images or videos, and all are used to drive the front camera.
在第一硬件接口集合中的任意两个硬件接口的全部功能相同的情况下,第一硬件接口集合的功能与第一硬件接口集合中的任一硬件接口的功能相同。例如,第一硬件接口集合中的所有硬件接口均可以用于语音通话,第一硬件接口集合的功能为语音通话。In the case where all the functions of any two hardware interfaces in the first hardware interface set are the same, the function of the first hardware interface set is the same as the function of any hardware interface in the first hardware interface set. For example, all hardware interfaces in the first hardware interface set can be used for voice calls, and the function of the first hardware interface set is voice calls.
通常,任意两个硬件接口的类型相同,该任意两个硬件接口所能够实现的功能通常是相同或者是近似的。Generally, any two hardware interfaces are of the same type, and the functions that can be implemented by the any two hardware interfaces are usually the same or similar.
第一硬件接口集合可以包括某一类电子设备的多个硬件接口。例如,电子设备包括前置摄像头和后置摄像头,该第一硬件接口集合可以包括用于驱动前置摄像的硬件接口1,又包括用于驱动后置摄像头的硬件接口2。又如,电子设备包括多个多媒体传输接口,分别用于支持不同的多媒体传输标准(如HDMI、VGA)。The first set of hardware interfaces may include multiple hardware interfaces of a certain type of electronic device. For example, the electronic device includes a front camera and a rear camera, and the first set of hardware interfaces may include a hardware interface 1 for driving the front camera and a hardware interface 2 for driving the rear camera. For another example, the electronic device includes multiple multimedia transmission interfaces, which are respectively used to support different multimedia transmission standards (such as HDMI and VGA).
图5为第一硬件接口集合中的硬件接口的示意图。第一硬件接口集合包括硬件接口1、硬件接口2、硬件接口3、硬件接口4。其中,硬件接口1、硬件接口2为电子设备501所 具有的硬件接口。硬件接口3为电子设备502所具有的硬件接口。硬件接口3、硬件接口4为电子设备503所具有的硬件接口。Fig. 5 is a schematic diagram of the hardware interfaces in the first set of hardware interfaces. The first set of hardware interfaces includes hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4. Among them, the hardware interface 1 and the hardware interface 2 are hardware interfaces of the
可以看出,不同的电子设备的硬件接口可以相同。例如,版本号为版本号1的手机1使用硬件1,版本号为版本号2的手机2使用硬件2,硬件1与硬件2来自同一硬件厂商,且硬件1与硬件2为同一型号的硬件,因此手机1和手机2可以具有相同的硬件接口。It can be seen that the hardware interfaces of different electronic devices can be the same. For example, mobile phone 1 with version number 1 uses hardware 1, mobile phone 2 with version number 2 uses hardware 2, hardware 1 and hardware 2 are from the same hardware manufacturer, and hardware 1 and hardware 2 are the same type of hardware. Therefore, the mobile phone 1 and the mobile phone 2 may have the same hardware interface.
根据上文的描述,第一硬件接口集合可以包括类型相同的多个硬件接口,且包括多个电子设备的硬件接口。以图5为例,硬件接口1、硬件接口2、硬件接口3、硬件接口4可以均为拍摄接口,电子设备501可以是手机,电子设备502可以是手表,电子设备503可以是平板电脑。其中,电子设备501所具有的硬件接口1可以是用于调用前置摄像头的拍摄接口,电子设备501所具有的硬件接口2可以是用于调用后置摄像头的拍摄接口。电子设备503所具有的硬件接口3可以是用于调用前置摄像头的拍摄接口,电子设备503所具有的硬件接口4可以是用于调用后置摄像头的拍摄接口。电子设备502所具有的硬件接口3与电子设备503所具有的硬件接口3相同。类似地,根据上文的描述,第一硬件接口集合可以包括部分或全部功能相同的多个硬件接口,且包括多个电子设备的硬件接口。According to the above description, the first set of hardware interfaces may include multiple hardware interfaces of the same type, and include hardware interfaces of multiple electronic devices. Taking FIG. 5 as an example, the hardware interface 1, the hardware interface 2, the hardware interface 3, and the hardware interface 4 may all be shooting interfaces. The
可选的,第一指示信息包括指示第二硬件接口的信息,且所述电子设备不具有所述第二硬件接口,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将所述第二硬件接口所属于的硬件接口集合确定为所述第一硬件接口集合。Optionally, the first indication information includes information indicating a second hardware interface, and the electronic device does not have the second hardware interface, and the first hardware interface is collected from the first hardware interface according to the first indication information. Before determining at least one first hardware interface possessed by the electronic device, the method further includes: determining, according to the first indication information, the set of hardware interfaces to which the second hardware interface belongs as the first hardware interface set.
电子设备可以存储第一硬件接口集合的相关信息,该相关信息包括第一硬件接口集合的标识以及该第一硬件接口集合中的多个硬件接口的信息(如每个硬件接口的标识、调用参数等),该多个硬件接口包括该第二硬件接口。例如,可以保存图5所示的第一硬件接口集合的标识,和硬件接口1的标识、硬件接口2的标识、硬件接口3的标识、硬件接口4的标识,以及第一硬件接口集合分别与硬件接口1、硬件接口2、硬件接口3、硬件接口4之间的对应关系。在电子设备501读取第一应用的代码中的第一指示信息,且该第一指示信息指示图5中的硬件接口3时,由于电子设备501不具有硬件接口3,电子设备501无法调用硬件接口3,而电子设备501可以根据第一指示信息以及第一硬件接口集合的相关信息,确定硬件接口3与第一硬件接口集合之间存在对应关系,从而确定该第一硬件接口集合。The electronic device may store related information of the first hardware interface set, and the related information includes the identification of the first hardware interface set and the information of multiple hardware interfaces in the first hardware interface set (such as the identification of each hardware interface, the call parameter Etc.), the multiple hardware interfaces include the second hardware interface. For example, the identification of the first hardware interface set shown in FIG. 5, and the identification of hardware interface 1, the identification of hardware interface 2, the identification of hardware interface 3, the identification of hardware interface 4, and the identification of the first hardware interface set can be saved, respectively. Correspondence between hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4. When the
图6所示为多个硬件接口集合的示意图。电子设备可以存储有多个硬件接口集合的相关信息,该多个硬件接口集合包括图6所示的硬件接口集合601、硬件接口集合602。Figure 6 shows a schematic diagram of a set of multiple hardware interfaces. The electronic device may store related information of multiple hardware interface sets, and the multiple hardware interface sets include the hardware interface set 601 and the hardware interface set 602 shown in FIG. 6.
在一个示例中,硬件接口集合601的类型为类型1,硬件接口集合602的类型为类型2。In an example, the type of the hardware interface set 601 is type 1, and the type of the hardware interface set 602 is type 2.
第一指示信息包括指示所述第一应用需要调用的硬件接口的第一类型的信息,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将与所述第一类型匹配的硬件接口集合确定为所述第一硬件接口集合。The first indication information includes information indicating the first type of the hardware interface that the first application needs to call. According to the first indication information, it is determined from the first hardware interface set that the electronic device has at least Before a first hardware interface, the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first type as the first hardware interface set.
所述第一硬件接口集合与第一类型匹配,一种可能的情况是,所述第一硬件接口集合的类型为该第一类型。上文已经详细描述了硬件接口集合的类型,在此就不再赘述。The first hardware interface set matches the first type, and a possible situation is that the type of the first hardware interface set is the first type. The type of the hardware interface set has been described in detail above, and will not be repeated here.
另一种可能的情况是,所述第一硬件接口集合的功能为与该第一类型所实现的功能相 同或相似。Another possible situation is that the function of the first hardware interface set is the same or similar to the function implemented by the first type.
例如,第一指示信息指示的类型为移动通信接口,第一硬件接口集合的功能包括语音通话功能,移动通信接口也能够实现该语音通话功能,因此所述第一硬件接口集合与第一类型匹配。For example, the type indicated by the first indication information is a mobile communication interface, the function of the first hardware interface set includes a voice call function, and the mobile communication interface can also implement the voice call function, so the first hardware interface set matches the first type .
又如,第一指示信息指示的类型为屏幕显示接口,第一硬件接口集合的功能包括在屏幕上显示图像的功能,屏幕显示接口也能够实现该在屏幕上显示图像的功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a screen display interface, and the functions of the first set of hardware interfaces include the function of displaying images on the screen, and the screen display interface can also realize the function of displaying images on the screen. A set of hardware interfaces matches the first type.
又如,第一指示信息指示的类型为扬声器接口,第一硬件接口集合的功能包括声音播放功能,扬声器接口也能够实现该声音播放功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a speaker interface, the function of the first hardware interface set includes a sound playback function, and the speaker interface can also implement the sound playback function, so the first hardware interface set matches the first type.
又如,第一指示信息指示的类型为耳机接口,第一硬件接口集合的功能包括声音播放功能,耳机接口也能够实现该声音播放功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a headphone interface, the function of the first hardware interface set includes a sound playing function, and the headphone interface can also implement the sound playing function, so the first hardware interface set matches the first type.
又如,第一指示信息指示的类型为指纹识别接口,第一硬件接口集合的功能包括指纹识别功能,指纹识别接口也能够实现该指纹识别功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a fingerprint identification interface, and the function of the first hardware interface set includes a fingerprint identification function, and the fingerprint identification interface can also implement the fingerprint identification function. Therefore, the first hardware interface set and the first type match.
又如,第一指示信息指示的类型为定位接口,第一硬件接口集合的功能包括定位功能,定位接口也能够实现该定位功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a positioning interface, the function of the first hardware interface set includes a positioning function, and the positioning interface can also implement the positioning function, so the first hardware interface set matches the first type.
又如,第一指示信息指示的类型为无线通信接口,第一硬件接口集合的功能包括数据传输功能,无线通信接口也能够实现该数据传输功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a wireless communication interface, and the function of the first hardware interface set includes a data transmission function, and the wireless communication interface can also implement the data transmission function. Therefore, the first hardware interface set and the first type match.
又如,第一指示信息指示的类型为拍摄接口,第一硬件接口集合的功能包括捕捉电子设备周围场景,拍摄接口也能够实现该捕捉电子设备周围场景的功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the type indicated by the first indication information is a shooting interface, and the function of the first hardware interface set includes capturing the scene around the electronic device, and the shooting interface can also realize the function of capturing the scene around the electronic device. Therefore, the first hardware interface set Matches the first type.
因此,在第一应用通过第一指示信息指示调用第一类型的硬件接口的情况下,电子设备可以根据该第一类型确定与该第一类型匹配的该第一硬件接口集合。Therefore, in a case where the first application instructs to invoke the first type of hardware interface through the first indication information, the electronic device may determine the first set of hardware interfaces matching the first type according to the first type.
在一个示例中,硬件接口集合601的功能包括功能1,硬件接口集合602的功能包括功能2。In an example, the function of the hardware interface set 601 includes function 1, and the function of the hardware interface set 602 includes function 2.
可选的,所述第一指示信息包括指示所述第一应用需要调用的硬件接口的第一功能的信息,在所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口之前,所述方法还包括:根据所述第一指示信息,将与所述第一功能匹配的硬件接口集合确定为所述第一硬件接口集合。Optionally, the first indication information includes information indicating the first function of the hardware interface that the first application needs to call, and the first function is determined from the first hardware interface set according to the first indication information Before the at least one first hardware interface of the electronic device, the method further includes: determining, according to the first indication information, a set of hardware interfaces matching the first function as the first set of hardware interfaces.
所述第一硬件接口集合与第一功能匹配,一种可能的情况是,所述第一硬件接口集合的功能包括该第一类型。上文已经详细描述了多种硬件接口集合的功能,在此就不再赘述。The first hardware interface set matches the first function, and a possible situation is that the function of the first hardware interface set includes the first type. The functions of the various hardware interface sets have been described in detail above, and will not be repeated here.
另一种可能的情况是,所述第一硬件接口集合的功能与该第一类型所实现的功能相同或相似。Another possible situation is that the function of the first hardware interface set is the same or similar to the function implemented by the first type.
例如,第一指示信息指示的功能为语音通话功能,第一硬件接口集合的类型为移动通信接口,且移动通信接口能够实现该语音通话功能,因此所述第一硬件接口集合与第一类型匹配。For example, the function indicated by the first indication information is a voice call function, the type of the first hardware interface set is a mobile communication interface, and the mobile communication interface can implement the voice call function, so the first hardware interface set matches the first type .
又如,第一指示信息指示的功能为在屏幕上显示图像的功能,第一硬件接口集合的类 型为屏幕显示接口,且屏幕显示接口能够实现该在屏幕上显示图像的功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is the function of displaying images on the screen, the type of the first hardware interface set is the screen display interface, and the screen display interface can realize the function of displaying images on the screen. A set of hardware interfaces matches the first type.
又如,第一指示信息指示的功能为声音播放功能,第一硬件接口集合的类型为扬声器接口或耳机接口,且扬声器接口或耳机接口能够实现该声音播放功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is a sound playback function, the type of the first hardware interface set is a speaker interface or a headphone interface, and the speaker interface or the headphone interface can realize the sound playback function, so the first hardware interface set Matches the first type.
又如,第一指示信息指示的功能为指纹识别功能,第一硬件接口集合的类型为指纹识别接口,且指纹识别接口能够实现该指纹识别功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is a fingerprint recognition function, the type of the first hardware interface set is a fingerprint recognition interface, and the fingerprint recognition interface can realize the fingerprint recognition function, so the first hardware interface set is the same as the first type match.
又如,第一指示信息指示的功能为定位功能,第一硬件接口集合的类型为定位接口,且定位接口能够实现该定位功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is a positioning function, the type of the first hardware interface set is a positioning interface, and the positioning interface can implement the positioning function, so the first hardware interface set matches the first type.
又如,第一指示信息指示的功能为数据传输功能,第一硬件接口集合的类型为无线通信接口,且无线通信接口能够实现该数据传输功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is a data transmission function, and the type of the first hardware interface set is a wireless communication interface, and the wireless communication interface can realize the data transmission function. Therefore, the first hardware interface set is the same as the first type. match.
又如,第一指示信息指示的功能为捕捉电子设备周围场景的功能,第一硬件接口集合的类型为拍摄接口,且拍摄接口能够实现该捕捉电子设备周围场景的功能,因此所述第一硬件接口集合与第一类型匹配。For another example, the function indicated by the first indication information is the function of capturing the scene around the electronic device, the type of the first hardware interface set is the shooting interface, and the shooting interface can realize the function of capturing the scene around the electronic device, so the first hardware The set of interfaces matches the first type.
因此,在第一应用通过第一指示信息指示调用第一功能的硬件接口的情况下,电子设备可以根据该第一功能确定与该第一功能匹配的该第一硬件接口集合。Therefore, when the first application instructs the hardware interface for invoking the first function through the first indication information, the electronic device may determine the first hardware interface set matching the first function according to the first function.
402,根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口。402. Determine at least one first hardware interface of the electronic device from the first hardware interface set according to the first indication information.
在确定了第一硬件接口集合之后,电子设备可以在该第一硬件接口集合中选择该电子设备所具有的一个或多个硬件接口,即电子设备可以选择该电子设备能够正确调用的一个或多个硬件接口。After the first hardware interface set is determined, the electronic device can select one or more hardware interfaces of the electronic device in the first hardware interface set, that is, the electronic device can select one or more hardware interfaces that the electronic device can call correctly. A hardware interface.
以图5所示的第一硬件接口集合为例,由于硬件接口3、硬件接口4均不是电子设备501具有的硬件接口,而硬件接口1、硬件接口2是电子设备501具有的硬件接口,因此电子设备501可以从该第一硬件接口集合中确定硬件接口1、硬件接口2,将硬件接口1、硬件接口2均作为第一硬件接口。Taking the first set of hardware interfaces shown in FIG. 5 as an example, since neither hardware interface 3 and hardware interface 4 are hardware interfaces of
在一个示例中,电子设备可以根据第一硬件接口集合中的硬件接口的信息,对第一硬件接口集合中的硬件接口逐一尝试,在调用结果为成功时,即可确定该至少一个第一硬件接口。In an example, the electronic device can try the hardware interfaces in the first hardware interface set one by one according to the information of the hardware interfaces in the first hardware interface set, and when the call result is successful, it can determine the at least one first hardware interface. interface.
以图5所示的第一硬件接口集合为例,电子设备501可以从该第一硬件接口集合中依次尝试硬件接口1、硬件接口2、硬件接口3、硬件接口4是否能够成功调用,由于硬件接口3、硬件接口4均不是电子设备501具有的硬件接口,电子设备501无法正确调用,而硬件接口1、硬件接口2是电子设备501具有的硬件接口,因此电子设备501可以正确调用硬件接口1、硬件接口2,从而可以将硬件接口1、硬件接口2均确定为第一硬件接口。Taking the first hardware interface set shown in FIG. 5 as an example, the
在一个示例中,电子设备可以根据电子设备的类型,从第一硬件接口集合中确定电子设备所具有的至少一个第一硬件接口。In an example, the electronic device may determine at least one first hardware interface possessed by the electronic device from the first hardware interface set according to the type of the electronic device.
可选的,所述根据所述第一指示信息,从所述第一硬件接口集合中确定电子设备所具 有的至少一个第一硬件接口,包括:根据所述电子设备的类型以及所述第一指示信息,从所述第一硬件接口集合中确定所述至少一个第一硬件接口。Optionally, the determining at least one first hardware interface of the electronic device from the first hardware interface set according to the first indication information includes: according to the type of the electronic device and the first hardware interface Indication information, determining the at least one first hardware interface from the first hardware interface set.
以图5所示的第一硬件接口集合为例,第一硬件接口集合包括硬件接口1、硬件接口2、硬件接口3、硬件接口4。其中,硬件接口1、硬件接口2为电子设备501所具有的硬件接口。硬件接口3为电子设备502所具有的硬件接口。硬件接口3、硬件接口4为电子设备503所具有的硬件接口。电子设备501可以根据其自身的设备类型,将硬件接口1、硬件接口2均确定为第一硬件接口。Taking the first hardware interface set shown in FIG. 5 as an example, the first hardware interface set includes hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4. Among them, the hardware interface 1 and the hardware interface 2 are hardware interfaces of the
可选的,所述第一指示信息还包括指示所述第一应用需要调用的接口的版本号的信息。Optionally, the first indication information further includes information indicating the version number of the interface that the first application needs to call.
以无线通信接口为例,蓝牙2.0版本的蓝牙天线所对应的接口与蓝牙4.0版本的蓝牙天线所对应的接口不同,在第一指示信息指示蓝牙4.0版本的情况下,电子设备可以忽略蓝牙2.0所对应的接口。例如,图5中的硬件接口1为蓝牙2.0版本的蓝牙接口,图5中的硬件接口2为蓝牙4.0版本的蓝牙接口,第一指示信息指示蓝牙4.0版本,电子设备可以根据第一指示信息中的版本号,将硬件接口2确定为第一硬件接口。除无线通信接口可以具有版本号外,多媒体传输接口(版本号可以为HDMI、VGA等)、耳机接口(版本号可以为2.5mm、3.5mm、USB-C等)、移动通信接口(版本号可以为GSM、CDMA等)等也可以具有版本号。Taking the wireless communication interface as an example, the interface corresponding to the Bluetooth antenna of the Bluetooth 2.0 version is different from the interface corresponding to the Bluetooth antenna of the Bluetooth 4.0 version. When the first indication information indicates the Bluetooth 4.0 version, the electronic device can ignore the Bluetooth 2.0 version. Corresponding interface. For example, hardware interface 1 in Figure 5 is a Bluetooth interface of Bluetooth 2.0 version, and hardware interface 2 in Figure 5 is a Bluetooth interface of Bluetooth 4.0 version. The first indication information indicates the Bluetooth 4.0 version, and the electronic device can follow the instructions in the first indication information. The version number of the hardware interface 2 is determined as the first hardware interface. In addition to the wireless communication interface can have a version number, multimedia transmission interface (version number can be HDMI, VGA, etc.), headphone jack (version number can be 2.5mm, 3.5mm, USB-C, etc.), mobile communication interface (version number can be GSM, CDMA, etc.) may also have version numbers.
403,调用所述至少一个第一硬件接口。403. Call the at least one first hardware interface.
调用第一硬件接口,可以指通过第一硬件接口驱动第一硬件接口对应的硬件。Invoking the first hardware interface may refer to driving the hardware corresponding to the first hardware interface through the first hardware interface.
在一个示例中,电子设备读取通话应用的代码中的第一指示信息,该第一指示信息用于指示类型为移动通信接口或功能为语言通话的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为移动通信接口,或者该至少一个第一硬件接口的功能均包括语音通话。从而,电子设备调用该至少一个第一硬件接口,通过驱动用于移动通信的天线,实现语音通话功能。In an example, the electronic device reads the first indication information in the code of the call application, and the first indication information is used to indicate the first set of hardware interfaces whose type is a mobile communication interface or whose function is a language call. The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a mobile communication interface according to the type of the interface, or the function of the at least one first hardware interface Both include voice calls. Thus, the electronic device invokes the at least one first hardware interface, and realizes the voice call function by driving the antenna for mobile communication.
在一个示例中,电子设备读取视频播放应用的代码中的第一指示信息,该第一指示信息用于指示类型为屏幕显示接口的第一硬件接口集合,或者功能为在屏幕上显示图像的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为屏幕显示接口,或者该至少一个第一硬件接口的功能均包括在屏幕上显示图像,从而电子设备调用该至少一个第一硬件接口,并在显示屏上播放视频。In an example, the electronic device reads the first instruction information in the code of the video playback application, and the first instruction information is used to indicate the first set of hardware interfaces whose type is a screen display interface, or whose function is to display images on the screen. The first set of hardware interfaces. The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a screen display interface according to the type of the interface, or the function of the at least one first hardware interface Both include displaying an image on the screen, so that the electronic device calls the at least one first hardware interface and plays the video on the display screen.
在一个示例中,电子设备读取音频播放应用的代码中的第一指示信息,该第一指示信息用于指示类型为扬声器接口的第一硬件接口集合,或者功能为播放声音的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为扬声器接口,或者该至少一个第一硬件接口的功能均包括播放声音,从而电子设备调用该至少一个第一硬件接口,并通过扬声器播放音频文件。In an example, the electronic device reads the first indication information in the code of the audio playback application, and the first indication information is used to indicate the first hardware interface set whose type is the speaker interface, or the first hardware interface whose function is to play sound set. The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a speaker interface according to the type, or the function of the at least one first hardware interface is all It includes playing a sound, so that the electronic device calls the at least one first hardware interface and plays the audio file through the speaker.
在一个示例中,电子设备读取音频播放应用的代码中的第一指示信息,该第一指示信息用于指示类型为耳机接口的第一硬件接口集合,或者功能为播放声音的第一硬件接口集 合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为耳机接口,或者该至少一个第一硬件接口的功能均包括播放声音,从而电子设备调用该至少一个第一硬件接口,并通过耳机播放音频文件。In an example, the electronic device reads the first indication information in the code of the audio playback application, and the first indication information is used to indicate the first hardware interface set whose type is the headphone interface, or the first hardware interface whose function is to play sound set. The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a headphone interface according to the type, or the function of the at least one first hardware interface is all It includes playing a sound, so that the electronic device calls the at least one first hardware interface and plays the audio file through the earphone.
在一个示例中,电子设备读取安全应用的代码中的第一指示信息,该第一指示信息用于指示类型为指纹识别接口的第一硬件接口集合,或者功能为指纹识别的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为指纹识别接口,或者该至少一个第一硬件接口的功能均包括指纹识别,从而电子设备调用该至少一个第一硬件接口,并在指纹识别模块反馈的指纹与预设指纹信息匹配时,认为当前电子设备的操作是安全的。In an example, the electronic device reads the first indication information in the code of the security application, and the first indication information is used to indicate the first hardware interface set whose type is fingerprint recognition interface, or the first hardware interface whose function is fingerprint recognition set. The electronic device can determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a fingerprint recognition interface according to the type of the interface, or the function of the at least one first hardware interface Both include fingerprint recognition, so that the electronic device calls the at least one first hardware interface, and when the fingerprint fed back by the fingerprint recognition module matches the preset fingerprint information, the current operation of the electronic device is considered to be safe.
在一个示例中,电子设备读取地图导航应用的代码中的第一指示信息,该第一指示信息用于指示类型为定位接口的第一硬件接口集合,或者功能为定位的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为定位接口,或者该至少一个第一硬件接口的功能均包括定位,从而电子设备调用该至少一个第一硬件接口,并通过GPS天线反馈的定位信息规划行车路径。In an example, the electronic device reads the first indication information in the code of the map navigation application, and the first indication information is used to indicate the first hardware interface set whose type is positioning interface, or the first hardware interface set whose function is positioning . The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a positioning interface according to the type of the interface, or the function of the at least one first hardware interface is all Including positioning, so that the electronic device invokes the at least one first hardware interface, and plans the driving route through the positioning information fed back by the GPS antenna.
在一个示例中,电子设备读取文件传输应用的代码中的第一指示信息,该第一指示信息用于指示类型为无线通信接口的第一硬件接口集合,或者功能为数据传输的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为无线通信接口,或者该至少一个第一硬件接口的功能均包括数据传输,从而电子设备调用该至少一个第一硬件接口,并通过蓝牙天线向邻近的电子设备发送文件,或者接收邻近的电子设备发送的文件。In an example, the electronic device reads the first indication information in the code of the file transfer application, and the first indication information is used to indicate the first hardware interface set whose type is a wireless communication interface, or the first hardware whose function is data transmission. Interface collection. The electronic device can determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a wireless communication interface according to the type of the interface, or the function of the at least one first hardware interface Both include data transmission, so that the electronic device calls the at least one first hardware interface, and sends a file to or receives a file sent by a nearby electronic device through a Bluetooth antenna.
在一个示例中,电子设备读取拍摄应用的代码中的第一指示信息,该第一指示信息用于指示类型为拍摄接口的第一硬件接口集合,或者功能为捕捉电子设备周围场景的第一硬件接口集合。电子设备可以从该第一硬件接口集合中确定该电子设备所具有的至少一个第一硬件接口,该至少一个第一根据接口的类型均为拍摄接口,或者该至少一个第一硬件接口的功能均包括捕捉电子设备周围场景,从而电子设备调用该至少一个第一硬件接口,并调用前置拍摄接口,并通过前置摄像头拍摄人像。In an example, the electronic device reads the first indication information in the code of the shooting application, the first indication information is used to indicate the first set of hardware interfaces whose type is the shooting interface, or the function is to capture the first part of the scene around the electronic device. A collection of hardware interfaces. The electronic device may determine from the first hardware interface set at least one first hardware interface that the electronic device has, and the at least one first hardware interface is a shooting interface according to the type, or the function of the at least one first hardware interface is all It includes capturing the scene around the electronic device, so that the electronic device calls the at least one first hardware interface, calls the front-facing interface, and shoots the portrait through the front-facing camera.
可选的,还可以根据电子设备的硬件类型,确定硬件调用模式。Optionally, the hardware call mode can also be determined according to the hardware type of the electronic device.
例如,手机显示屏的尺寸为5寸,可以根据该硬件类型,选择硬件调用模式1;手表屏幕尺寸为40mm,与手机显示屏尺寸不同,可以选择用于小屏的硬件调用模式2;电视的屏幕尺寸为50寸,与手机显示屏的尺寸不同,也与手表屏幕的尺寸不同,可以选择用于超大屏的硬件调用模式3。For example, if the size of the mobile phone display is 5 inches, you can select hardware call mode 1 according to the hardware type; the watch screen size is 40mm, which is different from the mobile phone display size, and you can select hardware call mode 2 for small screens; The screen size is 50 inches, which is different from the size of the mobile phone display and the size of the watch screen. You can choose the hardware call mode 3 for the super large screen.
又如,手机显示屏的尺寸包括4.8寸、5寸、5.1寸,因此,不同手机可以选择与不同尺寸屏幕适配的不同硬件调用模式。For another example, the size of the mobile phone display screen includes 4.8 inches, 5 inches, and 5.1 inches. Therefore, different mobile phones can choose different hardware calling modes adapted to different sizes of screens.
在本申请实施例中,第一应用通过第一指示信息指示第一硬件接口集合,该电子设备可以根据其自身参数(如版本号、电子设备类型等信息)确认该第一应用实际应当调用的真实硬件接口参数。因此,第一应用无需预先获知执行该第一应用的电子设备所具有的真实硬件接口。并且,该第一应用在指示第一硬件接口集合的情况下,该第一应用可以在多个电子设备上被执行。所以本申请实施例提供的方法可以降低应用开发人员的负担。In this embodiment of the application, the first application indicates the first hardware interface set through the first indication information, and the electronic device can confirm according to its own parameters (such as version number, electronic device type, etc.) what the first application should actually call Real hardware interface parameters. Therefore, the first application does not need to know in advance the actual hardware interface of the electronic device executing the first application. Moreover, when the first application indicates the first set of hardware interfaces, the first application may be executed on multiple electronic devices. Therefore, the method provided in the embodiments of the present application can reduce the burden of application developers.
图7为本申请实施例提供的一种调用硬件接口的方法的示意性流程图。Fig. 7 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
701,读取第二应用的代码中的第二指示信息,所述第二指示信息用于指示第二硬件接口集合的相关信息,所述第二硬件接口集合包括多个电子设备的硬件接口,所述第二硬件接口集合中的任意两个硬件接口的类型相同,或者,所述第二硬件接口集合中的任意两个硬件接口的部分或全部功能相同。701. Read second indication information in a code of a second application, where the second indication information is used to indicate related information of a second hardware interface set, where the second hardware interface set includes hardware interfaces of multiple electronic devices. The types of any two hardware interfaces in the second hardware interface set are the same, or part or all of the functions of any two hardware interfaces in the second hardware interface set are the same.
在本申请中,第二应用例如可以是通话应用、视频播放应用、音频播放应用、安全应用、地图导航应用、文件传输应用、拍摄应用等。第二应用还可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等。本申请对第二应用的具体类型不作限定。In this application, the second application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on. The second application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the second application.
第二硬件接口集合包括多个电子设备的硬件接口,该多个电子设备的类型例如可以包括手机、平板电脑、智能手表、视频播放器、膝上型计算机(Laptop)、台式计算机、电视、笔记本电脑中的至少两个。The second set of hardware interfaces includes hardware interfaces of multiple electronic devices. The types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
通常情况下,不同类型的电子设备所具有的硬件接口通常不同,如手机所具有的硬件接口与手表所具有的硬件接口不同,手表所具有的硬件接口与电视所具有的硬件接口不同,手机所具有的硬件接口与电视所具有的硬件接口不同。Under normal circumstances, different types of electronic devices have different hardware interfaces. For example, the hardware interface of a mobile phone is different from that of a watch, and the hardware interface of a watch is different from that of a TV. The hardware interface is different from the hardware interface of the TV.
相同类型的不同电子设备所具有的硬件接口可以相同,也可以不同。例如,相同版本号的两个手机所具有的硬件接口可以相同,版本号的两个手机所具有的硬件接口可以不同。The hardware interfaces of different electronic devices of the same type may be the same or different. For example, two mobile phones with the same version number may have the same hardware interfaces, and two mobile phones with the same version number may have different hardware interfaces.
步骤701的具体实现方式可以参照图4所示实施例中的步骤401,在此就不必赘述。For the specific implementation of
702,在所述电子设备不具有所述第二硬件接口集合中的任一硬件接口的情况下,调用预设的目标接口,或者呈现告警信息。702. In a case where the electronic device does not have any hardware interface in the second hardware interface set, call a preset target interface, or present alarm information.
如图6所示,第二硬件接口集合中包括硬件接口5、硬件接口6、硬件接口7,其中硬件接口5、硬件接口6、硬件接口7均不是电子设备所具有的硬件接口。As shown in FIG. 6, the second hardware interface set includes hardware interface 5, hardware interface 6, and hardware interface 7, where hardware interface 5, hardware interface 6, and hardware interface 7 are not hardware interfaces of electronic devices.
第二硬件接口集合的类型为第二类型,在第二应用指示调用属于该第二类型的接口的情况下,电子设备不具有所述第二硬件接口集合中的任一硬件接口,因此电子设备不具有属于该第二类型的接口,或者不具有与该第二类型匹配的接口。The type of the second hardware interface set is the second type. In the case where the second application instructs to call an interface belonging to the second type, the electronic device does not have any hardware interface in the second hardware interface set, so the electronic device There is no interface belonging to the second type, or no interface matching the second type.
或者,第二硬件接口集合的功能为第二功能,在第二应用指示调用具有该第二功能的接口的情况下,电子设备不具有所述第二硬件接口集合中的任一硬件接口,因此电子设备不具有能够实现该第二功能的接口,或者不具有与该第二功能匹配的接口。Or, the function of the second hardware interface set is the second function, and in the case that the second application instructs to call the interface with the second function, the electronic device does not have any hardware interface in the second hardware interface set, so The electronic device does not have an interface that can implement the second function, or does not have an interface that matches the second function.
预设的目标接口,可以是虚拟接口或是物理接口。The preset target interface can be a virtual interface or a physical interface.
例如,电子设备为手表,第二指示信息指示调用USB接口,而手表不具有USB接口。在此情况下,该电子设备可以调用用于充电的耳机接口,该耳机接口即为目标接口。由于电子设备可以调用目标接口,因此不会得到电子设备无法调用USB接口的调用反馈结果,也就不会因为该电子设备没有USB接口而导致第二应用运行失败(如第二应用运行崩溃或无限次的循环错误)。For example, the electronic device is a watch, the second indication information indicates to call the USB interface, and the watch does not have a USB interface. In this case, the electronic device can call the earphone interface for charging, and the earphone interface is the target interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the USB interface, and it will not cause the second application to fail because the electronic device does not have a USB interface (such as the second application running crash or unlimited Cycle error).
又如,电子设备为电视,第二指示信息指示调用移动通信接口,而电视不具有移动通信接口。在此情况下,该电子设备可以调用一个预设的虚拟接口。由于电子设备可以调用目标接口,因此不会得到电子设备无法调用移动通信接口的调用反馈结果,也就不会因为该电子设备没有移动通信接口而导致第二应用运行失败(如第二应用运行崩溃或无限次的 循环错误)。For another example, the electronic device is a TV, the second indication information indicates to call a mobile communication interface, and the TV does not have a mobile communication interface. In this case, the electronic device can call a preset virtual interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the mobile communication interface, and it will not cause the second application to fail because the electronic device does not have a mobile communication interface (for example, the second application crashes. Or an infinite loop error).
告警信息例如可以是在屏幕上显示“×”等符号。The warning information may be, for example, displaying symbols such as "×" on the screen.
可选的,呈现告警信息,可以呈现与第二硬件接口集合的类型或功能匹配的告警信息。Optionally, the alarm information is presented, and the alarm information that matches the type or function of the second hardware interface set may be presented.
例如,第二硬件接口集合的类型为移动通信接口,呈现的告警信息可以是“本机不具备语音通话功能”。For example, the type of the second hardware interface set is a mobile communication interface, and the displayed alarm information may be "the machine does not have the voice call function".
又如,第二硬件接口集合的类型为指纹识别接口,呈现的告警信息可以是“无法获取指纹信息”。For another example, the type of the second hardware interface set is a fingerprint identification interface, and the displayed alarm information may be "fingerprint information cannot be obtained".
又如,第二硬件接口集合的类型为定位接口,呈现的告警信息可以是“无法获取当前位置信息,是否手动输入当前位置信息”。For another example, the type of the second hardware interface set is a positioning interface, and the displayed alarm information may be "cannot obtain current location information, whether to manually input current location information".
又如,第二硬件接口集合的类型为蓝牙接口,呈现的告警信息可以是“无可连接的蓝牙设备”。For another example, the type of the second hardware interface set is a Bluetooth interface, and the displayed alarm information may be "No Bluetooth device connectable".
又如,第二硬件接口集合的类型为前置摄像头接口,呈现的告警信息可以是“调用前置摄像头出现错误,是否调用后置摄像头”。For another example, the type of the second hardware interface set is the front camera interface, and the presented warning information may be "An error occurred when calling the front camera, whether to call the rear camera".
图8为本申请实施例提供的一种调用硬件接口的方法的示意性流程图。FIG. 8 is a schematic flowchart of a method for invoking a hardware interface provided by an embodiment of the application.
801,读取第三应用的代码中的第三指示信息,所述第三指示信息用于指示所述第三应用需要调用的硬件接口的功能或类型。801. Read third indication information in the code of the third application, where the third indication information is used to indicate the function or type of the hardware interface that the third application needs to call.
在本申请中,第三应用例如可以是通话应用、视频播放应用、音频播放应用、安全应用、地图导航应用、文件传输应用、拍摄应用等。第三应用还可以包括音乐播放、视频播放、阅读应用、应用市场、图库、日历、通话、地图、导航等。本申请对第三应用的具体类型不作限定。In this application, the third application may be, for example, a call application, a video playback application, an audio playback application, a security application, a map navigation application, a file transfer application, a shooting application, and so on. The third application may also include music playback, video playback, reading application, application market, gallery, calendar, call, map, navigation, etc. This application does not limit the specific type of the third application.
第三硬件接口集合包括多个电子设备的硬件接口,该多个电子设备的类型例如可以包括手机、平板电脑、智能手表、视频播放器、膝上型计算机(Laptop)、台式计算机、电视、笔记本电脑中的至少两个。The third set of hardware interfaces includes the hardware interfaces of multiple electronic devices. The types of the multiple electronic devices may include, for example, mobile phones, tablets, smart watches, video players, laptops, desktop computers, TVs, and notebooks. At least two of the computers.
硬件接口可以通过代码实现硬件调用,因此,可以使用代码来定义硬件接口。例如,在安卓系统中,可以使用硬件接口定义语言(hardware interface definition language,HIDL)定义硬件接口。又如,可以使用HIDL语言调用java格式的代码,实现硬件接口的调用。通常情况下,不同类型的电子设备所具有的硬件接口通常不同,如手机所具有的硬件接口与手表所具有的硬件接口不同,手表所具有的硬件接口与电视所具有的硬件接口不同,手机所具有的硬件接口与电视所具有的硬件接口不同。The hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface. For example, in the Android system, a hardware interface definition language (HDL) can be used to define a hardware interface. For another example, the HIDL language can be used to call the code in the java format to implement the call of the hardware interface. Under normal circumstances, different types of electronic devices have different hardware interfaces. For example, the hardware interface of a mobile phone is different from that of a watch, and the hardware interface of a watch is different from that of a TV. The hardware interface is different from the hardware interface of the TV.
相同类型的不同电子设备所具有的硬件接口可以相同,也可以不同。例如,相同版本号的两个手机所具有的硬件接口可以相同,版本号的两个手机所具有的硬件接口可以不同。The hardware interfaces of different electronic devices of the same type may be the same or different. For example, two mobile phones with the same version number may have the same hardware interfaces, and two mobile phones with the same version number may have different hardware interfaces.
硬件接口的功能例如可以是语音通话功能、在屏幕上显示图像的功能、声音播放功能、指纹识别功能、定位功能、文件传输功能、捕捉电子设备周围场景的功能等。The function of the hardware interface may be, for example, a voice call function, a function of displaying an image on a screen, a sound playback function, a fingerprint recognition function, a positioning function, a file transfer function, a function of capturing scenes around the electronic device, and so on.
硬件接口的类型例如可以是移动通信接口、屏幕显示接口、扬声器接口、耳机接口、指纹识别接口、定位接口、无线通信接口、拍摄接口。The type of the hardware interface may be, for example, a mobile communication interface, a screen display interface, a speaker interface, a headphone interface, a fingerprint recognition interface, a positioning interface, a wireless communication interface, and a shooting interface.
802,根据电子设备的类型以及所述第三指示信息,从多个硬件接口中确定所述电子设备所具有的至少一个第三硬件接口,所述多个硬件接口包括多个电子设备所具有的硬件接口。802. According to the type of the electronic device and the third indication information, determine at least one third hardware interface possessed by the electronic device from a plurality of hardware interfaces, and the plurality of hardware interfaces include those possessed by the plurality of electronic devices. Hardware interface.
为描述清楚,第三指示信息所指示的第三应用需要调用的硬件接口的功能为第三功能,第三指示信息所指示的第三应用需要调用的硬件接口的类型为第三类型。也就是说,根据第三指示信息指示的第三类型,确定该电子设备可以成功调用的至少一个第三硬件接口,该第三硬件接口的类型或功能与该第三指示信息所指示的第三类型匹配。或者,根据第三指示信息指示的第三功能,确定该电子设备可以成功调用的至少一个第三硬件接口,该第三硬件接口的类型或功能与该第三指示信息所指示的第三功能匹配。For clarity of description, the function of the hardware interface to be called by the third application indicated by the third indication information is the third function, and the type of the hardware interface to be called by the third application indicated by the third indication information is the third type. That is, according to the third type indicated by the third indication information, at least one third hardware interface that can be successfully called by the electronic device is determined, and the type or function of the third hardware interface is the same as the third type indicated by the third indication information. Type match. Or, according to the third function indicated by the third indication information, determine at least one third hardware interface that the electronic device can successfully call, and the type or function of the third hardware interface matches the third function indicated by the third indication information .
电子设备可以存储有该多个硬件接口的相关信息,该相关信息包括该多个硬件接口中每个硬件接口的功能或类型。该相关信息还包括调用该每个硬件接口所需的各类参数。该相关信息还包括该每个硬件接口所属的电子设备的信息。可选的,该相关信息还可以包括每个硬件接口的标识。因此,当电子设备读取第三指示信息后,可以根据该电子设备自身的类型、参数、型号等,从多个硬件接口中选择符合要求的至少一个第三硬件接口。The electronic device may store related information of the multiple hardware interfaces, and the related information includes the function or type of each hardware interface of the multiple hardware interfaces. The related information also includes various parameters required for invoking each hardware interface. The related information also includes the information of the electronic device to which each hardware interface belongs. Optionally, the related information may also include the identification of each hardware interface. Therefore, after the electronic device reads the third indication information, it can select at least one third hardware interface that meets the requirements from the multiple hardware interfaces according to the type, parameter, model, etc. of the electronic device itself.
在第三指示信息指示硬件接口的功能时,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到至少一个第三硬件接口,该至少一个第三硬件接口与该第三指示信息所指示的第三功能相匹配。其中,所述至少一个第三硬件接口与该第三指示信息所指示的第三功能相匹配,可以指该至少一个第三硬件接口的功能均与该第三功能相同,还可以指该至少一个第三硬件接口的类型与该第三功能相匹配。When the third indication information indicates the function of the hardware interface, the electronic device can find at least one third hardware interface from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, and the at least one third hardware interface and the third indication The third function indicated by the information matches. Wherein, the at least one third hardware interface matches the third function indicated by the third indication information, which may mean that the functions of the at least one third hardware interface are the same as the third function, or that the at least one The type of the third hardware interface matches the third function.
在一个示例中,第三指示信息指示的硬件接口的功能为语音通话功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现语言通话功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的移动通信接口。In an example, the function of the hardware interface indicated by the third indication information is a voice call function, and the electronic device can find out from multiple hardware interfaces that the electronic device has the ability to implement language calls based on the relevant information of the multiple hardware interfaces. The functional hardware interface, for example, the mobile communication interface of the electronic device can be found from multiple hardware interfaces.
在一个示例中,第三指示信息指示的硬件接口的功能为在屏幕上显示图像的功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现在屏幕上显示图像的功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的屏幕显示接口。In an example, the function of the hardware interface indicated by the third indication information is the function of displaying an image on the screen, and the electronic device can find out from the multiple hardware interfaces the The hardware interface that can realize the function of displaying images on the screen, for example, the screen display interface of the electronic device can be found from multiple hardware interfaces.
在一个示例中,第三指示信息指示的硬件接口的功能为声音播放功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现声音播放功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的扬声器接口和耳机接口。In an example, the function of the hardware interface indicated by the third indication information is a sound playback function, and the electronic device can find out from the multiple hardware interfaces that the electronic device has the function of sound playback according to the related information of the multiple hardware interfaces. The functional hardware interface, for example, the speaker interface and earphone interface of the electronic device can be found from multiple hardware interfaces.
在一个示例中,第三指示信息指示的硬件接口的功能为定位功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现定位功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的定位接口。In an example, the function of the hardware interface indicated by the third indication information is the positioning function, and the electronic device can find out from the multiple hardware interfaces the functions of the electronic device that can realize the positioning function according to the related information of the multiple hardware interfaces. The hardware interface, for example, the positioning interface of the electronic device can be found from multiple hardware interfaces.
在一个示例中,第三指示信息指示的硬件接口的功能为无线通信功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现无线通信功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的蓝牙接口。In an example, the function of the hardware interface indicated by the third indication information is a wireless communication function, and the electronic device can find out from the multiple hardware interfaces that the electronic device has the wireless communication function according to the related information of the multiple hardware interfaces. The functional hardware interface, for example, the Bluetooth interface of the electronic device can be found from multiple hardware interfaces.
在一个示例中,第三指示信息指示的硬件接口的功能为拍摄功能,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的、能够实现拍摄功能的硬件接口,例如可以从多个硬件接口中找到该电子设备所具有的前置摄像头接口、后置摄像头接口。In an example, the function of the hardware interface indicated by the third indication information is the shooting function, and the electronic device can find out from the multiple hardware interfaces the functions of the electronic device that can realize the shooting function according to the related information of the multiple hardware interfaces. The hardware interface, for example, the front camera interface and the rear camera interface of the electronic device can be found from multiple hardware interfaces.
第三指示信息指示硬件接口的类型时,电子设备可以根据多个硬件接口的相关信息, 从多个硬件接口中找到至少一个第三硬件接口,该至少一个第三硬件接口与该第三指示信息所指示第三类型相匹配。其中,所述至少一个第三硬件接口与该第三指示信息所指示的第三类型相匹配,可以指该至少一个第三硬件接口的类型均与该第三类型相同,还可以指该至少一个第三硬件接口所能够实现的功能与该第三类型相匹配。When the third indication information indicates the type of the hardware interface, the electronic device can find at least one third hardware interface from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, and the at least one third hardware interface and the third indication information The indicated third type matches. Wherein, the at least one third hardware interface matches the third type indicated by the third indication information, which may mean that the type of the at least one third hardware interface is the same as the third type, or that the at least one The functions that the third hardware interface can implement match the third type.
在一个示例中,第三指示信息指示移动通信接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的移动通信接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现语言通话功能的硬件接口。In an example, the third indication information indicates a mobile communication interface, and the electronic device can find the mobile communication interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from the multiple hardware interfaces Find the hardware interface of the electronic device that can realize the language call function.
在一个示例中,第三指示信息指示屏幕显示接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的屏幕显示接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现在屏幕上显示图像的功能的硬件接口。In an example, the third indication information indicates the screen display interface, and the electronic device can find the screen display interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from the multiple hardware interfaces Find the hardware interface of the electronic device that can realize the function of displaying images on the screen.
在一个示例中,第三指示信息指示扬声器接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的扬声器接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现声音播放功能的硬件接口。In an example, the third indication information indicates a speaker interface, and the electronic device can find the speaker interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the sound playback function.
在一个示例中,第三指示信息指示耳机接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的耳机接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现声音播放功能的硬件接口。In an example, the third indication information indicates a headphone interface, and the electronic device can find the headphone interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the sound playback function.
在一个示例中,第三指示信息指示定位接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的定位接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现定位功能的硬件接口。In an example, the third indication information indicates the positioning interface, and the electronic device can find the positioning interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the positioning function.
在一个示例中,第三指示信息指示蓝牙接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的蓝牙接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现无线通信功能的硬件接口。In an example, the third indication information indicates the Bluetooth interface, and the electronic device can find the Bluetooth interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or find from the multiple hardware interfaces The hardware interface of the electronic device that can realize the wireless communication function.
在一个示例中,第三指示信息指示前置摄像头接口,电子设备可以根据多个硬件接口的相关信息,从多个硬件接口中找到该电子设备所具有的前置摄像头接口,或者,从多个硬件接口中找到该电子设备所具有的、能够实现拍摄功能的硬件接口。In an example, the third indication information indicates the front camera interface, and the electronic device can find the front camera interface of the electronic device from the multiple hardware interfaces according to the related information of the multiple hardware interfaces, or from multiple hardware interfaces. Find the hardware interface of the electronic device that can realize the shooting function in the hardware interface.
可选的,根据电子设备的类型以及所述第三指示信息,从多个硬件接口中确定所述电子设备所具有的至少一个第三硬件接口,包括:根据电子设备的类型,确定与所述电子设备的类型匹配的第三硬件接口集合,所述多个硬件接口包括所述第三硬件接口集合中的硬件接口;根据所述第三指示信息,从所述第三硬件接口集合中确定至少一个第三硬件接口。Optionally, according to the type of the electronic device and the third indication information, determining at least one third hardware interface of the electronic device from a plurality of hardware interfaces includes: determining, according to the type of the electronic device, the A third set of hardware interfaces matching the type of the electronic device, where the multiple hardware interfaces include hardware interfaces in the third set of hardware interfaces; according to the third indication information, determine at least from the third set of hardware interfaces A third hardware interface.
第三硬件接口集合与电子设备的类型匹配,可以指第三硬件接口集合包括该电子设备所具有的部分或全部硬件接口,且不包括该电子设备不具有的硬件接口。第三硬件接口集合不包括该电子设备不具有的硬件接口,例如可以是第三硬件接口集合包括其他类型的电子设备所具有的硬件接口。例如,第三硬件接口与手机匹配,那么第三硬件接口集合中的硬件接口均为手机的硬件接口,第三硬件接口集合不会包含不是该手机的硬件接口,例如不会包含手表的硬件接口,也不会包含电视的硬件接口。The third hardware interface set matches the type of the electronic device, which may mean that the third hardware interface set includes part or all of the hardware interfaces of the electronic device, and does not include hardware interfaces that the electronic device does not have. The third hardware interface set does not include hardware interfaces that the electronic device does not have. For example, the third hardware interface set may include hardware interfaces of other types of electronic devices. For example, if the third hardware interface matches the mobile phone, then the hardware interfaces in the third hardware interface set are all the hardware interfaces of the mobile phone, and the third hardware interface set will not include hardware interfaces that are not the mobile phone, for example, it will not include the hardware interfaces of the watch. , It will not include the hardware interface of the TV.
如图9所示,硬件接口集合901中的硬件接口1、硬件接口2、硬件接口3、硬件接口4均为电子设备1所具有的硬件接口,硬件接口集合902中的硬件接口5、硬件接口6、硬件接口7均为电子设备2所具有的硬件接口。As shown in Figure 9, hardware interface 1, hardware interface 2, hardware interface 3, and hardware interface 4 in hardware interface set 901 are all hardware interfaces of electronic device 1, and hardware interface 5, hardware interface in hardware interface set 902 6. The hardware interface 7 is the hardware interface of the electronic device 2.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件 接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为语音通话功能,电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现语言通话功能的硬件接口,或者从第三硬件接口集合中确定移动通信接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Hardware interface; the function of the hardware interface indicated by the third indication information is the voice call function, and the electronic device can determine the hardware interface that can realize the language call function from the third hardware interface set according to the third indication information, or from the third The mobile communication interface is determined in the hardware interface set.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为在屏幕上显示图像的功能;电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现在屏幕上显示图像的功能的硬件接口,或者从第三硬件接口集合中确定屏幕显示接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Have a hardware interface; the function of the hardware interface indicated by the third indication information is the function of displaying images on the screen; the electronic device can determine the function of displaying images on the screen from the third hardware interface set according to the third indication information , Or determine the screen display interface from the third set of hardware interfaces.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为声音播放功能;电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现声音播放功能的硬件接口,或者从第三硬件接口集合中确定扬声器接口和耳机接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Hardware interface; the function of the hardware interface indicated by the third instruction information is the sound playback function; the electronic device can determine the hardware interface that can realize the sound playback function from the third hardware interface set according to the third instruction information, or from the third The speaker interface and headphone interface are determined in the hardware interface set.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为定位功能;电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现定位功能的硬件接口,或者从第三硬件接口集合中确定定位接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Hardware interface; the function of the hardware interface indicated by the third indication information is the positioning function; the electronic device can determine the hardware interface that can realize the positioning function from the third hardware interface set according to the third indication information, or from the third hardware interface Determine the positioning interface in the collection.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为无线通信功能;电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现无线通信功能的硬件接口,或者从第三硬件接口集合中确定蓝牙接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Hardware interface; the function of the hardware interface indicated by the third indication information is a wireless communication function; the electronic device can determine a hardware interface that can realize the wireless communication function from the third hardware interface set according to the third indication information, or from the third The Bluetooth interface is determined in the hardware interface set.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示的硬件接口的功能为拍摄功能;电子设备可以根据第三指示信息,从第三硬件接口集合中确定能够实现拍摄功能的硬件接口,或者从第三硬件接口集合中确定前置摄像头接口、后置摄像头接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Hardware interface; the function of the hardware interface indicated by the third instruction information is the shooting function; the electronic device can determine the hardware interface that can realize the shooting function from the third hardware interface set according to the third instruction information, or from the third hardware interface The front camera interface and the rear camera interface are determined in the collection.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示移动通信接口,电子设备可以根据第三指示信息,从第三硬件接口集合中确定移动通信接口,或者从第三硬件接口集合中确定能够实现语言通话功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. The third instruction information indicates the mobile communication interface. The electronic device can determine the mobile communication interface from the third hardware interface set according to the third instruction information, or determine the mobile communication interface from the third hardware interface set that can realize the language call function Hardware interface.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示屏幕显示接口;电子设备可以根据第三指示信息,从第三硬件接口集合中确定屏幕显示接口,或者从第三硬件接口集合中确定能够实现在屏幕上显示图像的功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Have hardware interfaces; the third instruction information indicates the screen display interface; the electronic device can determine the screen display interface from the third hardware interface set according to the third instruction information, or determine from the third hardware interface set that it can be displayed on the screen The hardware interface of the image function.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示扬声器接口;电子设备可以根据第三指示信息,从第三硬件接口集合中确定扬声器接口,或者从第三硬件接口集合中确定能够实现声音播放功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Have hardware interfaces; the third instruction information indicates the speaker interface; the electronic device can determine the speaker interface from the third hardware interface set according to the third instruction information, or determine the hardware interface that can realize the sound playback function from the third hardware interface set .
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示耳机接口;电子设备可以根据第三指示信息,从第三硬件接口集合中确定耳机接口,或者从第三硬件接口集合中确定能够实现声音播放功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Have a hardware interface; the third indication information indicates the headphone interface; the electronic device can determine the headphone interface from the third hardware interface set according to the third indication information, or determine the hardware interface that can realize the sound playback function from the third hardware interface set .
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示定位接口;电子设备可以根据第三指示信息,从第三硬件接口集合中确定定位接口,或者从第三硬件接口集合中确定能够实现定位功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. The third instruction information indicates the positioning interface; the electronic device can determine the positioning interface from the third hardware interface set or determine the hardware interface that can implement the positioning function from the third hardware interface set according to the third instruction information.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示蓝牙;电子设备可以根据第三指示信息,从第三硬件接口集合中确定蓝牙接口,或者从第三硬件接口集合中确定能够实现无线通信功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. The third instruction information indicates Bluetooth; the electronic device can determine the Bluetooth interface from the third hardware interface set, or determine the hardware interface that can realize the wireless communication function from the third hardware interface set according to the third instruction information.
在一个示例中,电子设备为手表,电子设备可以根据该电子设备的类型,从多个硬件接口集合中确定第三硬件接口集合,该第三硬件接口集合中的硬件接口均为该电子设备所具有的硬件接口;第三指示信息指示前置摄像头接口;电子设备可以根据第三指示信息,从第三硬件接口集合中确定前置摄像头接口,或者从第三硬件接口集合中确定能够实现拍摄功能的硬件接口。In an example, the electronic device is a watch, and the electronic device can determine a third hardware interface set from a plurality of hardware interface sets according to the type of the electronic device, and the hardware interfaces in the third hardware interface set are all made by the electronic device. Have hardware interfaces; the third instruction information indicates the front camera interface; the electronic device can determine the front camera interface from the third hardware interface set according to the third instruction information, or determine from the third hardware interface set that it can realize the shooting function Hardware interface.
803,调用所述至少一个第三硬件接口。803. Call the at least one third hardware interface.
步骤803的具体实现方式可以参照图4所示实施例中的步骤403,在此就不必赘述。For the specific implementation of
可选的,所述方法还包括:读取第四应用的代码中的第四指示信息,所述第四应用需要调用的硬件接口的第四功能;在所述电子设备不具有与所述第四功能相匹配的硬件接口的情况下,调用预设的目标接口,或者呈现告警信息。Optionally, the method further includes: reading fourth indication information in the code of the fourth application, the fourth function of the hardware interface that the fourth application needs to call; In the case of hardware interfaces that match the four functions, the preset target interface is called, or alarm information is presented.
可选的,所述方法还包括:读取第四应用的代码中的第四指示信息,所述第四应用需要调用的硬件接口的第四类型;在所述电子设备不具有与所述第四类型相匹配的硬件接口的情况下,调用预设的目标接口,或者呈现告警信息。Optionally, the method further includes: reading fourth indication information in the code of the fourth application, the fourth type of hardware interface that the fourth application needs to call; In the case of hardware interfaces that match the four types, the preset target interface is called, or alarm information is presented.
上文已经详细描述了硬件接口的类型与硬件接口的类型或功能匹配的示例,以及硬件接口的功能与硬件接口的类型或功能匹配的示例,在此就不再赘述。The example of matching the type or function of the hardware interface with the type or function of the hardware interface has been described in detail above, and the example of matching the function of the hardware interface with the type or function of the hardware interface, and will not be repeated here.
预设的目标接口,可以是虚拟接口或是物理接口。The preset target interface can be a virtual interface or a physical interface.
例如,电子设备为手表,第二指示信息指示调用USB接口,而手表不具有USB接口。在此情况下,该电子设备可以调用用于充电的耳机接口,该耳机接口即为目标接口。由于电子设备可以调用目标接口,因此不会得到电子设备无法调用USB接口的调用反馈结果, 也就不会因为该电子设备没有USB接口而导致第二应用运行失败(如第二应用运行崩溃或无限次的循环错误)。For example, the electronic device is a watch, the second indication information indicates to call the USB interface, and the watch does not have a USB interface. In this case, the electronic device can call the earphone interface for charging, and the earphone interface is the target interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the USB interface, and it will not cause the second application to fail because the electronic device does not have a USB interface (such as the second application crashing or infinite Cycle error).
又如,电子设备为电视,第二指示信息指示调用移动通信接口,而电视不具有移动通信接口。在此情况下,该电子设备可以调用一个预设的虚拟接口。由于电子设备可以调用目标接口,因此不会得到电子设备无法调用移动通信接口的调用反馈结果,也就不会因为该电子设备没有移动通信接口而导致第二应用运行失败(如第二应用运行崩溃或无限次的循环错误)。For another example, the electronic device is a TV, the second indication information indicates to call a mobile communication interface, and the TV does not have a mobile communication interface. In this case, the electronic device can call a preset virtual interface. Since the electronic device can call the target interface, it will not get the call feedback result that the electronic device cannot call the mobile communication interface, and it will not cause the second application to fail because the electronic device does not have a mobile communication interface (for example, the second application crashes. Or an infinite loop error).
告警信息例如可以是在屏幕上显示“×”等符号。The warning information may be, for example, displaying symbols such as "×" on the screen.
呈现告警信息,可以根据第二指示信息指示的第二硬件接口集合的类型或功能,确定呈现的告警信息。To present alarm information, the presented alarm information may be determined according to the type or function of the second hardware interface set indicated by the second indication information.
例如,第二硬件接口集合的类型为移动通信接口,呈现的告警信息可以是“本机不具备语音通话功能”。For example, the type of the second hardware interface set is a mobile communication interface, and the displayed alarm information may be "the machine does not have the voice call function".
又如,第二硬件接口集合的类型为指纹识别接口,呈现的告警信息可以是“无法获取指纹信息”。For another example, the type of the second hardware interface set is a fingerprint identification interface, and the displayed alarm information may be "fingerprint information cannot be obtained".
又如,第二硬件接口集合的类型为定位接口,呈现的告警信息可以是“无法获取当前位置信息,是否手动输入当前位置信息”。For another example, the type of the second hardware interface set is a positioning interface, and the displayed alarm information may be "cannot obtain current location information, whether to manually input current location information".
又如,第二硬件接口集合的类型为蓝牙接口,呈现的告警信息可以是“无可连接的蓝牙设备”。For another example, the type of the second hardware interface set is a Bluetooth interface, and the displayed alarm information may be "No Bluetooth device connectable".
又如,第二硬件接口集合的类型为前置摄像头接口,呈现的告警信息可以是“调用前置摄像头出现错误,是否调用后置摄像头”。For another example, the type of the second hardware interface set is the front camera interface, and the presented warning information may be "An error occurred when calling the front camera, whether to call the rear camera".
可选的,所述第三指示信息还包括指示所述第三应用需要调用的接口的版本号的信息。Optionally, the third indication information further includes information indicating the version number of the interface that the third application needs to call.
图10是本申请实施例的电子设备100的软件结构框图。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用层,应用框架层,安卓运行时(Android runtime)和系统库。如图9所示,软件架构中的各层可以通过硬件接口层调用硬件层,硬件层可以包括图1中的多个硬件。其中,应用层,应用框架层,安卓运行时(Android runtime),系统库和硬件层可以参照图2所示的示例,在此不再赘述。FIG. 10 is a block diagram of the software structure of the
在系统层与硬件层之间还可以包括硬件接口层,该硬件接口层包括多个电子设备的硬件接口,每个硬件接口可以驱动一个电子设备的硬件。例如包括用于驱动显示屏的手机接口、用于驱动显示屏的手表接口、用于驱动显示屏的电视接口、用于驱动摄像头的手机接口等。A hardware interface layer may also be included between the system layer and the hardware layer. The hardware interface layer includes hardware interfaces of multiple electronic devices, and each hardware interface can drive the hardware of one electronic device. For example, it includes a mobile phone interface for driving a display screen, a watch interface for driving a display screen, a TV interface for driving a display screen, and a mobile phone interface for driving a camera.
当电子设备内部的处理器或芯片读取应用程序层、应用框架层、安卓运行时、系统库的代码时,可以通过硬件接口层,找到该电子设备能够调用的硬件接口,从而驱动硬件层中的硬件,并执行相应的操作。例如,硬件接口层中包括手机能够调用的硬件、手表能够调用的硬件和电视能够调用的硬件,手机可以在硬件接口层中找到手机能够调用的硬件接口,从而驱动硬件层中的硬件,并执行相应的操作。When the processor or chip inside the electronic device reads the code of the application program layer, application framework layer, Android runtime, and system library, it can find the hardware interface that the electronic device can call through the hardware interface layer, so as to drive the hardware layer Hardware, and perform the corresponding operations. For example, the hardware interface layer includes the hardware that can be called by the mobile phone, the hardware that can be called by the watch, and the hardware that can be called by the TV. The mobile phone can find the hardware interface that the mobile phone can call in the hardware interface layer to drive the hardware in the hardware layer and execute The corresponding operation.
图11所示为硬件接口层的内部结构框图。硬件接口层可以包括硬件接口代理层、硬件接口适配层、硬件接口访问控制层。Figure 11 shows a block diagram of the internal structure of the hardware interface layer. The hardware interface layer may include a hardware interface proxy layer, a hardware interface adaptation layer, and a hardware interface access control layer.
硬件接口代理层可以包括权限控制,用于确认硬件接口访问请求是否安全,还可以用于确认访问对象是否具有访问硬件接口的权限。硬件接口代理层可以实现安全、合理地访问硬件接口层。The hardware interface proxy layer may include authority control, which is used to confirm whether the hardware interface access request is safe, and can also be used to confirm whether the access object has the authority to access the hardware interface. The hardware interface agent layer can realize safe and reasonable access to the hardware interface layer.
硬件接口适配层包括多个硬件接口。硬件接口可以通过代码实现硬件调用,因此,可以使用代码来定义硬件接口。例如,在安卓系统中,可以使用硬件接口定义语言(hardware interface definition language,HIDL)定义硬件接口。又如,可以使用HIDL语言调用java格式的代码,实现硬件接口的调用。The hardware interface adaptation layer includes multiple hardware interfaces. The hardware interface can implement hardware calls through code, so the code can be used to define the hardware interface. For example, in the Android system, a hardware interface definition language (HDL) can be used to define a hardware interface. For another example, the HIDL language can be used to call the code in the java format to implement the call of the hardware interface.
该多个硬件接口的类型互不相同。或者,硬件接口适配层包括该多个硬件接口,该多个硬件接口所能够实现的功能互不相同。图11所示为硬件接口适配层包括多个不同类型的硬件接口的示例。如图11所示,硬件接口适配层包括类型1的硬件接口以及类型2的硬件接口。硬件接口适配层中的多个硬件接口为虚拟接口。硬件接口适配层中的多个硬件接口,可以用于表示上文中第一硬件接口集合、第二硬件接口集合、第三硬件接口集合、第四硬件接口集合中的至少一个。具体调用硬件接口适配层的方法可以参照图4、图7、图8所示的实施例。具体地,具体调用硬件接口适配层的方法可以参照图4所示实施例的步骤401、图7所示实施例的步骤701、图8所示的实施例的步骤801。The types of the multiple hardware interfaces are different from each other. Alternatively, the hardware interface adaptation layer includes the multiple hardware interfaces, and the functions that the multiple hardware interfaces can implement are different from each other. Figure 11 shows an example in which the hardware interface adaptation layer includes multiple different types of hardware interfaces. As shown in Figure 11, the hardware interface adaptation layer includes a type 1 hardware interface and a type 2 hardware interface. Multiple hardware interfaces in the hardware interface adaptation layer are virtual interfaces. The multiple hardware interfaces in the hardware interface adaptation layer may be used to represent at least one of the above-mentioned first hardware interface set, second hardware interface set, third hardware interface set, and fourth hardware interface set. For a specific method of invoking the hardware interface adaptation layer, refer to the embodiments shown in FIG. 4, FIG. 7, and FIG. 8. Specifically, for a specific method of invoking the hardware interface adaptation layer, reference may be made to step 401 in the embodiment shown in FIG. 4,
硬件接口访问控制层用于根据硬件接口适配层中硬件接口的调用情况,确定电子设备能够调用的硬件接口,或者执行预设的操作。电子设备可以包括用于识别设备类型的软件模块或硬结模块。例如,电子设备可以电子设备的版本号、型号等,从而调用该电子设备的硬件,或者确定该电子设备的硬件接口。电子设备可以包括用于识别硬件类型的软件模块或硬结模块。例如,电子设备可以识别芯片的类型,从而调用包括该芯片的硬件,或者确定包括该芯片的硬件的硬件接口。又如,电子设备可以识别硬件的版本号或型号,从而确定是否调用该硬件,或者确定该硬件的硬件接口。The hardware interface access control layer is used to determine the hardware interface that the electronic device can call or perform preset operations according to the calling situation of the hardware interface in the hardware interface adaptation layer. The electronic device may include a software module or a hard-wired module for identifying the type of the device. For example, the electronic device can call the hardware of the electronic device or determine the hardware interface of the electronic device by using the version number, model, etc. of the electronic device. The electronic device may include a software module or a hard-wired module for identifying the type of hardware. For example, the electronic device can identify the type of the chip, so as to call the hardware including the chip, or determine the hardware interface of the hardware including the chip. For another example, the electronic device can identify the version number or model of the hardware to determine whether to call the hardware or determine the hardware interface of the hardware.
硬件接口适配层中的每个硬件接口均与至少两个电子设备的硬件接口有对应关系。如图11所示,类型1的硬件接口与设备1的硬件接口1、设备2的硬件接口2、设备3的硬件接口3有对应关系。类型2的硬件接口与设备1的硬件接口4、设备2的硬件接口5有对应关系。当有应用程序通过指示信息指示调用类型1的硬件接口时,设备1可以根据该指示信息调用该硬件接口1。而当有应用程序通过指示信息指示调用类型2的硬件接口时,设备3可以调用预设的目标接口,或者呈现告警信息。硬件接口访问控制层中的多个硬件接口,可以用于表示上文中硬件接口集合中的多个硬件接口。具体调用硬件接口适配层的方法可以参照图4、图7、图8所示的实施例。具体地,具体调用硬件接口适配层的方法可以参照图4所示实施例的步骤402-403、图7所示实施例的步骤702、图8所示的实施例的步骤802-803。Each hardware interface in the hardware interface adaptation layer has a corresponding relationship with the hardware interfaces of at least two electronic devices. As shown in Fig. 11, the type 1 hardware interface has a corresponding relationship with the hardware interface 1, the hardware interface 2 of the device 2, and the hardware interface 3 of the device 3. The type 2 hardware interface has a corresponding relationship with the hardware interface 4 of the device 1 and the hardware interface 5 of the device 2. When an application instructs to call the hardware interface of type 1 through the instruction information, the device 1 can call the hardware interface 1 according to the instruction information. When an application instructs to call the type 2 hardware interface through the instruction information, the device 3 can call a preset target interface or present alarm information. The multiple hardware interfaces in the hardware interface access control layer can be used to represent multiple hardware interfaces in the above hardware interface set. For a specific method of invoking the hardware interface adaptation layer, refer to the embodiments shown in FIG. 4, FIG. 7, and FIG. 8. Specifically, for a specific method of invoking the hardware interface adaptation layer, reference may be made to steps 402-403 in the embodiment shown in FIG. 4,
硬件接口访问控制层可以驱动硬件层中的硬件,从而根据应用程序中的代码执行相应的操作。The hardware interface access control layer can drive the hardware in the hardware layer to perform corresponding operations according to the code in the application program.
图12是本申请实施例提供的电子设备的硬件结构示意图。图12所示的电子设备1200(该电子设备1200具体可以是一种计算机设备)包括存储器1201、处理器1202、通信接口1203以及总线1204。其中,存储器1201、处理器1202、通信接口1203通过总线1204实现彼此之间的通信连接。FIG. 12 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application. The electronic device 1200 shown in FIG. 12 (the electronic device 1200 may specifically be a computer device) includes a memory 1201, a processor 1202, a communication interface 1203, and a bus 1204. Among them, the memory 1201, the processor 1202, and the communication interface 1203 implement communication connections between each other through the bus 1204.
存储器1201可以是只读存储器(read only memory,ROM),静态存储设备,动态存 储设备或者随机存取存储器(random access memory,RAM)。存储器1201可以存储程序,当存储器1201中存储的程序被处理器1202执行时,处理器1202用于执行本申请实施例中图4、7或8所示的处理图像的方法的各个步骤。The memory 1201 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1201 may store a program. When the program stored in the memory 1201 is executed by the processor 1202, the processor 1202 is configured to execute each step of the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application.
处理器1202可以采用通用的中央处理器(central processing unit,CPU),微处理器,应用专用集成电路(application specific integrated circuit,ASIC),图形处理器(graphics processing unit,GPU)或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例中图4、7或8所示的处理图像的方法。The processor 1202 may adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more The integrated circuit is used to execute related programs to implement the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application.
处理器1202还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请实施例中图4、7或8所示的处理图像的方法的各个步骤可以通过处理器1202中的硬件的集成逻辑电路或者软件形式的指令完成。The processor 1202 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the image processing method shown in FIG. 4, 7 or 8 in the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 1202 or instructions in the form of software.
上述处理器1202还可以是通用处理器、数字信号处理器(digital signal processing,DSP)、专用集成电路(ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1201,处理器1202读取存储器1201中的信息,结合其硬件完成本申请实施例的电子设备中包括的单元所需执行的功能,或者执行本申请实施例中图4、7或8所示的处理图像的方法。The above-mentioned processor 1202 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, Discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory 1201, and the processor 1202 reads the information in the memory 1201, and combines its hardware to complete the functions required by the units included in the electronic device of the embodiment of the present application, or executes Figures 4 and 7 in the embodiment of the present application. Or the image processing method shown in 8.
通信接口1203使用例如但不限于收发器一类的收发装置,来实现电子设备1200与其他设备或通信网络之间的通信。例如,可以通过通信接口1203获取待构建的神经网络的信息以及构建神经网络过程中需要的训练数据(如图4、7或8所示实施例中的待处理图像)。The communication interface 1203 uses a transceiving device such as but not limited to a transceiver to implement communication between the electronic device 1200 and other devices or a communication network. For example, the information of the neural network to be constructed and the training data required in the process of constructing the neural network can be obtained through the communication interface 1203 (the image to be processed in the embodiment shown in FIG. 4, 7 or 8).
总线1204可包括在电子设备1200各个部件(例如,存储器1201、处理器1202、通信接口1203)之间传送信息的通路。The bus 1204 may include a path for transferring information between various components of the electronic device 1200 (for example, the memory 1201, the processor 1202, and the communication interface 1203).
应理解,电子设备中的获取模块可以相当于电子设备1200中的通信接口1203;电子设备中的处理模块可以相当于处理器1202。It should be understood that the acquisition module in the electronic device may be equivalent to the communication interface 1203 in the electronic device 1200; the processing module in the electronic device may be equivalent to the processor 1202.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显 示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the function 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 technical solution of the present application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disks or optical disks and other media that can store program codes. .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application. Should be covered within the scope of protection of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims (24)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910883684.7 | 2019-09-18 | ||
| CN201910883684.7A CN110780929B (en) | 2019-09-18 | 2019-09-18 | Method for calling hardware interface and electronic equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2021051982A1 true WO2021051982A1 (en) | 2021-03-25 |
Family
ID=69383794
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/102280 Ceased WO2021051982A1 (en) | 2019-09-18 | 2020-07-16 | Method for calling hardware interface and electronic device |
Country Status (2)
| Country | Link |
|---|---|
| CN (2) | CN110780929B (en) |
| WO (1) | WO2021051982A1 (en) |
Families Citing this family (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110780929B (en) * | 2019-09-18 | 2024-05-03 | 华为技术有限公司 | Method for calling hardware interface and electronic equipment |
| CN111813724B (en) * | 2020-05-20 | 2023-06-30 | 北京元心科技有限公司 | HIDL interface adapting system, method, corresponding equipment and storage medium |
| CN111918135B (en) * | 2020-06-23 | 2024-11-15 | 青岛海尔多媒体有限公司 | Method and device for configuration parameter verification, and television |
| CN113312103A (en) * | 2021-05-31 | 2021-08-27 | 浙江商汤科技开发有限公司 | Software definition method and device for intelligent camera, electronic equipment and storage medium |
| CN114817115A (en) * | 2022-05-20 | 2022-07-29 | 深圳市广和通无线通信软件有限公司 | Serial port communication method and related device |
| CN119851368B (en) * | 2025-01-10 | 2025-12-26 | 重庆长安科技有限责任公司 | Image data processing methods, apparatus, vehicle-mounted equipment, storage media and products |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103164207A (en) * | 2011-12-16 | 2013-06-19 | 深圳市快播科技有限公司 | Application program development method and system for spanning hardware platforms based on Android system |
| US8918841B2 (en) * | 2011-08-31 | 2014-12-23 | At&T Intellectual Property I, L.P. | Hardware interface access control for mobile applications |
| CN105224489A (en) * | 2015-11-12 | 2016-01-06 | 南威软件股份有限公司 | A kind of integrated management system of hardware device |
| CN106649164A (en) * | 2016-12-29 | 2017-05-10 | 南威软件股份有限公司 | Hardware interface management method |
| CN108415856A (en) * | 2018-02-08 | 2018-08-17 | 广东欧珀移动通信有限公司 | Device compatibility method and related device |
| CN110780929A (en) * | 2019-09-18 | 2020-02-11 | 华为技术有限公司 | Method for calling hardware interface and electronic equipment |
Family Cites Families (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103984540A (en) * | 2014-04-14 | 2014-08-13 | 美的集团股份有限公司 | Method and device for generating hardware interface running program |
| CN104281455A (en) * | 2014-10-11 | 2015-01-14 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
| CN104615410A (en) * | 2015-01-22 | 2015-05-13 | 北京彩云动力教育科技有限公司 | Multi-type hardware interface instruction processing method and system |
| CN104866383B (en) * | 2015-05-29 | 2018-11-23 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
| US20180095605A1 (en) * | 2016-09-30 | 2018-04-05 | International Business Machines Corporation | Generating a Mixed reality Interface to Expose Object Functionality |
| CN108415863A (en) * | 2018-02-01 | 2018-08-17 | 广东欧珀移动通信有限公司 | Hardware compatible implementation method of electronic device and related product |
| CN108829379B (en) * | 2018-05-31 | 2021-09-10 | 天津大学 | Multi-hardware interface communication protocol software on-demand automatic generation method |
| CN109684103A (en) * | 2018-12-17 | 2019-04-26 | 上海曼恒数字技术股份有限公司 | A kind of interface call method, device, server and storage medium |
-
2019
- 2019-09-18 CN CN201910883684.7A patent/CN110780929B/en active Active
- 2019-09-18 CN CN202010963635.7A patent/CN112214294B/en active Active
-
2020
- 2020-07-16 WO PCT/CN2020/102280 patent/WO2021051982A1/en not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8918841B2 (en) * | 2011-08-31 | 2014-12-23 | At&T Intellectual Property I, L.P. | Hardware interface access control for mobile applications |
| CN103164207A (en) * | 2011-12-16 | 2013-06-19 | 深圳市快播科技有限公司 | Application program development method and system for spanning hardware platforms based on Android system |
| CN105224489A (en) * | 2015-11-12 | 2016-01-06 | 南威软件股份有限公司 | A kind of integrated management system of hardware device |
| CN106649164A (en) * | 2016-12-29 | 2017-05-10 | 南威软件股份有限公司 | Hardware interface management method |
| CN108415856A (en) * | 2018-02-08 | 2018-08-17 | 广东欧珀移动通信有限公司 | Device compatibility method and related device |
| CN110780929A (en) * | 2019-09-18 | 2020-02-11 | 华为技术有限公司 | Method for calling hardware interface and electronic equipment |
Also Published As
| Publication number | Publication date |
|---|---|
| CN112214294B (en) | 2022-01-14 |
| CN112214294A (en) | 2021-01-12 |
| CN110780929A (en) | 2020-02-11 |
| CN110780929B (en) | 2024-05-03 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109814766B (en) | Application display method and electronic device | |
| WO2020259452A1 (en) | Full-screen display method for mobile terminal, and apparatus | |
| WO2021213164A1 (en) | Application interface interaction method, electronic device, and computer readable storage medium | |
| CN113994317A (en) | User interface layout method and electronic equipment | |
| WO2021051982A1 (en) | Method for calling hardware interface and electronic device | |
| WO2021036735A1 (en) | User interface display method and electronic device | |
| WO2021249053A1 (en) | Image processing method and related apparatus | |
| WO2020093988A1 (en) | Image processing method and electronic device | |
| WO2021063237A1 (en) | Control method for electronic device, and electronic device | |
| WO2020173370A1 (en) | Method for moving application icons, and electronic device | |
| CN111669459A (en) | Keyboard display method, electronic device and computer-readable storage medium | |
| WO2021036770A1 (en) | Split-screen processing method and terminal device | |
| CN114553814B (en) | Method and device for processing push messages | |
| WO2022068483A1 (en) | Application startup method and apparatus, and electronic device | |
| WO2021190524A1 (en) | Screenshot processing method, graphic user interface and terminal | |
| WO2021159746A1 (en) | File sharing method and system, and related device | |
| EP4224298A1 (en) | Screen display method and electronic device | |
| WO2021057203A1 (en) | Operation method and electronic device | |
| WO2022095744A1 (en) | Vr display control method, electronic device, and computer readable storage medium | |
| CN115033313A (en) | Terminal application control method, terminal equipment and chip system | |
| WO2021052311A1 (en) | Method for displaying user interface according to color of rear case, and electronic device | |
| WO2022143180A1 (en) | Collaborative display method, terminal device, and computer readable storage medium | |
| CN112437341B (en) | A video stream processing method and electronic device | |
| WO2024109481A1 (en) | Window control method and electronic device | |
| WO2024152910A1 (en) | Video recording method and electronic device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20865275 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20865275 Country of ref document: EP Kind code of ref document: A1 |