I can intercept incoming and outgoing calls. My problem is that it does not work in version 2.3.x
here my code:
public class PhoneCallReceiver extend
MODIFY_PHONE_STATE
permission is reserved for system use only, And ITelephony.silenceRinger()
need MODIFY_PHONE_STATE
permission. Use AudioManager if need to silent your phone at the time of call. But EndCall(
) will work fine.
The reason it does not work in Gingerbread 2.3.x is this 15031 issue, and 15872 issue Google changed the framework surrounding the permissions for the telephony, much to the annoyance of developers. Although it is not guaranteed, some phone makers leave the permission in place (Sony is one that comes to mind!), others have pulled down the code from Google's AOSP and built their own variants accordingly to their manufacture process, with the changed framework permission in place.
Simply put, the alternative is to have the handset rooted and create a MITM on the telephony socket layer and do the interception before the Android Stack ever sees the events... but on the face of it, its too complicated and not worth doing.
Now that ICS is out now, and the permission is still unchanged so that's something to bear in mind. Meanwhile GB source is left to gather dust as Google moves forward and very little can be done despite "Please fix this" in the 15031 issue page...