signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.16k stars 6.06k forks source link

Bluetooth headset button does not answer or end Signal voice calls #7679

Open cegg1 opened 6 years ago

cegg1 commented 6 years ago

Bug description

Signal supports using Bluetooth headsets for voice calls. However, when an incoming Signal call rings and a bluetooth headset is paired and connected, pressing the multifunction button on the headset does not answer the Signal call. The call has to be answered manually from the phone screen, only then does the bluetooth set engage.

Even more surprisingly, pressing the multifunction button while a Signal call is in progress (and the BT set in use) has the effect of handing the call over to the regular earpiece - rather than the expected result of ending the call.

The same issue has been observed on Pixel 2 (stock 8.1) and on Nexus 5 (LineageOS 14.1).

Steps to reproduce

Actual result: The call keeps ringing. Expected result: The call is answered, similarly to regular phone call.

Actual result: The call gets handed over to the earpiece. Expected result: The call is ended.

Screenshots

Not relevant

Device info

Bluetooth headset: Aukey EP-B40 Bluetooth 4.1 Device: Google Pixel 2 Android version: Stock Android 8.1.0 - OPM2.171019.029 Signal version: 4.18.3

Link to debug log

Trying to pick up a Signal call by pressing the bluetooth button (nothing happens) https://debuglogs.org/e98e666571435c9a13e6cac176ecdd4eda57ddd60a7127381c0c73625df697e0

Trying to end a Signal call by pressing the bluetooth button (call gets handed over to earpiece) https://debuglogs.org/789eec7e8c8e1138cf86a1fe61ea803bcc1df35bbb80b4f21edc057eeb581b0a

johanw666 commented 6 years ago

For headsets with only one button it is doable. For the generic case with carkits with 2 buttons this is extremely complicated because Android reserves that functionality only for the official phone app.

You can do that in a number of ways: the easiest way requires the MODIFY_PHONE_STATE permission, which is unfortunately only available for system apps. It would have the added advantage that an incomming "normal" call while you're on a Signal call gets busy.

I asked this question already on Stackoverflow once when it came up for my job but got no answers: https://stackoverflow.com/questions/47354818/how-to-make-a-voip-app-use-a-carkit-like-the-native-call-app

The only alternative that does not require root would be to implement the bluetooth communication on a low level yourself with BT sockets, but that is a lot of work, might not work correctly with all hardwareand require a lot of maintenance.

cegg1 commented 6 years ago

Thanks for the insight about answering calls with the Bluetooth button.

But what about ending a call in progress? There's still something I don´t understand: Signal must be already detecting that the button is being pressed - in fact, it hands the call over to the earpiece when you press it. This is just a single tap on the multifunction button (not that the headset is suddenly being turned off or becoming unavailable mid-call or anything). So Signal might as well react by ending the call rather than handing it back to the earpiece.

I understand that it might be technically challenging to pick up calls, but that doesn't fully explain why pressing the button during a call does not end the call.

johanw666 commented 6 years ago

Hangup is easy: you can detect the button being pressed, and when your call state is calling (the app knows when it is calling) it can hangup.

tohojo commented 6 years ago

I have also recently been bitten by this. A full integration would be awesome, of course, but just having hangup work would fix a lot of the annoyance; finding out that your call is still active minutes after you thought you hung up is a bit annoying :)

destivar89 commented 5 years ago

Hi @johanw666, you said the easiest way requires MODIFY_PHONE_STATE, I'm developing an app in which I have system permissions. So, what would be this easiest way?

Thanks in advance

johanw666 commented 5 years ago

I didn't work it out completely because the app I was working on didn't have this permission but the first set of results when I Google on android accept calls MODIFY_PHONE_STATE look promissing. And I believe that you didn't need system in very old Android versions so some old code could be usefull to check out too.

vedaker commented 5 years ago

I agree, I'm not sure there is an easy solution for this issue by using the existing Java APIs. The reason is that the "Call" button event is most likely received by the low level Bluetooth driver but Android for some reason which I don;t understand is masking this event (security?). So far I have not found a way to get the CALL events from the Java APIs. You could however get a Bluetooth state change notification when you press on the "Call" button but this is not a good method to interpret the button press because the state might change by other events/actions in the system.

