Audio output method, electronic device and storage medium

By using proximity sensors in the mobile phone to judge user behavior and determine the output method according to the type of audio output device, the problem of the user not outputting sound when the mobile phone connects other audio output devices is solved, and the user experience and flexibility of audio signal output is improved.

CN116527810BActive Publication Date: 2025-03-11HONOR DEVICE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310651827.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2016-08-26
Publication Date
2025-03-11
Estimated Expiration
2036-08-26

AI Technical Summary

Technical Problem

In the prior art, when a user connects other audio output devices to the mobile phone, the earpiece does not output a voice signal on the phone, resulting in poor user experience and may mistakenly think that the call is abnormal and hang up the phone.

Method used

The proximity data is obtained through the proximity sensor. When the data meets the preset conditions, the handset of the mobile phone outputs an audio signal, and determines whether the audio signal is output through the handset or the audio output device according to the type of the audio output device.

Benefits of technology

Ensure that users hear sounds through the earpiece when they place their phones in their ears to answer, which improves the user experience, and flexibly selects the output method according to the type of audio output device, improving the flexibility of audio signal output.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116527810B_ABST
    Figure CN116527810B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention relates to a method for outputting audio, an electronic device, and a storage medium. The method is applied to an electronic device having a proximity sensor, and the method includes: when the electronic device is connected to an audio output device and has an audio signal output, obtaining proximity data of the proximity sensor; when the proximity data meets a preset condition, the earpiece of the electronic device outputs the audio signal, and determining the type of the audio output device; and determining whether the audio output device outputs the audio signal based on the type of the audio output device. As can be seen from the above, in an embodiment of the present invention, when an electronic device including a mobile phone is connected to other audio output devices, the earpiece can output an audio signal under certain conditions to improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The application number of the original application is 201680080878.8, and the original application date is August 26, 2016. The entire content of the original application is incorporated into this application by reference. Technical Field

[0002] The embodiments of the present invention relate to the field of terminals, and in particular to a method for outputting audio, an electronic device, and a storage medium. Background Art

[0003] Currently, in addition to the built-in earpiece, mobile phones can also be connected to other audio output devices, such as wired headphones, Bluetooth headphones, external speakers, etc.

[0004] In the prior art, when a mobile phone receives an instruction message input by a user to answer a new incoming call, it first determines whether the mobile phone is currently connected to an audio output device other than a handset; if other audio output devices are connected, the call voice signal is output through the audio output device; if no other audio output devices are connected, the call voice signal is output through the handset.

[0005] As can be seen from the above, in the prior art, if it is determined that the mobile phone is connected to other audio output devices, the call voice signal is output through the audio output device, and the mobile phone receiver does not output the call voice signal. When the user uses the mobile phone receiver to answer the call, he cannot hear any sound. At this time, the user may mistakenly think that the call is abnormal and hang up the phone. Or, the user first realizes that he has used the wrong answering device to answer the call sound, and then changes the answering device to hear the call sound normally, which is a poor user experience. Summary of the invention

[0006] The embodiments of the present invention provide a method for outputting audio, an electronic device, and a storage medium, which can improve the user experience when an electronic device including a mobile phone is connected to other audio output devices.

[0007] In a first aspect, a method for outputting audio is provided, which is applied to an electronic device with a proximity sensor, the method comprising: when the electronic device is connected to an audio output device and has an audio signal output, obtaining proximity data of the proximity sensor; when the proximity data meets a preset condition, an earpiece of the electronic device outputs an audio signal to determine the type of the audio output device; and according to the type of the audio output device, determining whether the audio output device outputs an audio signal.

[0008] As can be seen from the above, in the embodiments of the present invention, it can be determined that the user has placed the electronic device (such as a mobile phone) next to the ear to answer the call by using proximity data to meet preset conditions, so that the user can also hear the sound through the earpiece when placing the electronic device next to the ear to answer the call. The user experience is improved when the electronic device is connected to other audio output devices; in addition, depending on the type of audio output device, there are two ways to output the audio signal: both the earpiece and the audio output device output the audio signal, and only the earpiece outputs the audio signal. According to the type of audio output device, one of the ways is selected to output the audio signal, thereby improving the flexibility of outputting the audio signal.

[0009] In a possible implementation, the method further includes: when a receiver of the electronic device outputs an audio signal, the electronic device outputs prompt information, where the prompt information is a prompt text or a prompt sound.

[0010] As can be seen from the above, in the embodiments of the present invention, since usually after the electronic device is connected to the audio output device, the audio signal is output only through the audio output device and the earpiece does not output the audio signal, when the earpiece of the electronic device outputs the audio signal, the electronic device outputs a prompt message, which can improve the user experience.

