-1

Possible Duplicate:
How to intercept incoming calls android 2.3.x

I am making an app that overrides the default telephone screen and I it need to be compatible with Android 2.3 onwards.

Currently I have this code:

private void answerCallAidl() throws RemoteException {
    // telephonyService.silenceRinger();       -------not work on 2.3
    // telephonyService.answerRingingCall();   -------not work on 2.3

    Intent headSetUnPluggedintent = new Intent(Intent.ACTION_HEADSET_PLUG);
    headSetUnPluggedintent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    headSetUnPluggedintent.putExtra("state", 1); // 0 = unplugged  1 = Headset with microphone 2 = Headset without microphone
    headSetUnPluggedintent.putExtra("name", "Headset");

    // TODO: Should we require a permission?
    sendOrderedBroadcast(headSetUnPluggedintent, null);

    Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);           
    buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
                          KeyEvent.KEYCODE_HEADSETHOOK));
    sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");

    // froyo and beyond trigger on buttonUp instead of buttonDown
    Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);             
    buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP,
                           KeyEvent.KEYCODE_HEADSETHOOK));
    sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
} 


private void ignoreCallAidl() throws RemoteException {
    // telephonyService.silenceRinger();     -------not work on 2.3
    // telephonyService.endCall();           -------not work on 2.3
    Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);             
    buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
                        KeyEvent.KEYCODE_HEADSETHOOK));
    sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}

My problems are:

  1. I am unable to reject incoming calls.
  2. It does not work on version 2.3.5.
  3. I want my app to replace the default telephone screen.

I would appreciate very much any help.

Community
  • 1
  • 1
user1458530
  • 21
  • 1
  • 5

1 Answers1

0

In simple word - it is not possible.

Previously there was a cheat in JAVA (using reflection) but now its no more available. Please refer below,

Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);

You should refer this link; which tells that it is not possible. I would suggest to give up this idea soon after reading this.

Rajnikant
  • 1,097
  • 1
  • 7
  • 22
  • it is not work on android 2.3.3 – user1458530 Jun 25 '12 at 10:36
  • it is working on few devices only. I am not aware for which all version it will work. Purpose of my detailing is to convey that there were few ways but nothing concrete to deal with this use case. – Rajnikant Jun 26 '12 at 05:40