If you really must get the "Call" or "Disconnect" button events the solution might be to write a low level C code to parse the Bluetooth data stream, but this is most likely not an easy task to do.

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

sellth commented 2 years ago

This is only one of the issues related to Signal not using Android's proper call API, but handling calls as a media player instead. Related feature request: https://community.signalusers.org/t/implement-android-telecom-api-for-calls/41280

cody-signal commented 2 years ago

Try on 5.33 where we've integrated with the Android telecom system, and made some changes to how we ring. Please post an updated debuglog if you try with that version and still encounter problems.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

sellth commented 2 years ago

Sorry for the delay in getting back to you. Here are two new debug logs. Device: Google Pixel 4a Signal: 5.36.3

  1. https://debuglogs.org/android/5.36.3/1bd8c900e5e44932cc9c613edab731c276ce19b4d7fbcc369699d51ff17fcc14
  2. https://debuglogs.org/android/5.36.3/d50f3cc9d5e32ac0684f9ac77c8904899b641c6327a9307e401ea6bd9a4d1dbd

First log:

Second log:

After few more tries, this seems to be the behaviour:

Edit: However, the Telecom changes are possibly not enabled yet. https://whispersystems.discoursehosting.net/t/beta-feedback-for-the-upcoming-android-5-37-release/44124/20

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

seung-pluto commented 1 year ago

Phone: Google Pixel 6 Bluetooth Devices Tested: Jowave BH830, Google Pixel Buds Pro, Beats Studio Buds, Plantronics Voyager 5200 Android Version: 12 (July 2022 Patch Level) Signal Versions: 5.43, 5.44 Android Auto Device: Kenwood Excelon DMX957XR

Wanted to write in to note that up until 5.44, I was having the exact same issue. The Telecom integration patched into 5.44 appears to have resolved this issue, at least for me. I can confirm that now, the multifunction button on all devices tested will properly pick up on an incoming call and hang up when on a call.

This may not related to this particular issue, but I have also noticed that when you have different Bluetooth devices active (say a smartwatch and your Bluetooth headset), Signal will switch (even in the middle of a call) to the last Bluetooth device the phone communicated with. There is no way for you to specify which Bluetooth device you want, so you're stuck with whatever Signal decides is the correct Bluetooth device. As a workaround, you can remove the ability to do calls and media from all devices that are not Bluetooth headsets, but that is obviously undesireable for multiple reasons.

As a final note, as a user I wanted to thank you for this fix. There's no way to accept calls or make Signal calls using Android Auto (no notification will display, even though the ringtone plays, and Android Auto brings up the Android phone dialer history UI), so having the ability to tap the MFB on my Bluetooth headset and have that answer calls has been wonderful from a car safety standpoint. Prior to this, if I wanted to answer a Signal call while in my car, I would have to dig the phone out and answer from there (which I did not do as that is dangerous).

rajeevn1 commented 7 months ago

We still can't answer/end incoming calls on bluetooth headset, including car dashboards. This seems to be a safety issue. Looking at the code, it seems the allow list for telecom integration is empty.

Can you provide an update please.

cody-signal commented 7 months ago

We tried almost a half dozen times to get telecom integration working, but it's improperly implemented across multiple vendors and devices. It results in all kinds of really bad problems. At this time, there is no plan to return to it until we hear from Google that something has improved, which potentially could be their new telecom integration library but so far that has not been the case.

rajeevn1 commented 7 months ago

Thanks for the update. Hoping for resolution with:

https://android-developers.googleblog.com/2023/11/alpha-release-of-telecom-library.html

Werkov commented 4 months ago

Would the mentioned telecom library update apply to older Androids too? Regardless of that, IIUC, the current implementation is not via telecom but "media player". Would it be simpler to implement the call ending functionality via this? (As that is what is troubling me much more than call answering.)

comminutus commented 2 months ago

Can this please be addressed? This is a pretty big limitation since often a headset is all I have and my phone has to be secured away. In this scenario I can't receive any signal calls.