[0011] In a possible implementation, the method further includes: determining, according to the type of the audio output device, whether the audio output device outputs an audio signal, including: when the audio output device is a headset, the audio output device outputs an audio signal.

[0012] As can be seen from the above, in an embodiment of the present invention, when the type of the audio output device shows that the audio output device is a headset, that is, the audio output device does not have an external speaker function, the audio signal is output through the earpiece and the headset. When the proximity data satisfies the preset conditions to identify the user behavior is inaccurate, the user can still hear the sound through the headset.

[0013] In a possible implementation, determining whether the audio output device outputs an audio signal according to the type of the audio output device includes: when the audio output device is an external speaker, the audio output device does not output an audio signal.

[0014] As can be seen from the above, in the embodiment of the present invention, when the type of the audio output device shows that the audio output device has an external speaker function, the audio signal is output only through the earpiece, which can protect the user's privacy and prevent others from hearing the audio signal.

[0015] In a possible implementation, the proximity data is the distance between the electronic device and the obstacle, and the proximity data satisfies a preset condition, including: the distance between the electronic device and the obstacle is less than or equal to a preset distance.

[0016] As can be seen from the above, in the embodiment of the present invention, the method of identifying user behavior is simple, easy to implement, and has a fast judgment speed, which is particularly suitable for the specific scenario where the user puts the mobile phone to the ear to answer the call.

[0017] In a possible implementation manner, the duration for which the proximity data meets a preset condition is greater than a preset time.

[0018] As can be seen from the above, in the embodiment of the present invention, by judging that the duration of the proximity data satisfying the preset condition is greater than the preset time, the proximity data is judged to satisfy the preset condition, thereby improving the accuracy of judging that the proximity data satisfies the preset condition. In one possible implementation, the proximity data represents the distance between the electronic device and the obstacle; when the electronic device is connected to an audio output device and an audio signal is output, the proximity data of the proximity sensor is obtained, including: when the electronic device is connected to an audio output device and an audio signal is output, multiple proximity data of the proximity sensor within a preset time period are obtained; the proximity data satisfies the preset condition, specifically: at least one proximity data among the multiple proximity data satisfies the first preset condition, and / or, the change trend of the multiple proximity data over time satisfies the second preset condition.

[0019] Among them, at least one proximity data among the multiple proximity data satisfies the first preset condition, which can be specifically: at least one proximity data among the multiple proximity data satisfies a distance less than or equal to a preset distance; the changing trend of the multiple proximity data over time satisfies the second preset condition, which can be specifically: the changing trend of the multiple proximity data over time satisfies a decreasing trend.

[0020] As can be seen from the above, in the embodiment of the present invention, by acquiring multiple proximity data within a preset time period and combining the change trends of the multiple proximity data to determine whether the proximity data meets the preset conditions, the user behavior is determined, which can improve the accuracy of the judgment result.

[0021] In a possible implementation, when the proximity data meets a preset condition, the earpiece of the electronic device outputs an audio signal, including: when the proximity data meets the preset condition, setting the audio type of the audio signal to a custom audio type; and outputting the audio signal through the earpiece according to a correspondence between the preset custom audio type and the earpiece.

[0022] As can be seen from the above, with regard to the audio signal output situation after a general electronic device is connected to an audio output device, that is, the audio signal is output only through the audio output device, and the earpiece does not output the audio signal, in an embodiment of the present invention, in order to achieve the purpose of the earpiece of the electronic device outputting an audio signal after the electronic device is connected to the audio output device when the proximity data meets a preset condition, a custom audio type is adopted, and the corresponding relationship between the custom audio type and the earpiece is pre-set. This implementation method is relatively clever and easy to implement.

[0023] On the other hand, an electronic device is provided, which includes a processor, a memory, an earpiece, a proximity sensor and an interface circuit; wherein the memory is used to store computer executable program code, and the program code includes instructions. When the processor executes the instructions, the method of the first aspect mentioned above is implemented. Since the implementation method and beneficial effects of the electronic device to solve the problem can refer to the first aspect and the possible implementation methods and beneficial effects of the first aspect mentioned above, the implementation of the electronic device can refer to the implementation of the method of the first aspect, and the repeated parts will not be repeated.

[0024] On the other hand, an embodiment of the present invention provides an electronic device, which includes an acquisition unit and a processing unit; the acquisition unit is used to acquire proximity data of a proximity sensor when the electronic device is connected to an audio output device and has an audio signal output; the processing unit is used to output an audio signal from a receiver of the electronic device and determine the type of the audio output device when the proximity data acquired by the acquisition unit meets a preset condition; and determine whether the audio output device outputs an audio signal based on the type of the audio output device. Based on the same inventive concept, since the principle and beneficial effects of the electronic device in solving the problem can refer to the above-mentioned first aspect and the various possible implementation methods of the first aspect and the beneficial effects brought about, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0025] On the other hand, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used in the design scheme of the method of the first aspect mentioned above.

