Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically end a call on 2.3+?

Tags:

android

Up to Android 2.2 I know I can use reflection and terminate the call through getITelephony.

However, as of 2.3 this no longer works because even if you grant the MODIFY_PHONE_STATE permission to your app, it's now a system app only permission: https://stackoverflow.com/a/5095956/821423

That said, it's possible still because a myriad of applications on the google play market are doing it just fine on ICS, for example, this one:

https://play.google.com/store/apps/details?id=com.androminigsm.fscifree&hl=en

So the question is, how do they do it? I know I can pick up the call using simulating a headset hook, but I can't figure out how to end the call.

Thank you.

like image 295
Stephan Tual Avatar asked Apr 07 '12 12:04

Stephan Tual


2 Answers

Well after much soul-searching I realize something really, really, really dumb. On the plus side no one on StackOverflow seems to have noticed it either. MODIFY_PHONE_STATE is no longer working on silenceRinger() since 2.3+, but endCall is just fine.

So the solution is to comment out the call to silenceRinger().

Can't believe I've just spent a week on this! I'll try to update the other questions as there seem to be tons of dupe on SO along the lines of 'it's not possible to use reflection to terminate the calls anymore'.

like image 199
Stephan Tual Avatar answered Oct 03 '22 09:10

Stephan Tual


The call() , endcall() functions work fine for me as well. But there is also another way tha works without using iTelephony.aidl. Its published in this post. BTW I think google already knows but for some reason they havent done anything with the rest of functions, wich is good!!!

http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html

like image 43
Byron Avatar answered Oct 03 '22 07:10

Byron