The mobile phone must support the headset and Bluetooth headset, and be able to switch between active and passive detection. The headset and Bluetooth headset are detected.
After the connection, we can use the amixer command to set the codec route to control the system sound.
Headset: the connection of the headset can be reported to the kernel through gpio. The kernel is embodied in/dev/headset (you need to write the driver yourself ). The application can actively obtain the insertion status of the headset by reading the device. You can also use the monitoring IO port to obtain the plug-in of the headset.
Status.
Bluetooth headsets: Bluetooth headsets are more complex than headphones. Because Bluetooth does not only exist as a headset device. Therefore, we cannot
To obtain the headset status, you can obtain the two connectors of the Bluetooth headset. Fortunately, bluez in Linux provides us with convenience.
After the Bluetooth background is started, we can register the audio service. Then, through monitoring, the connected and
Remove the signal to obtain the current Bluetooth headset status.
In the mobile phone system, the following situations need special handling:
Device priority:
1] a headset and a Bluetooth headset are connected at the same time. Most Bluetooth headsets require priority. When the Bluetooth headset is disconnected, use the headset and try again. In some cases, both the headset and the Bluetooth headset can be used for audio control at the same time.
2] In some cases, peripheral pronunciation should be given priority, such as playing MP3. In some cases, the peripherals and the local machine must be pronounced simultaneously, for example, the ring tone.
3. process the relationship with the system's scene mode. Such as vibration and mute.
Generally, the source is directly cut off on the AP layer, and no special processing from the background service is required.