[0026] Compared with the prior art, in the embodiments of the present invention, it is possible to determine that the user has placed the electronic device next to the ear to answer the call by using proximity data to meet preset conditions, so that the user can also hear the sound through the earpiece when placing the electronic device next to the ear to answer the call. The user experience is improved when the electronic device is connected to other audio output devices; in addition, depending on the type of audio output device, there are two ways to output the audio signal: both the earpiece and the audio output device output the audio signal, or only the earpiece outputs the audio signal. According to the type of audio output device, one of the ways is selected to output the audio signal, thereby improving the flexibility of the electronic device in outputting the audio signal. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A flow chart of a method for outputting audio provided by an embodiment of the present invention;

[0028] Figure 2 A flow chart of another method for outputting audio provided by an embodiment of the present invention;

[0029] Figure 3 This is a schematic diagram of the audio output structure of the mobile phone operating system;

[0030] Figure 4 A structural diagram of an electronic device provided by an embodiment of the present invention;

[0031] Figure 5 A structural diagram of another electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] Figure 1 A flow chart of a method for outputting audio provided by an embodiment of the present invention, the method can be executed by an electronic device such as a mobile phone having a proximity sensor, and the method includes:

[0034] When the electronic device is connected to an audio output device and has an audio signal output, proximity data of the proximity sensor is obtained; when the proximity data meets a preset condition, the earpiece of the electronic device outputs the audio signal, and the type of the audio output device is determined; based on the type of the audio output device, it is determined whether the audio output device outputs the audio signal.

[0035] It should be understood that in the embodiments of the present invention, the electronic device may be referred to as a terminal, user equipment (User Equipment, referred to as "UE"), a mobile station (Mobile Station, referred to as "MS"), a mobile terminal (Mobile Terminal), a computer, a microcomputer, etc. The electronic device may communicate with one or more core networks via a radio access network (Radio Access Network, referred to as "RAN"). For example, the electronic device may be a mobile phone (or a "cellular" phone), a computer with a mobile terminal, etc. For example, the electronic device may also be a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device, which exchanges voice and / or data with a radio access network. The present invention is not limited to this, for example, the electronic device also includes an electronic device with wired access having a multi-bearing feature.

[0036] The following is a detailed description of the method steps:

[0037] Step 101: When the electronic device is connected to an audio output device and has an audio signal output, proximity data of a proximity sensor is acquired.

[0038] Among them, the audio output device can be a device that can output audio signals, such as headphones and speakers; the audio output device is different from a receiver, and the audio output device and the electronic device can be connected by wire or wirelessly, and the audio output device can be a Bluetooth device, a Wireless-Fidelity (wifi) device, or a device connected through other connection interfaces.

[0039] The above-mentioned output audio signal can be triggered by an audio output event, and the audio output event can be an incoming call voice, ringtone, Internet phone (Voice over Internet Protocol, voip) voice, text to speech (Text to Speech, TTS) voice broadcast, music playback and other audio output events.

[0040] The electronic device analyzes the proximity data to determine the user's behavior, for example, to determine that the user puts the electronic device next to the ear. And modify at least one setting of the electronic device in response to the analysis result. For example, how to process input or output data from an input-output device. The electronic device can be a phone such as a cellular phone, an integrated phone and a media player, or other types of devices that can include sensors and process data from sensors, and the input-output device can be an audio input-output device, a keypad, or a multi-touch input pad. The sensor can be any of a variety of sensors, including a proximity sensor, a temperature sensor, an accelerometer, a light sensor, a position determination device, an orientation determination device, a radio frequency electromagnetic wave sensor, a touch input pad, a motion sensor, or a sound sensor. In some embodiments, the electronic device may include a plurality of sensors that provide data together to at least one processor, and the processor analyzes the data to determine the user's behavior. In at least some embodiments, the analysis can use artificial intelligence processing, which includes comparing data derived from one or more sensors with a threshold; for example, data from a proximity sensor can be compared with a threshold that represents the distance between a portion of the device and the user's ear or head. The data from the sensor may represent an analog value detected by the sensor; the analog value may indicate any of a variety of analog values, including, for example, distance, temperature, light intensity, a measurement of motion or orientation, a measurement of sound intensity, or a radio frequency (RF) electromagnetic measurement. In at least some embodiments, artificial intelligence processing may be required to receive the data and select an interpretation of the data from a set of possible interpretations, and the selected interpretation will then be used to determine how to modify the at least one setting. The modified setting may be any of a variety of settings, including, for example, settings for a display illuminator, settings for sound input or sound output parameters, settings for a sound output device, settings for a state of an input device related to receiving user input, settings for communication parameters, settings for a processor, or settings for a device mode (e.g., a cellular phone mode or a media player mode).

