Conflict resolution method for ultrasonic path and earphone path and related device
Through multi-thread management of the headphone channel and ultrasonic channel, the thread synchronization mechanism is used to avoid conflicts, which solves the audio data anomaly problem caused by channel closure in the existing technology, improves work efficiency and user experience, and realizes device power consumption management and accidental touch protection.
Patent Information
- Application Number
- CN202310621487.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-05-29
AI Technical Summary
In the existing technology, when the common part of the ultrasonic channel and the earphone channel is closed, audio data transmission is abnormal, affecting the user experience, and it is difficult to avoid conflicts, affecting the power consumption management and accidental touch protection effects of the device.
Through multi-threading, the headphone channel and the ultrasonic channel are managed, and thread synchronization mechanisms (such as condition variables) are used to ensure the independence of the channels, avoid conflicts, and ensure that the headphone channel and the ultrasonic channel do not affect each other in different states.
It effectively avoids the conflict between the headphone channel and the ultrasonic channel, improves the work efficiency of the respective channels, ensures the stability of audio data transmission and user experience, and at the same time achieves the effects of device power consumption management and accidental touch protection.
Smart Images

Figure CN117692832B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio, and in particular to a method for resolving conflicts between an ultrasonic path and an earphone path and a related device. Background Art
[0002] In order to save power consumption of electronic devices and to prevent accidental touches of electronic devices when the electronic device is close to the ear, when a proximity event is triggered, the electronic device can control the display screen of the electronic device to turn off, thereby saving power consumption of the electronic device and preventing accidental touches. Among them, the event of the electronic device being close to the user's ear can be called a proximity event.
[0003] The method for determining a proximity event is usually to open an application with a proximity light function in an electronic device, trigger the proximity light service, and the electronic device sends ultrasonic data through the receiver and receives ultrasonic data through the microphone. The electronic device calculates the sent ultrasonic data and the received ultrasonic data to obtain a proximity result. The electronic device controls the display screen to turn off based on the proximity result.
[0004] Ultrasonic data needs to be sent after analog-to-digital conversion in the hardware path of the chip of the electronic device. Limited by the functions of existing chips, on some models of chips, there are common parts in the hardware path, such as the ultrasonic path for transmitting ultrasonic data and the headphone path for transmitting audio data. When the application is closed, thus ending the proximity light service, the ultrasonic data and ultrasonic path will be closed, and the common part of the path will also be closed. Therefore, it will cause abnormal operation of the audio data level path, resulting in silence of the left and right channels of the headphones, affecting the user experience. Summary of the invention
[0005] An embodiment of the present application provides a conflict resolution method for an ultrasonic path and a headphone path and a related device, which manages the headphone path and the ultrasonic path separately through multi-threading, thereby avoiding conflicts between the headphone path and the ultrasonic path and improving the working efficiency of the headphone path and / or the ultrasonic path.
[0006] In a first aspect, an embodiment of the present application provides a method for solving a conflict between an ultrasonic path and an earphone path, which is applied to an electronic device, wherein the electronic device includes an ultrasonic path and an earphone path, wherein the ultrasonic path is used to transmit ultrasonic data, and the earphone path is used to transmit audio data, and the method includes:
[0007] Triggering a first event to set the earphone thread to a blocked state, wherein the earphone thread in the blocked state cannot be used to process transactions related to the earphone channel;
[0008] Calling the earphone thread to send a first notification message to the ultrasonic thread, wherein the first notification message includes a message related to the first event;
[0009] Calling the ultrasonic thread to send a second notification message to the earphone thread, wherein the second notification message includes a processing result of processing the ultrasonic path according to the first notification message;
[0010] The headset thread is set to a non-blocking state according to the second notification message, wherein the headset thread in the non-blocking state can be used to process transactions related to the headset channel.
[0011] It can be seen that two threads are used to manage different channels. The headphone thread is used to manage the headphone channel, such as opening or closing the headphone channel. The ultrasonic thread is used to manage the ultrasonic channel, such as opening or closing the ultrasonic channel. When the headphone thread is called to send the first notification message to the ultrasonic thread, the headphone thread is locked for protection. In this way, the state of the ultrasonic channel is prevented from affecting the state of the headphone channel during the process of closing the ultrasonic channel; or the state of the headphone channel is prevented from affecting the state of the ultrasonic channel during the process of closing the headphone channel.
[0012] In a possible implementation, setting the headset thread to a blocked state includes:
[0013] The earphone thread is blocked by a conditional variable so that the earphone thread is in the blocking state within a preset time.
[0014] It can be seen that by locking the earphone thread through conditional variables, it is possible to avoid affecting the earphone path during closing or opening the ultrasonic pen path.
[0015] In a possible implementation, triggering the first event to set the headset thread to a blocked state includes:
[0016] Before opening the earphone path, the earphone thread is set to a blocked state.
[0017] It can be seen that before the headphone channel is opened, the headphone thread is locked and protected to avoid affecting the state of the headphone channel.
[0018] In a possible implementation, setting the headset thread to a non-blocking state according to the second notification message includes:
[0019] Determining, according to the second notification message, that the ultrasonic path has been closed, and satisfying the conditional variable of the earphone thread;
[0020] When the condition variable is satisfied, setting the headset thread to a non-blocking state;
[0021] The headset thread in the non-blocking state is called to open the headset path.
[0022] It can be seen that before opening the headphone channel, when closing the ultrasonic channel, the headphone channel will not be affected because the headphone thread is in a blocked state. After knowing that the ultrasonic channel has been closed, the headphone channel is opened to avoid the conflict between the ultrasonic channel and the headphone channel. Among them, the condition variable is a thread synchronization mechanism that allows threads to wait for specific conditions in a non-competitive manner. When the condition is not met, the thread suspends and waits.
[0023] In a possible implementation manner, after calling the headset thread to send the first notification message to the ultrasonic thread and before calling the ultrasonic thread to send the second notification message to the headset thread, the method further includes:
[0024] In the case where it is determined that the ultrasonic path is to be closed, calling the ultrasonic thread to close the ultrasonic path;
[0025] After determining that the ultrasonic path is closed, the second notification message is generated.
[0026] It can be seen that the ultrasonic path needs to be processed in the ultrasonic thread. In order not to affect the opening of the headphone path, if the ultrasonic path is in place, the ultrasonic path is closed.
[0027] In a possible implementation manner, when the earphone path is closed, the ultrasonic path is in a closed state, and the triggering of the first event to set the earphone thread to a blocked state includes:
[0028] After closing the earphone path, the earphone thread is set to a blocked state.
[0029] It can be seen that when the earphone channel is closed, the ultrasonic channel is in a closed state, so the closing of the earphone channel will not affect the state of the ultrasonic channel. After the earphone channel is closed, the earphone thread is locked to prevent the state of the earphone channel from affecting the ultrasonic channel. For example, it is prevented that the earphone channel can be reopened to affect the ultrasonic channel.
[0030] In a possible implementation, setting the headset thread to a non-blocking state according to the second notification message includes:
[0031] Determining, according to the second notification message, that the transaction on the ultrasound channel has been completed in the ultrasound thread, and that a condition variable for blocking the earphone thread is satisfied;
[0032] When the condition variable is met, the headset thread is set to a non-blocking state.
[0033] It can be seen that when the ultrasonic path is closed, the earphone thread is in a blocked state, so it will not affect the earphone path. Therefore, the ultrasonic thread can be called to process the ultrasonic path, and after the ultrasonic path is processed, the earphone thread can be unlocked. In this way, the earphone thread can continue to process other matters.
[0034] In a possible implementation manner, after calling the headset thread to send the first notification message to the ultrasonic thread and before calling the ultrasonic thread to send the second notification message to the headset thread, the method further includes:
[0035] In the case where it is determined in the ultrasonic thread that an ultrasonic path is to be opened, calling the ultrasonic thread to open the ultrasonic path;
[0036] In the case where it is determined in the ultrasonic thread that the ultrasonic path is not to be opened, the ultrasonic thread is not called;
[0037] After the ultrasonic thread is executed, the second notification message is generated.
[0038] It can be seen that after closing the earphone channel, the earphone thread is called to send a message to the ultrasonic thread. Because the earphone channel has been closed and the earphone thread is in a blocked state, the earphone channel will not affect the ultrasonic channel, so the ultrasonic thread is called to process the ultrasonic channel, such as opening the ultrasonic channel.
[0039] In a possible implementation, calling the ultrasonic thread to open the ultrasonic path includes:
[0040] Calling the ultrasonic thread to determine the state of the earphone channel;
[0041] If the earphone path is in a closed state, calling the ultrasonic thread to open the ultrasonic path;
[0042] If the earphone path is in an open state, the ultrasonic path is not opened.
[0043] It can be seen that the ultrasonic thread maintains the status bit of the headphone path being open or closed, which is used to determine whether to open or close the ultrasonic path.
[0044] In a second aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: one or more processors and a memory; wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect or any possible implementation of the first aspect.
[0045] In a third aspect, the present application provides a chip or a chip system, the chip or chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in the first aspect or any possible implementation of the first aspect. Among them, the communication interface in the chip can be an input / output interface, a pin or a circuit, etc.
[0046] In a possible implementation, the chip or chip system described above in the embodiment of the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0047] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0048] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a communication device, enables the communication device to execute a method as described in the first aspect or any possible implementation of the first aspect.
[0049] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The following is an introduction to the drawings used in the embodiments of the present application.
[0051] Figure 1A is a structural diagram of an electronic device 100 provided in an embodiment of the present application;
[0052] Figure 1B It is a software structure block diagram of an electronic device provided in an embodiment of the present application;
[0053] Figure 2A It is a schematic diagram of turning off the display screen of an electronic device provided in an embodiment of the present application;
[0054] Figure 2B This is a schematic diagram of an embodiment of the present application providing a method of realizing a proximity and distance function by using the principle of ultrasonic radar ranging;
[0055] Figure 2C It is a hardware schematic diagram of an ultrasonic path and an earphone path provided in an embodiment of the present application;
[0056] Figure 3A It is a schematic diagram of an ultrasonic path and an earphone path that do not conflict with each other provided by an embodiment of the present application;
[0057] Figure 3B is a schematic diagram of a conflict between an ultrasound path and an earphone path provided in an embodiment of the present application;
[0058] Figure 3C is a schematic diagram of another conflict between an ultrasound path and an earphone path provided in an embodiment of the present application;
[0059] Figure 4A This is a schematic diagram of an interface for triggering a proximity light service provided in an embodiment of the present application;
[0060] Figure 4BThis is a schematic diagram of an interface for triggering a headphone playback event provided in an embodiment of the present application;
[0061] Figure 4C is an interactive schematic diagram of opening an earphone path provided by an embodiment of the present application;
[0062] Figure 5A This is a schematic diagram of an interface for closing an earphone playback event provided in an embodiment of the present application;
[0063] Figure 5B is a schematic diagram of an interface for triggering a proximity event provided in an embodiment of the present application;
[0064] Figure 5C is an interactive schematic diagram of opening an ultrasonic path provided by an embodiment of the present application;
[0065] Figure 6 It is a flow chart of a conflict approach method of an ultrasonic approach light path and an earphone path provided in an embodiment of the present application;
[0066] Figure 7 It is a schematic diagram of a flow chart for opening an ultrasonic path provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.
[0068] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0069] The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device, and finally presented as content that can be recognized by the user. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.
[0070] First, an embodiment of the present application provides an electronic device. Figure 1A It is a structural diagram of an electronic device 100 provided in an embodiment of the present application.
[0071] 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, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, an earpiece 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, 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, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0072] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0073] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0074] The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions. The processor 110 can also be provided with a memory for storing instructions and data.
[0075] In some embodiments, 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, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0076] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0077] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0078] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0079] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0080] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0081] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0082] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0083] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0084] The charging management module 140 is used to receive charging input from a charger. While the charging management module 140 is charging the battery 142 , it can also power the electronic device through the power management module 141 .
[0085] 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 charging management module 140 to power the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
[0086] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0087] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0088] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0089] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be arranged in the same device as the mobile communication module 150 or other functional modules.
[0090] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering processing, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2. Exemplarily, the wireless communication module 160 may include a Bluetooth module, a Wi-Fi module, etc.
[0091] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM) general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TDSCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0092] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 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 that execute program instructions to generate or change display information.
[0093] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD). The display panel can also be made of an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), miniled, microled, micro-oled, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0094] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0095] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0096] The earpiece 170B, also called a "receiver", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the earpiece 170B close to the human ear. In the embodiment of the present application, ultrasonic data can be sent through the earpiece 170B.
[0097] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the source of sound, realize directional recording function, etc. In an embodiment of the present application, ultrasonic data reflected by an object can be received by the microphone 170C.
[0098] The headphone jack 170D is used to connect a wired headphone. The headphone jack 170D can be a USB port 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface. In the embodiment of the present application, audio data can be sent through the left and right channels of the connected headphone, and voice data can be received through the microphone of the headphone.
[0099] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. When a touch operation is applied to the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A.
[0100] The gyro sensor 180B can be used to detect the magnitude of the angular velocity of the electronic device 100 in various directions (generally three axes). The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions. The gyro sensor 180B and the acceleration sensor 180E can be used to determine the motion posture of the electronic device 100. In the embodiment of the present application, the data reported by the acceleration sensor 180E and the gyro sensor 180B can be used to determine the motion state of the device, and then assist in determining whether the image at the corresponding moment will be jittery, ghosting, etc.
[0101] The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. The distance sensor 180F is used to measure distance. In the shooting scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focus. The proximity light sensor 180G can be used to determine that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. 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. In the shooting scene, the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect temperature. The bone conduction sensor 180M can obtain vibration signals.
[0102] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control 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. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0103] The buttons 190 include a power button, a volume button, etc. The electronic device 100 can receive button inputs and generate key signal inputs related to user settings and function control of the electronic device 100. The motor 191 can generate vibration prompts. The indicator 192 can be an indicator light. The SIM card interface 195 is used to connect a SIM card.
[0104] See also Figure 1B , Figure 1B It is a software structure block diagram of an electronic device provided in an embodiment of the present application.
[0105] like Figure 1B As shown in FIG. 1 , the layered architecture divides the system into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some possible implementations, the system can be divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the hardware abstraction layer (HAL), the kernel layer, and the hardware layer. Among them:
[0106] The application layer can include a series of application packages.
[0107] like Figure 1B As shown, the application package may include applications (APP) such as camera, gallery, social application, browser, short message, video, music, Bluetooth, navigation and WLAN.
[0108] The application framework layer provides application programming interface and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0109] like Figure 1B As shown, the application framework layer may include a window manager, a content provider, a phone manager, a resource manager ( Figure 1B Not shown), notification manager, etc. ( Figure 1B not shown), the view system ( Figure 1BThe application framework layer may also include: audio service, sensor manager, system services ( Figure 1B not shown).
[0110] Among them, the audio service is used to provide the ability to transmit and receive ultrasonic data.
[0111] The sensor manager is used to interact with applications using sensors through an application program interface (API), and can interact with the HAL through the HAL interface definition language (HIDL).
[0112] The application layer and the application framework layer run in a virtual machine, which executes the Java files of the application layer and the application framework layer as binary files.
[0113] HAL is used to provide a standard interface and expose device hardware capabilities to higher-level Java API frameworks. HAL contains multiple modules, each of which implements an interface for a specific type of hardware component, such as the audio module, the sensor module, and the camera module. Figure 1B Not shown), Bluetooth module ( Figure 1B not shown).
[0114] For example, the audio module is used to control the ultrasonic proximity audio switch and open the ultrasonic path. The audio module is also used to configure audio paths such as high-fidelity HIFI, smart power amplifier smart PA, and codec. The audio module is also used for ultrasonic calibration control and non-volatile data NV parameter reading and writing.
[0115] The kernel layer is the layer between the hardware layer and the software layer. The kernel layer includes at least one or more of the following: display driver ( Figure 1B Not shown), camera driver ( Figure 1B The hardware layer includes at least one or more of the following: sensor digital signal processing (sensor DSP), audio digital signal processor (Audio DSP), earpiece and microphone MIC.
[0116] Exemplarily, the audio driver is used to drive the audio module to generate ultrasonic data and send the ultrasonic data to the earpiece through the ultrasonic channel smartPA. The audio driver is also used to drive the audio module to use the ultrasonic proximity algorithm to calculate the ultrasonic data uploaded by the microphone MIC through the codec Codec to obtain the ultrasonic determination result.
[0117] Exemplarily, the sensor data signal processor is used to drive the sensor driver to obtain the ultrasonic determination result obtained by the audio module, and use the fusion algorithm to calculate the data collected by one or more sensors to obtain the proximity result. Among them, the fusion algorithm can be understood as an algorithm for fusing the gesture proximity determination result formed by the acceleration sensor ACC and the gyroscope sensor Gyro, the ambient light proximity determination result formed by the ambient light sensor, the touch proximity determination TP result and the ultrasonic determination result. The sensor driver is also used to drive the sensors sensor driver to report the proximity result to the system service.
[0118] The following is an example of the workflow of electronic devices and hardware using the ultrasonic proximity light opening scenario.
[0119] When the touch sensor 180K receives a touch operation, the corresponding hardware terminal is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. Taking the operation as a touch operation, and the control corresponding to the touch operation as the control of the video application icon as an example, the call application calls the interface of the application framework layer, opens the call application, and turns on the proximity light. The sensor manager interacts with the sensor module, and then opens the sensor driver by calling the kernel layer. The sensor driver is used to drive the sensor digital signal processor according to the notification issued by the sensor manager, process the data obtained by the sensor, and obtain the processing result. The processing result is sent to the audio digital signal processor. The audio digital signal processor is used to control the audio driver according to the processing result to drive the audio module to open the ultrasonic path and send the ultrasonic signal through the ultrasonic path. The information triggering the proximity light service is sent to the audio DSP through the sensor DSP, and the audio DSP calls the audio module through the audio driver to generate ultrasonic data and transmit the ultrasonic data through the ultrasonic path. Ultrasonic data is sent through the earpiece and received through the microphone.
[0120] In order to save power consumption of electronic devices and to prevent accidental touching of electronic devices by placing the device close to the ear. Usually, the electronic device 100 controls the screen of the electronic device to turn on or off in some scenarios, such as the call scenario built into the electronic device 100, the voice call scenario or voice message playback scenario implemented by third-party software such as instant messaging applications, and other third-party software calling the scenario of proximity to light. For details, please refer to Figure 2A , Figure 2A 1 is a schematic diagram of turning off the display screen of an electronic device provided in an embodiment of the present application. In a scenario where the electronic device 100 answers a call, when it is detected that the electronic device 100 is close to the user's ear to answer the call, the electronic device 100 can control the display screen 194 of the mobile phone to turn off the screen, thereby achieving the purpose of saving power consumption.
[0121] The above-mentioned event of the electronic device 100 approaching the user's ear may be referred to as a proximity event. Figure 2B , Figure 2B It is a schematic diagram of an embodiment of the present application that uses the principle of ultrasonic radar ranging to realize the approach and distance function. At present, the method for determining the proximity event can be: the electronic device 100 has an earpiece 170B, a microphone 170C, a gyroscope sensor 180B and an acceleration sensor 180E. After opening the application program in the electronic device 100 that has the proximity light turned on, the proximity light service is triggered and the proximity light is turned on. Therefore, the electronic device 100 can transmit ultrasonic data through the earpiece 170B, and the microphone 170C receives the reflected ultrasonic data. The electronic device 100 uses the principle of ultrasonic radar ranging to realize the approach and distance function, thereby providing a screen on and off function in a voice call scenario. The principle of ultrasonic determination is to determine whether the mobile phone and the object are in a close state or a distant state by detecting the change in the echo energy of the ultrasonic data received by the microphone 170C.
[0122] That is, the electronic device 100 transmits ultrasonic data of a fixed frequency through the earpiece 170B. After the ultrasonic data contacts the object 200, it will be reflected on the contact surface, and a part of the emitted echo will be received by the microphone 170C. When the object 200 is far away from the earpiece 170B and the microphone 170C, the echo energy is low; when the object 200 is close to the earpiece 170B and the microphone 170C, the echo energy is high. Therefore, the electronic device 100 calculates the amplitude, frequency, phase and other characteristics of the ultrasonic data sent and received to obtain a proximity result. The electronic device 100 combines the proximity result and the data collected by the gyroscope sensor 180B and the acceleration sensor 180E to calculate whether the object 200 and the electronic device 100 are in a close state or a distant state.
[0123] If it is calculated that the object 200 and the electronic device 100 are in a close state (also referred to as a triggering close event), the electronic device 100 controls the display screen 194 to turn off the screen. If it is calculated that the object 200 and the electronic device 100 are in a far away state (also referred to as a triggering far away event), the electronic device 100 controls the display screen 194 to turn on the screen.
[0124] See also Figure 2C , Figure 2C Schematic diagram of the hardware of an ultrasonic path and an earphone path provided in an embodiment of the present application. Figure 2C It can be seen that the electronic device 100 sends ultrasonic data through the earpiece 170B, and the electronic device 100 receives the ultrasonic data reflected by the object through the microphone 170C. When the electronic device 100 is connected to the earphone 210, for audio data, the electronic device 100 sends audio data through the left and right channels of the earphone 210, and the electronic device 100 receives voice data through the microphone of the earphone 210.
[0125] Generally speaking, the electronic device 100 needs to perform analog-to-digital conversion on the ultrasonic data and audio data through the hardware path of the codec chip 230 before sending. Correspondingly, the electronic device 100 needs to perform analog-to-digital conversion on the received ultrasonic data and audio data through the hardware path of the codec chip 230. Figure 2C As shown, due to the function of the codec chip 230, the hardware paths of some models of codec chips have a common part 231. That is, the ultrasonic path and the earphone path have a common part 231.
[0126] In summary. When the proximity light service is triggered, for example, an application with a proximity light function is opened, the electronic device 100 can send ultrasonic data through the earpiece 170B and receive ultrasonic echo data through the microphone 170C. When the headphone playback event is triggered, for example, an audio file is played through the headphone 210, the electronic device 100 can send audio data through the left and right channels of the headphone 210 and receive voice data through the microphone of the headphone 210. It can be understood that although the proximity light service and the headphone playback event are independent services, the above two services can also exist at the same time. Therefore, in the scenario where the proximity light service and the headphone playback event exist at the same time, there will be ultrasonic data and ultrasonic channels, as well as audio data and headphone channels working at the same time. When the proximity light service needs to be turned off, the ultrasonic data and ultrasonic channels will be turned off. Since there is a common part 231 in the hardware channel of the ultrasonic data and the audio data, when the ultrasonic data and the ultrasonic channel are turned off, the common part 231 of the channel is also turned off. If the headphone playback event still exists at this time, it will cause abnormalities in the audio data and the headphone channel, resulting in silence of the left and right channels of the headphone 210.
[0127] Vice versa, if the headphone playback event needs to be turned off but the proximity light service still exists, it will cause abnormalities in the ultrasonic data and the path, making it impossible to determine the accuracy of the judgment of the proximity light service.
[0128] See also FIG. 3A to FIG. 3C , Figure 3A This is a schematic diagram of an embodiment of the present application in which an ultrasonic path and an earphone path do not conflict with each other. Figure 3B is a schematic diagram of a conflict between an ultrasound path and an earphone path provided in an embodiment of the present application, Figure 3C This is another schematic diagram of the conflict between the ultrasound path and the earphone path provided in an embodiment of the present application.
[0129] like Figure 3A As shown in (a), at the first moment, the headphone playback event is triggered, and the electronic device opens the headphone channel, through which audio data can be transmitted or voice data can be received. At the second moment, the headphone playback event ends, and the electronic device closes the headphone channel. At the third moment after the second moment, the proximity light service is triggered, and the electronic device opens the ultrasonic channel, through which ultrasonic data can be transmitted or ultrasonic data reflected by an object can be received. At the fourth moment, the proximity light service ends, and the electronic device closes the ultrasonic channel. It can be seen that the proximity light service is triggered after the headphone playback event ends, so the closure of the headphone channel does not affect the normal use of the ultrasonic channel.
[0130] like Figure 3A As shown in (b), at the first moment, the proximity light service is triggered, and the electronic device opens the ultrasonic path, through which ultrasonic data can be transmitted or ultrasonic data reflected by an object can be received. At the second moment, the proximity light service ends, and the electronic device closes the ultrasonic path. At the third moment after the second moment, the headphone play event is triggered, and the electronic device opens the headphone path, through which audio data can be transmitted or voice data can be received. At the fourth moment, the headphone play event ends, and the electronic device closes the headphone path. It can be seen that the headphone play event is triggered after the proximity light service ends, so the closure of the ultrasonic path does not affect the normal use of the headphone path.
[0131] It should be noted that the present application does not impose any restrictions on the timing of triggering the headphone play event. The electronic device may establish a connection with the headphone before playing the audio data. In this way, playing the audio data may be considered to trigger the headphone play event. Alternatively, the electronic device may establish a connection with the headphone after playing the audio data, that is, during the process of playing the audio data, thereby triggering the headphone play event.
[0132] like Figure 3BAs shown in (a), at the first moment, the electronic device has established a connection with the headset, and the electronic device plays audio data, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. Alternatively, at the first moment, the electronic device plays audio data, and because the electronic device has not established a connection with the headset at the first moment, the audio data is played through a speaker or a receiver. In the process of playing audio data, that is, at the third moment, the electronic device establishes a connection with the headset, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. At the fourth moment, the headset play event ends, and the electronic device closes the headset path.
[0133] from Figure 3B As can be seen from (a), during the process of transmitting audio data through the earphone channel, that is, at the second moment, the proximity light service is triggered, the electronic device opens the ultrasonic channel, and transmits ultrasonic data through the ultrasonic channel or receives ultrasonic data after being reflected by an object. Because the ultrasonic channel and the earphone channel have a common part, at the fourth moment, the closing of the earphone channel will cause the above common part to be closed, which will affect the normal use of the ultrasonic channel.
[0134] like Figure 3B As shown in (b), at the first moment, the proximity light service is triggered, the electronic device opens the ultrasonic path, transmits ultrasonic data through the ultrasonic path or receives ultrasonic data reflected by an object. At the fourth moment, the proximity light service is terminated, and the electronic device closes the ultrasonic path.
[0135] from Figure 3B (b) shows that after the ultrasonic path is opened and before the ultrasonic path is closed. That is, at the second moment, the electronic device has established a connection with the headset, and the electronic device plays audio data, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. Alternatively, at the second moment, the electronic device plays audio data, and at the third moment, the electronic device establishes a connection with the headset, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. Because the ultrasonic path and the headset path have a common part, at the fourth moment, the closure of the ultrasonic path will cause the above common part to be closed, which will affect the normal operation of the headset path.
[0136] like Figure 3CAs shown in (a), at the first moment, the electronic device has established a connection with the headset, and the electronic device plays audio data, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. Alternatively, at the first moment, the electronic device plays audio data. Because at the first moment, the electronic device has not established a connection with the headset, the audio data is played through the speaker or the receiver. In the process of playing the audio data, that is, at the third moment, the electronic device establishes a connection with the headset, thereby triggering a headset play event, and transmitting audio data or receiving voice data through the headset path. At the fifth moment, the headset play event ends, and the electronic device closes the headset path.
[0137] from Figure 3C As can be seen from (a), in the process of transmitting audio data through the headphone channel, that is, at the second moment, the proximity light service is triggered, the electronic device opens the ultrasonic channel, and transmits ultrasonic data through the ultrasonic channel or receives ultrasonic data after being reflected by an object. At the fourth moment, the proximity light service is ended, and the electronic device closes the ultrasonic channel. Because the ultrasonic channel and the headphone channel have a common part, at the fourth moment, the closure of the ultrasonic channel will cause the above common part to be closed, which will affect the normal use of the headphone channel.
[0138] like Figure 3C As shown in (b), at the first moment, the proximity light service is triggered, the electronic device opens the ultrasonic path, transmits ultrasonic data through the ultrasonic path or receives ultrasonic data reflected by an object. At the fifth moment, the proximity light service is terminated, and the electronic device closes the ultrasonic path.
[0139] from Figure 3C (b) shows that after the ultrasonic path is opened and before the ultrasonic path is closed. That is, at the second moment, the electronic device has established a connection with the headset, and the electronic device plays audio data, thereby triggering a headset playback event, and transmitting audio data or receiving voice data through the headset path. Or, at the second moment, the electronic device plays audio data, and at the third moment, the electronic device establishes a connection with the headset, thereby triggering a headset playback event, and transmitting audio data or receiving voice data through the headset path. At the fourth moment, the headset playback event ends, and the electronic device closes the headset path. Because the ultrasonic path and the headset path have a common part, at the fourth moment, the closure of the headset path will cause the above-mentioned common part to be closed, which will affect the normal operation of the ultrasonic path.
[0140] In view of this, the present application provides a conflict resolution method and related device for ultrasonic path and headphone path, wherein the ultrasonic thread is used to manage the ultrasonic path, and the headphone thread is used to manage the headphone path. Information interaction between threads is used to control the ultrasonic path and the headphone path so as not to cause conflict, thereby ensuring the stability of proximity light services and headphone playback events.
[0141] Electronic devices are devices that have "proximity light service" functions and establish connections with peripheral devices (such as wired headphones, etc.), such as smartphones, tablets, large-screen devices, etc.
[0142] First, the scenario in which the ultrasonic path and the earphone path do not conflict with each other provided in the embodiment of the present application is described in combination with a user interface (UI) provided by an electronic device.
[0143] Scenario 1: Before opening the earphone channel, if the ultrasonic channel is in working state, the ultrasonic channel is closed.
[0144] See also FIG. 4A to FIG. 4C , Figure 4A This is a schematic diagram of an interface for triggering a proximity light service provided in an embodiment of the present application. Figure 4B is a schematic diagram of an interface for triggering a headphone playback event provided in an embodiment of the present application, Figure 4C It is an interactive schematic diagram of opening an earphone channel provided in an embodiment of the present application.
[0145] It should be noted that the call state may include the electronic device 100 being in an instant call state, or may include the electronic device being in a non-instant call state, that is, the call application referred to in this application may include an instant call function or a non-instant call function. Instant calls may include voice calls, video calls, etc. Non-instant calls may include voice messages, etc.
[0146] Therefore, in the embodiment of the present application, the call state of the electronic device 100 may include a state provided by all applications in which the user may need to put the ear close to listen to the voice call or voice message content, thereby causing the electronic device 100 to repeatedly turn on or off the screen. Next, the embodiment of the present application is explained by taking a voice call as an example.
[0147] See also Figure 4A , Figure 4A The user interface 41 and the user interface 42 of the "call" application on an electronic device such as a smart phone are exemplarily shown. Figure 4AAs shown, the user interface 41 may include a caller information bar 410, a reject control 411, and an answer control 412. The caller information bar 410 includes the caller's name, the location of the caller number, and the operator to which it belongs, etc.). When the user wants to answer the incoming call, he can click the answer control 412, and when the user wants to reject the incoming call, he can click the reject control 411.
[0148] When the electronic device 100 detects a touch operation (such as a click operation on the icon 401) acting on the answering control 412 through the touch sensor 180K, in response to the operation, the Figure 4A The user interface 42 is shown as an example. The user interface 42 may include a call duration bar 413 (used to display the call duration after the call is connected) and a call function area 414, which may include a recording control, a waiting control, an add call control, a video call, a mute control, a contact control, etc.; the bottom of the user interface 42 further includes common call function controls such as a dialing keypad 415, a hang-up control 416, and a hands-free control 417.
[0149] Among them, "call" is a call application on electronic devices such as smart phones and tablet computers, and this application does not limit the name of this application. In this application, the electronic device 100 is in a call state, which means the state of the electronic device 100 after detecting a touch operation on the answer control 412 and before detecting a touch operation on the hang-up control 416. That is, after the user answers the call and before hanging up the call.
[0150] When an incoming call is initially answered (for example, the answering control 412 is just clicked), the proximity light service is triggered, and the "call" application turns on the proximity light. The electronic device 100 creates an ultrasonic thread and calls the ultrasonic thread to open the ultrasonic path. Therefore, the electronic device 100 can transmit ultrasonic data through the ultrasonic path, and then send ultrasonic data through the earpiece 170B, and receive ultrasonic data reflected by the object 200 through the microphone 170C. The electronic device 100 calculates the amplitude, frequency, phase and other characteristics of the ultrasonic data sent and received to obtain a proximity result. The electronic device 100 then combines the proximity result, the data collected by the gyroscope sensor 180B and the acceleration sensor 180E, and calculates whether the object 200 and the electronic device 100 are in a close state or a distant state. Object 200 can refer to other objects, such as clothing, books, etc. Object 200 can also refer to a body part of the user, such as an ear, face, finger, etc. Of course, the object mentioned in the embodiment of the present application refers not only to one, but also to multiple, which can be determined according to the actual situation.
[0151] For example Figure 4A As shown, after receiving an incoming call, the electronic device 100 can play audio data, such as voice call content, through the earpiece 170B.
[0152] like Figure 4B As shown, during the process of answering a call, the headset 300 is connected via the USB interface 130, thereby triggering a headset play event, and the electronic device creates a headset thread. Figure 4C As shown, the electronic device calls the earphone thread to send a first notification message to the ultrasonic thread, and the first notification message includes a message to open the earphone channel.
[0153] Before opening the headphone channel, the electronic device may also set the headphone thread to a blocked state. The headphone thread in the blocked state cannot handle matters related to the headphone channel, such as opening or closing the headphone channel. In a possible implementation, the electronic device needs to lock and protect the headphone thread in the process of calling the headphone thread to send a first notification message to the ultrasonic thread, that is, the headphone thread may be blocked by a conditional variable so that the headphone thread is in a blocked state within a preset time. The preset time may be 1 second. The conditional variable may be whether the ultrasonic channel is closed. That is, when no message that satisfies the conditional variable is received, the headphone thread will continue to be blocked. The headphone thread in the blocked state cannot handle matters related to the headphone channel, such as if the headphone channel is to be closed, because the headphone thread is in a blocked state, the headphone thread cannot be called to close the headphone channel.
[0154] For example Figure 4C As shown, after the ultrasonic thread receives the first notification message, it determines whether to close the ultrasonic path. If closed, the ultrasonic thread is called to close the ultrasonic path; if not closed, the ultrasonic thread is not called. In a possible implementation, in the ultrasonic thread, the electronic device 100 can determine whether to close the ultrasonic path according to the working state of the earphone path, whether an application triggers the proximity light service, and whether the ultrasonic path is open.
[0155] In case 1, the working state of the earphone channel is open, an application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is called to close the ultrasonic channel.
[0156] In case 2, the earphone channel is in the open state, an application triggers the proximity light service, and the ultrasonic channel is closed, so the ultrasonic thread is not called.
[0157] Case three, the working state of the earphone channel is open, no application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is called to close the ultrasonic channel.
[0158] In case 4, the working state of the earphone channel is open, no application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is not called.
[0159] In case five, the working state of the earphone channel is closed, an application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is not called.
[0160] Case six: the earphone channel is in the closed state, an application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is not called.
[0161] Case seven, the working state of the earphone channel is closed, no application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is called to close the ultrasonic channel.
[0162] Case eight, the working state of the earphone channel is closed, no application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is not called.
[0163] It should be noted that situations 1 to 8 are pre-set in the electronic device 100. When the electronic device 100 receives conditions that meet the corresponding situations, it will perform corresponding processing on the ultrasonic path. In scenario 1 of the embodiment of the present application, after the ultrasonic thread receives the message that the headphone path is to be opened, it indicates that the working state of the headphone path is open, which corresponds to situations 1 to 4 in situations 1 to 8. According to situations 1 to 4, it is necessary to determine whether ultrasonic data is working. If the ultrasonic path is open, it means that there is an ultrasonic flow working, and the ultrasonic thread is called to close the ultrasonic path. If the ultrasonic path is closed, it means that there is no ultrasonic flow working, and the ultrasonic thread is not called.
[0164] For example Figure 4B As shown, if the call state has not ended, the "Call" application will continue to turn on the proximity light function. Therefore, the electronic device 100 will continue to send or receive ultrasonic data through the ultrasonic path. In order to avoid conflicts between the ultrasonic path and the earphone path, the electronic device 100 will call the ultrasonic thread to close the ultrasonic path. That is, when the ultrasonic flow is working, the ultrasonic path is closed. Therefore, after closing the ultrasonic path, the electronic device cannot send or receive ultrasonic data through the ultrasonic path.
[0165] If the call state has ended, it means that the "call" application and the proximity light function are turned off. Therefore, the electronic device 100 turns off the ultrasonic path and cannot send and receive ultrasonic data through the ultrasonic path.
[0166] In such Figure 4CAs shown, after determining that the ultrasonic channel is closed, the ultrasonic thread sends a second notification message to the headphone thread. The second notification message includes the processing result of the ultrasonic path according to the first notification message. For example, if there is a workflow working in the ultrasonic path, the processing result is to close the ultrasonic path; if there is no ultrasonic data stream working in the ultrasonic path, it means that the ultrasonic path has been closed, and the processing result is not to call the ultrasonic thread. After the headphone thread receives the second notification message, it determines that the ultrasonic path has been closed according to the second notification message. If the conditional variable is satisfied, the headphone thread can be set to a non-blocking state. The electronic device can call the headphone thread to open the headphone path.
[0167] It can be understood that when there is an ultrasonic data stream, the ultrasonic path is in an open state; when there is no ultrasonic data stream, the ultrasonic path is in a closed state.
[0168] Therefore, in Figure 4B As shown, the electronic device 100 can transmit audio data through the earphone channel, play the audio data through the left and right channels of the earphone 300, and receive the user's voice data through the microphone 301 of the earphone 300 to make a voice call.
[0169] It can be seen that if the headphone play event is triggered, the headphone thread can be called to notify the ultrasonic thread to open the headphone channel and set the headphone thread to a blocked state. In this way, after determining that the ultrasonic path has been closed, the ultrasonic thread notifies the headphone thread that the ultrasonic path has been closed. When it is determined that the ultrasonic path is closed, the headphone thread is set to a non-blocking state and the headphone thread is called to open the headphone path. This can prevent the ultrasonic path from conflicting with the headphone path during the process of closing the ultrasonic path.
[0170] Scenario 2: After closing the earphone channel, if the ultrasonic channel needs to be opened, open the ultrasonic channel.
[0171] See also FIG. 5A to FIG. 5C , Figure 5A is a schematic diagram of an interface for closing an earphone playback event provided in an embodiment of the present application, Figure 5B is a schematic diagram of an interface for triggering a proximity event provided in an embodiment of the present application. Figure 5C It is an interactive schematic diagram of opening an ultrasonic path provided in an embodiment of the present application.
[0172] In one possible implementation, Figure 4A-4B Afterwards, realize Figure 5A The process shown.
[0173] like Figure 5AAs shown, after the electronic device establishes a voice call, a user interface 42 may be displayed. The user interface 42 may include a call duration bar 413 (used to display the call duration after the call is connected) and a call function area 414, which may include a recording control, a waiting control, an add call control, a video call, a mute control, a contact control, etc.; the bottom of the user interface 42 further includes common call function controls such as a dialing keyboard 415, a hang-up control 416, and a hands-free control 417. During a voice call, for example, when the call duration is 00:10, the electronic device 100 establishes a connection with the headset 300 through the USB interface 130, and the user can make a voice call through the headset 300. That is, the electronic device 100 creates a headset thread and calls the headset thread to open the headset path. The electronic device 100 can transmit audio data through the headset channel, and then the user can receive the audio data through the left and right channels of the headset 300. The microphone 301 of the headset 300 can receive the user's voice data and send it to the electronic device 100 through the headset line. The electronic device 100 can receive voice data through the headset path.
[0174] For example, Figure 5A As shown, when the voice call duration is 00:35, when the user does not want to make a voice call through the headset 300, the interface of the headset 300 can be unplugged from the USB interface 130 of the electronic device 100. After unplugging, the headset 300 is disconnected from the electronic device 100, thereby ending the headset playback event, and the electronic device 100 calls the headset thread to close the headset path.
[0175] like Figure 5C As shown, the electronic device 100 calls the earphone thread to close the earphone path. After closing the earphone path, the earphone thread is called to send a first notification message to the ultrasonic thread. The first notification message includes a message that the earphone path has been closed. In addition, after closing the earphone path, the electronic device 100 can set the earphone thread to a blocked state. It should be noted that before opening the earphone path, it is necessary to determine whether the ultrasonic path is closed. Therefore, when closing the earphone path, because the ultrasonic path is closed, the closing of the earphone path will not affect the state of the ultrasonic path.
[0176] In a possible implementation, when the electronic device 100 calls the earphone thread to send the first notification message to the ultrasonic thread, it is necessary to lock the earphone thread for protection, that is, the earphone thread can be blocked by a conditional variable so that the earphone thread is blocked within a preset time. The preset time can be 1 second. The conditional variable can be whether the ultrasonic thread has completed the transaction on the ultrasonic path. That is, when there is no message that satisfies the conditional variable, the earphone thread will continue to be blocked.
[0177] When the ultrasonic thread receives the first notification message about closing the earphone channel, it is necessary to determine whether the ultrasonic flow needs to work, which can also be understood as whether the ultrasonic channel needs to be opened. In a possible implementation, in the ultrasonic thread, the electronic device 100 can determine whether to open the ultrasonic channel according to the working state of the earphone channel, whether the application triggers the proximity light service, and the working state of the ultrasonic channel.
[0178] In case 1, the working state of the earphone channel is open, an application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is not called.
[0179] In case 2, the earphone channel is in the open state, an application triggers the proximity light service, and the ultrasonic channel is closed, so the ultrasonic thread is not called.
[0180] Case three, the working state of the earphone channel is open, no application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is not called.
[0181] In case 4, the working state of the earphone channel is open, no application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is not called.
[0182] In case five, the working state of the earphone channel is closed, an application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is not called.
[0183] Case six: the earphone channel is in the closed state, an application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is called to open the ultrasonic channel.
[0184] Case seven, the working state of the earphone channel is closed, no application triggers the proximity light service, and the ultrasonic channel is open, then the ultrasonic thread is not called.
[0185] Case eight, the working state of the earphone channel is closed, no application triggers the proximity light service, and the ultrasonic channel is closed, then the ultrasonic thread is not called.
[0186] It should be noted that situations one to eight are pre-set in the electronic device 100. When the electronic device 100 receives conditions that meet the corresponding situations, it will perform corresponding processing on the ultrasonic path. In scenario two of the embodiment of the present application, after the ultrasonic thread receives a message that the headphone path is closed, it indicates that the working state of the headphone path is closed, which corresponds to situations five to eight in situations one to eight. It is necessary to determine whether to open the ultrasonic path. If an application triggers a proximity light service and the ultrasonic path is closed, it means that an ultrasonic flow needs to work, and the ultrasonic thread is called to open the ultrasonic path. If no application triggers a proximity light service, the ultrasonic thread is not called.
[0187] For example, if Figure 5B As shown, since the call state still exists, it means that the "call" application will continue to open the proximity light function, so the proximity light service has not ended. The electronic device 100 also needs the ultrasonic flow to work, so it needs to send or receive ultrasonic data through the ultrasonic path. Therefore, the electronic device 100 calls the ultrasonic thread to open the ultrasonic path, transmits ultrasonic data through the ultrasonic path, and then sends ultrasonic data through the earpiece 170B, and receives ultrasonic data reflected by the object 201 through the microphone 170C.
[0188] If the call state has ended, it means that the ultrasonic flow is not needed and the ultrasonic thread is not called.
[0189] After the ultrasonic thread has completed the transaction on the ultrasonic path, the electronic device 100 calls the ultrasonic thread to send a second notification message to the earphone thread, and the second notification message includes that the ultrasonic thread has completed the transaction on the ultrasonic path. After receiving the second notification message, the earphone thread determines that the transaction on the ultrasonic path has been completed in the ultrasonic thread according to the second notification message, so that the above conditional variables are met, and wakes up the blocked earphone thread. Therefore, the earphone thread can be set to a non-blocking state, and the earphone thread in a non-blocking state can process other transactions.
[0190] It can be seen that after the headphone playback event ends, the headphone thread can be called to notify the ultrasonic thread that the headphone path has been closed and the headphone thread is set to a blocked state. Because the headphone thread is in a blocked state, the state of the headphone path will not be changed. Therefore, in the process of processing the ultrasonic path in the ultrasonic thread, the state of the ultrasonic path will not be affected by the change in the state of the headphone path, resulting in a state confusion. When it is determined that the ultrasonic thread has been executed, the headphone thread is set to a non-blocking state, and the headphone thread can be used to process other matters.
[0191] Based on the above embodiments, the following describes a conflict approach method for ultrasonic approach light path and earphone path provided by the embodiment of the present application. The method can be applied to the electronic device 100 shown in the above content, and the method may include but is not limited to the following steps:
[0192] See also Figure 6 , Figure 6 It is a flow chart of a conflict approach method of an ultrasonic approach light path and an earphone path provided in an embodiment of the present application.
[0193] Step S601: the electronic device 100 triggers a first event and sets the earphone thread to a blocked state.
[0194] Among them, the headset thread in the blocked state is not used to process matters related to the headset channel, such as opening the headset channel or closing the headset channel, and so on.
[0195] When the user controls the electronic device 100 to initiate an interaction event, the processor in the electronic device 100 will initiate a thread for executing related tasks in the user interaction event to handle the event in response to the event. The thread used to execute the user interaction event and process the headphone path is represented by a headphone thread, and the thread used to execute the user interaction event and process the ultrasonic path is represented by an ultrasonic thread.
[0196] In a possible implementation, the first event includes before the headphone channel is opened and after the headphone channel is closed.
[0197] In a possible implementation, the electronic device 100 sets the earphone thread to a blocked state before opening the earphone path. Therefore, before opening the earphone path, the earphone channel may not be affected by the ultrasonic path, preventing the state of the earphone path from being affected during the process of closing the ultrasonic path.
[0198] In another possible implementation, the electronic device 100 sets the headphone thread to a blocked state after closing the headphone path. Therefore, after closing the headphone path, the state of the headphone path will not be changed. Therefore, there is no impact on the state of the ultrasonic channel due to the change in the state of the headphone path. For example, if the headphone path is not set to a blocked state, during the process of sending and receiving ultrasonic data through the ultrasonic path, if the headphone path is repeatedly opened and closed, the closing of the headphone path will affect the state of the ultrasonic path.
[0199] In a possible implementation, the electronic device 100 needs to lock the earphone thread for protection when calling the earphone thread to send the first notification message to the ultrasonic thread. That is, the electronic device 100 can block the earphone thread through the conditional variable so that the earphone thread is in a blocked state within a preset time. The preset time can be 1 second.
[0200] When the first event is before the earphone channel is turned on, the condition variable may be whether the ultrasonic channel is turned off. That is, when the first notification message that satisfies the condition variable is not received, the earphone thread will continue to be blocked.
[0201] When the first event is closing the earphone channel, the condition variable may be whether the ultrasonic thread is completed. That is, when no message that satisfies the condition variable is received, the earphone thread will continue to be blocked.
[0202] It should be noted that the preset time can be other times, and this application does not impose any restrictions on the value of the preset time.
[0203] Step S602: The electronic device 100 calls the earphone thread to send a first notification message to the ultrasonic thread.
[0204] The first notification message includes a message related to the first event.
[0205] In a possible implementation, when the first event is opening the earphone channel, the first notification message includes a message that the earphone channel is about to be opened.
[0206] In another possible implementation, when the first event is closing the earphone channel, the first notification message includes a message indicating that the earphone channel has been closed.
[0207] Step S603: The electronic device 100 calls the ultrasonic thread to send a second notification message to the earphone thread.
[0208] The second notification message includes a processing result of the ultrasonic path according to the first notification message.
[0209] In one possible implementation, before the headphone channel is opened, the ultrasonic thread receives the first notification message from the headphone thread and learns that the headphone channel is about to be opened. The electronic device 100 determines whether to close the ultrasonic channel. That is, the electronic device 100 needs to determine whether ultrasonic data is being sent or received through the ultrasonic channel at this time. If the application triggers the proximity light service and the ultrasonic channel is open, it means that ultrasonic data is being sent or received through the ultrasonic channel, and the ultrasonic channel needs to be closed. Therefore, when it is determined that the ultrasonic channel needs to be closed, the ultrasonic thread is called to close the ultrasonic channel. If no ultrasonic stream is working, it means that the ultrasonic channel is closed. The ultrasonic channel is not processed. After determining that the ultrasonic channel is closed, a second notification message including closing the ultrasonic channel is generated.
[0210] In another possible implementation, after the headphone channel is closed, the ultrasonic thread receives the first notification message from the headphone thread and learns that the headphone channel has been closed. The electronic device 100 determines whether to open the ultrasonic channel. That is, the electronic device 100 determines whether it is necessary to send or receive ultrasonic data through the ultrasonic channel. If an application triggers an ultrasonic proximity light service and the ultrasonic channel is closed, indicating that ultrasonic data needs to be sent or received through the ultrasonic channel, the ultrasonic thread is called to open the ultrasonic channel. If no application triggers an ultrasonic proximity light service, the ultrasonic thread is not called. After the judgment is completed, a second notification message containing the completion of the ultrasonic thread execution is generated.
[0211] In one possible implementation, see Figure 7 , Figure 7 FIG. 1 is a schematic diagram of a process for opening an ultrasonic path provided in an embodiment of the present application. Figure 7 As shown, the electronic device 100 can call the ultrasonic thread to maintain the status bit of the headphone path being opened or closed. That is, before calling the ultrasonic thread to open the ultrasonic thread, the electronic device 100 needs to determine the status bit of the headphone path. If the status bit of the headphone path is to open the headphone path, for example, the headphone is connected to the electronic device 100, the electronic device 100 does not call the ultrasonic thread to open the ultrasonic path. If the status of the headphone path is to close the headphone path, for example, the headphone is not connected to the electronic device 100, the electronic device 100 calls the ultrasonic thread to open the ultrasonic path.
[0212] Step S604: The electronic device 100 sets the earphone thread to a non-blocking state according to the second notification message.
[0213] The headphone thread in a non-blocking state is used to process transactions related to the headphone channel.
[0214] In a possible implementation, before opening the earphone path, the electronic device 100 determines that the ultrasonic path has been satisfied according to the second notification message, and satisfies the conditional variable of the earphone thread. When the conditional variable is satisfied, the earphone thread is set to a non-blocking state. Therefore, the electronic device 100 can call the earphone thread in a non-blocking state to open the earphone path. That is, the earphone thread in a non-blocking state is used to open the earphone path.
[0215] In another possible implementation, after closing the earphone path, the electronic device 100 determines, based on the second notification message, that the transaction of closing the ultrasonic path has been completed in the ultrasonic thread, and the condition variable of the earphone thread is satisfied. When the condition variable is satisfied, the earphone thread is set to a non-blocking state. Therefore, the electronic device 100 can call the earphone thread to process other transactions. That is, the earphone thread in a non-blocking state is used to process other transactions.
[0216] One or more of the above modules or units may be implemented in software, hardware, or a combination of both.
[0217] When any of the above modules or units are implemented in software, the software exists in the form of computer program instructions and is stored in a memory, and the processor can be used to execute the program instructions to implement the above method flow. The processor may include but is not limited to at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor and other types of computing devices that run software, each of which may include one or more cores for executing software instructions to perform operations or processing. The processor may be a separate semiconductor chip, or it may be integrated into a semiconductor chip together with other circuits. For example, it may form a SoC (system on chip) with other circuits (such as a codec circuit, a hardware acceleration circuit, or various buses and interface circuits), or it may be integrated into the ASIC as a built-in processor of an ASIC. The ASIC with an integrated processor may be packaged separately or with other circuits. In addition to the core for executing software instructions for operations or processing, the processor may further include necessary hardware accelerators, such as field programmable gate arrays (FPGAs), PLDs (programmable logic devices), or logic circuits that implement dedicated logic operations.
[0218] When the above modules or units are implemented in hardware, the hardware can be any one or any combination of a CPU, a microprocessor, a DSP, an MCU, an artificial intelligence processor, an ASIC, a SoC, an FPGA, a PLD, a dedicated digital circuit, a hardware accelerator or a non-integrated discrete device, which can run the necessary software or not rely on the software to execute the above method flow.
Claims
1. A solution to the conflict between an ultrasonic path and an earphone path, characterized in that: Applied to an electronic device, the electronic device comprises an ultrasonic path and an earphone path, the ultrasonic path is used to transmit ultrasonic data, the earphone path is used to transmit audio data, the method comprises: triggering a first event to set the earphone thread to a blocked state, wherein the earphone thread in the blocked state is not used to process transactions related to the earphone path; Calling the earphone thread to send a first notification message to the ultrasonic thread, wherein the first notification message includes a message related to the first event; Calling the ultrasonic thread to send a second notification message to the earphone thread, wherein the second notification message includes a processing result of processing the ultrasonic path according to the first notification message; The headset thread is set to a non-blocking state according to the second notification message, wherein the headset thread in the non-blocking state is used to process transactions related to the headset channel.
2. The method according to claim 1, characterized in that: The step of setting the headset thread to a blocked state includes: The earphone thread is blocked by a conditional variable so that the earphone thread is in the blocking state within a preset time.
3. The method according to claim 1 or 2, characterized in that: The triggering of the first event to set the headset thread to a blocked state includes: Before opening the headphone path, the headphone thread is set to the blocking state.
4. The method according to claim 3, characterized in that The step of setting the headset thread to a non-blocking state according to the second notification message includes: Determining, according to the second notification message, that the ultrasonic path has been closed, and satisfying the conditional variable of the earphone thread; When the condition variable is satisfied, setting the headset thread to a non-blocking state; The headset thread in the non-blocking state is called to open the headset path.
5. The method according to claim 3, characterized in that: After calling the earphone thread to send the first notification message to the ultrasonic thread, and before calling the ultrasonic thread to send the second notification message to the earphone thread, the method further includes: In the case where it is determined that the ultrasonic path is to be closed, calling the ultrasonic thread to close the ultrasonic path; After determining that the ultrasonic path is closed, the second notification message is generated.
6. The method according to claim 1 or 2, characterized in that: When the earphone path is closed, the ultrasonic path is in a closed state, and the triggering of the first event to set the earphone thread to a blocked state includes: After closing the earphone path, setting the earphone thread to the blocking state.
7. The method according to claim 6, characterized in that The step of setting the headset thread to a non-blocking state according to the second notification message includes: Determining, according to the second notification message, that the transaction regarding the ultrasonic path has been completed in the ultrasonic thread, and that the condition variable of the earphone thread is satisfied; When the condition variable is met, the headset thread is set to a non-blocking state.
8. The method according to claim 6, characterized in that After calling the earphone thread to send the first notification message to the ultrasonic thread, and before calling the ultrasonic thread to send the second notification message to the earphone thread, the method further includes: In the case where it is determined in the ultrasonic thread that the ultrasonic path is to be opened, calling the ultrasonic thread to open the ultrasonic path; In the case where it is determined in the ultrasonic thread that the ultrasonic path is not to be opened, the ultrasonic thread is not called; After the ultrasonic thread is executed, the second notification message is generated.
9. The method according to claim 8, characterized in that The calling of the ultrasonic thread to open the ultrasonic path includes: Calling the ultrasonic thread to determine the state of the earphone channel; If the earphone path is in a closed state, calling the ultrasonic thread to open the ultrasonic path; If the earphone path is in an open state, the ultrasonic path is not opened.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes the method as described in any one of claims 1-9.
11. A computer program product comprising instructions, characterized in that When the computer program product is run on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 9.
Citation Information
Patent Citations
Method and device for handling timeout of system service
CN109891392A
Automatic driving system based on computer vision and ultrasonic radar redundancy and control method thereof
CN111142519A
Echo data elimination method and device, terminal equipment and storage medium
CN112489671A
Method, device and system for calling using bluetooth earpiece
CN112913321A
Binaural consistency control method, graphical interface, system and related device
CN114827973A
