The problem is this - there is a Plantronics M180 headset. It is necessary to handle pressing the main button (I say right away - this is not MEDIA_BUTTON, through XEVENT it is also not caught).

Main Button

In logcat, clicking on it displays nothing, except for the moment when the call is on and pressing the button completes it, the following is displayed:

E/bt-rfcomm: PORT_DataInd, p_port:0xa4f3294c, p_data_co_callback is null D/bt-btif: bta_ag_hdl_event: p_scb 0xa4f3b4e4 D/bt-btif: AG evt (hdl 0x0001): State 2, Event 0x050b D/bt-btif: HFP AT cmd:6 arg_type:1 arg:0 arg: D/bt-btif: bta_ag_rfc_data, change link policy for SCO D/bt-btif: btif_hf_upstreams_evt: event=BTA_AG_AT_CHUP_EVT D/HeadsetStateMachine: AudioOn process message: 101, size: 1 D/HeadsetStateMachine: event type: 5 

What are some ways to handle a click?

    1 answer 1

    If the headset is connected via a hands-free profile, then when this button is pressed, it sends various AT commands to the corresponding SPP (serial port) depending on the context (for example, answer an incoming call, hang up, dial the last number dialed, etc.). d.) These commands are handled by the Bluetooth hands-free AG service.

    As a crazy idea (not sure what is feasible): if you don’t use a headset for calls and use only a button, you can try to disable Phone Audio in the Bluetooth connection settings, pretend to be headset AG (it is easier to implement than hands-free) and connecting to the appropriate serial port to receive an AT command to press a button.