[0041] Step 102: When the proximity data meets a preset condition, the earpiece of the electronic device outputs an audio signal.

[0042] In one example, the proximity data may represent the distance between the electronic device and an obstacle.

[0043] When the proximity data meets a preset condition, that is, when the distance between the electronic device and the obstacle is less than or equal to a preset distance, the earpiece of the electronic device outputs an audio signal.

[0044] In one example, when a receiver of an electronic device outputs an audio signal, the electronic device outputs prompt information, where the prompt information is a prompt text or a prompt tone, and is used to prompt a user that the receiver outputs the audio signal.

[0045] In one example, when the proximity data does not satisfy a preset condition, that is, the distance between the electronic device and the obstacle is greater than a preset distance, the earpiece of the electronic device does not output an audio signal, but outputs the audio signal through an audio output device.

[0046] In one example, the proximity data represents the distance between the electronic device and an obstacle; in step 101, when the electronic device is connected to an audio output device and an audio signal is output, multiple proximity data of the proximity sensor within a preset time period are obtained; in step 102, the proximity data satisfies preset conditions, specifically: there is at least one proximity data among the multiple proximity data that satisfies a first preset condition, and / or, a trend of changes in the multiple proximity data over time satisfies a second preset condition, and the duration for which the proximity data satisfies the preset condition is greater than a preset time.

[0047] The proximity data represents the distance between the electronic device and the obstacle, and the existence of at least one proximity data in the plurality of proximity data that satisfies the first preset condition represents that the distance between the electronic device and the obstacle is less than or equal to the preset distance. The variation trend of the plurality of proximity data over time satisfies the second preset condition, which may specifically be: the variation trend of the plurality of proximity data over time satisfies a decreasing trend.

[0048] As can be seen from the above, in the embodiment of the present invention, by judging that the duration for which the proximity data meets the preset condition is greater than the preset time, the proximity data is judged to meet the preset condition, thereby improving the accuracy of judging that the proximity data meets the preset condition.

[0049] Step 103: Determine the type of the audio output device.

[0050] Specifically, audio output devices can be divided into two categories: one is an audio output device with an audio external player function, referred to as an external player device, such as an external speaker; the other is an audio output device without an audio external player function, such as a headset.

[0051] In the embodiment of the present invention, there is no specific limitation on the execution order of step 102 and step 103. Step 102 may be executed first and then step 103, or step 103 may be executed first and then step 102, or step 102 and step 103 may be executed simultaneously.

[0052] Step 104: Determine, based on the type of the audio output device, whether the audio output device outputs an audio signal.

[0053] In one example, when the audio output device is a headset, the audio output device outputs an audio signal.

[0054] In one example, when the audio output device is an external speaker, the audio output device does not output an audio signal.

[0055] In an embodiment of the present invention, when an earpiece of an electronic device outputs an audio signal, the audio output device may or may not output the audio signal; in one example, whether the audio output device outputs an audio signal can be determined based on the type of the audio output device; when the type of the audio output device identifies that the audio output device does not have an audio external speaker function (such as headphones), the audio output device outputs an audio signal, which can avoid the situation where the user cannot hear the sound through the audio output device due to a misjudgment; when the type of the audio output device identifies that the audio output device has an audio external speaker function (such as a speaker), the audio output device does not output an audio signal, thereby protecting the privacy and security of the user.

[0056] In one example, the earpiece of an electronic device can output audio in the following manner: when the proximity data meets a preset condition, the audio type of the audio signal is set to a custom audio type; and the audio signal is output through the earpiece according to the correspondence between the preset custom audio type and the earpiece.

[0057] In one example, the earpiece and audio output device of an electronic device can be made to output audio in the following manner: when the proximity data meets a preset condition and the audio output device does not have an audio external speaker function, the audio type of the audio signal is set to a custom audio type; based on the correspondence between the preset custom audio type and the earpiece and the audio output device, the audio signal is output through the earpiece and the audio output device.

[0058] In an embodiment of the present invention, it can be determined that the user has placed the electronic device next to the ear to answer a call by the proximity data satisfying a preset condition, so that the user can also hear the sound through the earpiece when placing the electronic device next to the ear to answer a call. The user experience is improved when the electronic device is connected to other audio output devices; in addition, depending on the type of audio output device, there are two ways to output the audio signal: both the earpiece and the audio output device output the audio signal, or only the earpiece outputs the audio signal. Depending on the type of audio output device, one of the ways is selected to output the audio signal, thereby improving the flexibility of the electronic device in outputting the audio signal.

[0059] The following specifically describes the method for outputting audio provided by the present invention by taking an application scenario in which a user uses a mobile phone to answer a call as an example.

[0060] Figure 2A flowchart of another method for outputting audio provided by an embodiment of the present invention, the method is executed by a mobile phone having a proximity sensor, and the method includes:

[0061] Step 201: When the mobile phone receives the instruction information input by the user to answer the incoming call, it confirms that it is connected to other audio output devices except the handset, and determines the type of the audio output device.

[0062] The mobile phone can detect not only whether other audio output devices except the handset are connected via wired mode, but also whether other audio output devices except the handset are connected via wireless mode.

[0063] The above audio signal includes an incoming call ring signal and / or a call voice signal.

[0064] The electronic device dynamically updates the audio strategy table according to the audio signal and other connected audio output devices, wherein the audio strategy table includes the corresponding relationship between the audio signal and the audio output device that outputs the audio signal.

[0065] For example, when the electronic device receives an incoming call, the audio output device corresponding to the incoming call is configured by querying the audio policy table.

[0066] Step 202: Acquire proximity data from a proximity sensor.

[0067] In the embodiment of the present invention, the proximity sensor may be a distance sensor, and the proximity data may represent the distance between the mobile phone and the obstacle. The method for obtaining the proximity data is the same as the method for obtaining the proximity data in step 101.

[0068] Step 203: When the proximity data meets a preset condition, the handset of the mobile phone outputs an audio signal.

[0069] In the embodiment of the present invention, it is determined whether the earpiece of the electronic device outputs an audio signal by judging whether the proximity data meets a preset condition, that is, judging whether the user puts the mobile phone to the ear. When the proximity data meets the preset condition, that is, when the user puts the mobile phone to the ear, the audio signal is output through the earpiece of the mobile phone.

[0070] In the embodiment of the present invention, by detecting the distance between the mobile phone and the obstacle, it is determined whether to output the audio signal through the handset of the mobile phone. When the proximity data meets the preset condition, that is, the distance between the mobile phone and the obstacle is less than or equal to the effective listening distance, it is determined that the user puts the mobile phone to the ear, and the audio signal is output through the handset of the mobile phone; when the proximity data does not meet the preset condition, that is, the distance between the mobile phone and the obstacle is greater than the effective listening distance, it is determined that the user does not put the mobile phone to the ear, and the handset of the mobile phone does not output the audio signal.

[0071] The proximity data satisfies the preset condition, including: the duration of the proximity data satisfying the preset condition is greater than the preset time, that is, the duration of the user placing the mobile phone to the ear is greater than the preset time. When the user places the mobile phone to the ear for a duration greater than the preset time, an audio signal is output through the mobile phone receiver to improve the accuracy of the detection result. The above preset time period is, for example, 2 seconds.

[0072] Step 204: Determine whether the audio output device outputs an audio signal according to the type of the audio output device.

[0073] When the audio output device is a headset without an audio external speaker function, the audio output device outputs the audio signal. When the audio output device is a device with an audio external speaker function, the audio output device does not output the audio signal.

[0074] In the embodiment of the present invention, when the mobile phone is connected to other audio output devices and receives the instruction information of answering the incoming call, it is detected that the user puts the mobile phone to the ear, and the user can hear the sound through the receiver. In addition, it can also be determined whether the audio output device outputs the call voice signal according to the type of the audio output device.

[0075] In one example, when the proximity data meets a preset condition, the audio type of the audio signal is set to a custom audio type; and according to a preset correspondence between the custom audio type and the earpiece, the audio signal is output through an audio output device corresponding to the custom audio type. For example, the correspondence between the audio type and the audio output device may be as shown in Table 1.

[0076] Audio Type Audio output device music speaker Incoming ringtone speaker Call Audio earphone Custom audio type 1 earpiece Custom audio type 2 Earpiece + Headphones

[0077] Table 1

[0078] The embodiment of the present invention realizes that: when the audio output device is a headset without an audio external speaker function, the audio output device outputs a call voice signal, that is, the call voice signal is output through both the receiver and the headset, so that when the judgment result that the user puts the mobile phone to the ear is wrong, the user can also hear the call voice through the headset, thereby improving the user experience. When the audio output device is a device with an audio external speaker function, the audio output device does not output a call voice signal. That is, the call voice signal is output only through the receiver, which can prevent others from hearing it and protect the privacy and security of the user.

[0079] In one example, the method further includes:

[0080] Step 205: when the proximity data does not meet the preset condition, output the audio signal through the audio output device.

[0081] Wherein, step 205 may be implemented by presetting a correspondence between the audio type and the audio output device.

[0082] The method for determining the type of an audio output device provided by the present invention is described below through a specific embodiment.

[0083] In one example, the following method can be used to determine whether a device is plugged into the mobile phone via a wire:

[0084] Use the isWiredHeadsetOn() method in the AudioManager provided by Android; if a device is plugged into the phone via a wire, this method returns true, otherwise it returns false.

[0085] Optionally, when it is determined that a wired device is inserted, the wired headphones and wired speakers are distinguished by impedance characteristics.

[0086] In an example, the following method can be used to determine whether an audio output device such as headphones or external speakers is connected to the mobile phone via Bluetooth:

[0087] Get the Bluetooth type of the Bluetooth device connected to the mobile phone. When the Bluetooth type belongs to any one of the Bluetooth types in the Bluetooth type list of the audio output device, it is confirmed that there is an audio output device connected to the mobile phone via Bluetooth.

[0088] Android itself defines a series of Bluetooth types. Specifically, a series of Bluetooth types are defined in the BluetoothClass.Device class, including headphones, car equipment, etc. The mobile phone determines the Bluetooth type of the Bluetooth device (BluetoothDevice) according to the properties of the connected Bluetooth device and compares it with the type specified in BluetoothClass.Device to find the corresponding type. The following are the agreed types between Bluetooth manufacturers.

[0089] int AUDIO_VIDEO_CAMCORDER

[0090] int AUDIO_VIDEO_CAR_AUDIO

[0091] int AUDIO_VIDEO_HANDSFREE

[0092] int AUDIO_VIDEO_HEADPHONES

[0093] int AUDIO_VIDEO_HIFI_AUDIO

[0094] int AUDIO_VIDEO_LOUDSPEAKER

[0095] int AUDIO_VIDEO_MICROPHONE

[0096] When BluetoothDevice ==

[0097] AUDIO_VIDEO_CAR_AUDIO||AUDIO_VIDEO_HANDSFREE

[0098] ||AUDIO_VIDEO_HEADPHONES||AUDIO_VIDEO_HIFI_AUDIO

[0099] ||AUDIO_VIDEO_MICROPHONE

[0100] When the phone is connected to the Bluetooth headset or external speakers, it is judged that the audio output device is connected to the phone via Bluetooth.

[0101] The following specifically describes the method for outputting audio provided by the embodiment of the present invention in conjunction with the audio output structure of the mobile phone operating system (OS).

[0102] Figure 3 This is a schematic diagram of the audio output structure of the mobile phone OS. Figure 3 , the audio output passes through the application layer, Java framework and AudiHAL three layers in sequence.

[0103] Among them, Phone app is a telephone application at the application layer. The telephone application can remind users of incoming calls, receive instructions from users to answer new calls, and, when it is determined that the proximity data meets the preset conditions, that is, the mobile phone is close to the ear, send a notification message to the AudioService in the Java framework. The notification message is used to indicate that the mobile phone is placed next to the ear.

[0104] AudioService belongs to the Java framework layer and is the base camp of an audio system in Android OS. Its main functions include volume control, volume key processing, and audio IO device management. In the embodiment of the present invention, after receiving the notification message sent by the Phone app, AudioService sends the notification message to AudioSystem.

[0105] AudioSystem belongs to the Java framework layer and acts as the entry point for sampling audio system resources. It allows querying and accessing mixers installed on the system. AudioSystem includes many methods for converting audio data between different formats, as well as methods for converting between audio files and streams. After receiving the notification message sent by AudioService, AudioSystem sends the notification message to the AudioPol icyManager of the AudiHAL layer.

[0106] The AudiHAL layer is the bottom layer of Android audio and is a logical layer for communicating and controlling audio devices. Android's audio management strategy is: Android sets different routes for different audio types and selects different output devices based on the routes. And based on the audio type, a corresponding relationship is created between the audio output devices connected to the electronic device. For example, when the audio type sent by the application layer to AudioService is STREAM_MUSIC, and the electronic device is connected to headphones, the audio policy table determines that the audio type is STREAM_MUSIC. The sound will be output from the headphones. If the audio type is STREAM_RING, it will be output from both the headphones and the speaker.

[0107] The getDeviceForStrategy method of AudioPol icyManager is mainly used to select the corresponding output device for different audio types according to the route. Therefore, by adding custom audio types and modifying the audio strategy of getDeviceForStrategy, the audio management strategy of Android can be customized.

[0108] For example, a new audio type STREAM_CALLING_NEW is added, and the corresponding audio output devices configured for this audio type are mobile phone handsets and earphones.

[0109] When AudioPol icyManager receives the notification message from the upper-layer application, it sets the audio type to STREAM_CALLING_NEW, and getDeviceForStrategy selects the phone receiver and headset as the output device according to the modified audio strategy.

[0110] The method for outputting audio provided by the embodiment of the present invention is simple and easy to implement, thereby improving user experience.

[0111] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present invention, wherein the electronic device is used to execute the method for outputting audio provided in an embodiment of the present invention, and the electronic device includes:

[0112] Processor 401, memory 402, earpiece 403, proximity sensor 404 and interface circuit 405;

[0113] The memory 402 is used to store computer executable program codes, and the program codes include instructions.

[0114] The processor 401 calls the instructions stored in the memory 402 to implement the above Figure 1 Steps 101 to 104 in Figure 2 In steps 201 to 205 and the scheme in the method design for outputting audio, since the implementation method and beneficial effects of the electronic device to solve the problem can refer to the implementation and beneficial effects of the above-mentioned method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0115] Figure 5 This is another electronic device structure diagram provided by an embodiment of the present invention. The electronic device is used to perform the method for outputting audio provided by an embodiment of the present invention. The electronic device includes: an acquisition unit 501 and a processing unit 502. The acquisition unit 501 is used to implement the above Figure 1 Step 101 in Figure 2 Step 202 in the above; the processing unit 502 is used to execute the above Figure 1 Steps 102 to 104 in Figure 2 In steps 201, 203 to 205 and the method for outputting audio, since the implementation method and beneficial effects of the electronic device to solve the problem can refer to the implementation and beneficial effects of the above method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0116] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0117] In the several embodiments provided in the present application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of electronic devices or units can be electrical, mechanical or other forms.

[0118] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0119] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0120] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a non-volatile computer-readable storage medium. The above-mentioned software functional unit is stored in a non-volatile storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory RAM, disk or optical disk and other media that can store program codes.

[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for outputting audio, applied to an electronic device, characterized in that: The electronic device is connected to an audio output device, and the method comprises: When the audio type sent by the application layer of the electronic device to the AudioService in the Java framework is STREAM_MUSIC and the audio output device is a Bluetooth headset, the AudioPolicyManager determines to output the audio signal through the Bluetooth headset according to the audio policy table, wherein the audio policy table includes a correspondence between the audio type of the audio signal and the audio output device that outputs the audio signal; When the audio type is STREAM_RING and the audio output device is a Bluetooth headset, the AudioPolicyManager determines to output the audio signal through the Bluetooth headset and a speaker of the electronic device according to the audio policy table; When the mobile phone receives the instruction information input by the user to answer the incoming call, confirming that the audio output device other than the handset is connected, and determining the type of the audio output device; In response to the indication information of answering the incoming call, the electronic device acquires the proximity data; Determining whether the proximity data satisfies a preset condition, wherein the proximity data satisfies the preset condition includes: within a first preset time after answering the incoming call, the electronic device detects through the proximity data that the user places the electronic device next to the ear; When the proximity data meets the preset condition, the earpiece of the electronic device outputs an audio signal; When the proximity data meets the preset condition, setting the audio type of the audio signal to a custom audio type; and outputting the audio signal through an audio output device corresponding to the custom audio type according to a correspondence between the custom audio type and the earpiece preset in the audio strategy table, comprising: When the audio output device is a device with an audio external speaker function, setting the audio type of the audio signal to a first custom audio type, and determining that the audio output device does not output the audio signal according to the audio output device corresponding to the first custom audio type being the earpiece; When the audio output device is a headset without an audio external speaker function, setting the audio type of the audio signal to a second custom audio type, and determining that the audio output device outputs the audio signal according to the audio output device corresponding to the second custom audio type is a receiver and a headset; When the proximity data does not satisfy the preset condition, an audio signal is output through the audio output device.

2. The method according to claim 1, characterized in that The detecting that the user places the electronic device near the ear includes: detecting that the user places the electronic device near the ear according to at least one of the following: The distance between the electronic device and the user's ear and the movement of the electronic device; or The distance between the electronic device and the user's head and the movement of the electronic device.

3. The method according to claim 1, characterized in that The detecting that the user places the electronic device near the ear includes: detecting that the distance between the electronic device and the obstacle is less than a preset distance.

4. The method according to claim 3, characterized in that The method further includes: if it is detected that the distance between the electronic device and the obstacle is greater than a preset distance, outputting the call voice signal of the incoming call through the Bluetooth headset, and not outputting the call voice signal of the incoming call through the earpiece of the electronic device.

5. The method according to claim 1, characterized in that When the earpiece of the electronic device outputs an audio signal, the electronic device outputs prompt information, where the prompt information is used to prompt the earpiece to output the call voice signal of the incoming call, and the prompt information includes text information.

6. The method according to claim 1, characterized in that The first preset time is 2 seconds.

7. The method according to claim 1, characterized in that The detecting that the user places the electronic device next to the ear includes: detecting that the user places the electronic device next to the ear for a duration greater than a second preset time.

8. The method according to claim 1, characterized in that The AudioPolicyManager determines, according to the audio policy table, to output the audio signal through the Bluetooth headset, including: According to the correspondence between the audio type of the audio signal and the audio output device in the audio strategy table, it is determined to output the audio signal through the Bluetooth headset.

9. The method according to claim 1, characterized in that The AudioPolicyManager determines, according to the audio policy table, to output the audio signal through the Bluetooth headset and the speaker of the electronic device, including: According to the correspondence between the audio type of the audio signal and the audio output device in the audio strategy table, it is determined to output the audio signal through the Bluetooth headset and the speaker of the electronic device.

10. An electronic device, characterized in that: The electronic device is connected to an audio output device, and the electronic device comprises: processor, memory, earpiece, proximity sensor and / or motion sensor; The memory is used to store computer executable program codes, and the program codes include instructions. When the processor executes the instructions, the instructions cause the electronic device to execute: When the audio type sent by the application layer of the electronic device to the AudioService in the Java framework is STREAM_MUSIC and the audio output device is a Bluetooth headset, the AudioPolicyManager determines to output the audio signal through the Bluetooth headset according to the audio policy table, and the audio policy table includes a correspondence between the audio type of the audio signal and the audio output device that outputs the audio signal; When the audio type is STREAM_RING and the audio output device is a Bluetooth headset, the AudioPolicyManager determines to output the audio signal through the Bluetooth headset and a speaker of the electronic device according to the audio policy table; When the mobile phone receives the instruction information input by the user to answer the incoming call, confirming that the audio output device other than the handset is connected, and determining the type of the audio output device; In response to the indication information of answering the incoming call, the electronic device acquires the proximity data; Determining whether the proximity data satisfies a preset condition, wherein the proximity data satisfies the preset condition includes: within a first preset time after answering the incoming call, the electronic device detects through the proximity data that the user places the electronic device next to the ear; When the proximity data meets the preset condition, the earpiece of the electronic device outputs an audio signal; When the proximity data meets the preset condition, setting the audio type of the audio signal to a custom audio type; and outputting the audio signal through an audio output device corresponding to the custom audio type according to a correspondence between the custom audio type and the earpiece preset in the audio strategy table, comprising: When the audio output device is a device with an audio external speaker function, setting the audio type of the audio signal to a first custom audio type, and determining that the audio output device does not output the audio signal according to the audio output device corresponding to the first custom audio type being the earpiece; When the audio output device is a headset without an audio external speaker function, setting the audio type of the audio signal to a second custom audio type, and determining that the audio output device outputs the audio signal according to the audio output device corresponding to the second custom audio type is a receiver and a headset; When the proximity data does not satisfy the preset condition, an audio signal is output through the audio output device.

11. The electronic device according to claim 10, characterized in that: The detecting that the user places the electronic device near the ear includes: detecting that the user places the electronic device near the ear according to at least one of the following: The distance between the electronic device and the user's ear and the movement of the electronic device; or The distance between the electronic device and the user's head and the movement of the electronic device.

12. The electronic device according to claim 10, characterized in that: The detecting that the user places the electronic device near the ear includes: if it is detected that the distance between the electronic device and the obstacle is less than a preset distance.

13. The electronic device according to claim 12, characterized in that: The instruction also causes the electronic device to execute: if it is detected that the distance between the electronic device and the obstacle is greater than a preset distance, the call voice signal of the incoming call is output through the Bluetooth headset, and the call voice signal of the incoming call is not output through the earpiece of the electronic device.

14. The electronic device according to claim 10, characterized in that: When the earpiece of the electronic device outputs an audio signal, the electronic device outputs prompt information, where the prompt information is used to prompt the earpiece to output the call voice signal of the incoming call, and the prompt information includes text information.

15. The electronic device according to claim 10, characterized in that: The first preset time is 2 seconds.

16. The electronic device according to claim 10, characterized in that: The detecting that the user places the electronic device next to the ear includes: detecting that the user places the electronic device next to the ear for a duration greater than a second preset time.

17. The electronic device according to claim 10, characterized in that: The AudioPolicyManager determines, according to the audio policy table, to output the audio signal through the Bluetooth headset, including: According to the correspondence between the audio type of the audio signal and the audio output device in the audio strategy table, it is determined to output the audio signal through the Bluetooth headset.

18. The electronic device according to claim 10, characterized in that: The AudioPolicyManager determines, according to the audio policy table, to output the audio signal through the Bluetooth headset and the speaker of the electronic device, including: According to the correspondence between the audio type of the audio signal and the audio output device in the audio strategy table, it is determined to output the audio signal through the Bluetooth headset and the speaker of the electronic device.

19. A computer-readable storage medium storing a program, characterized in that: The program includes instructions, and when the instructions are executed by an electronic device, the electronic device executes the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Mobile terminal and audio channel fast switching method and device thereof

    CN104717363A

  • Audio output method and device

    CN104935729A

  • Audio test method and system and terminal

    CN105657632A

  • Mobile communication terminal with voice output switching function and operation method thereof

    CN1921665A