How to import com.android.internal.telephony.ITelephony to the Android application

The ITelephony interface is internal, so you cannot get a standard reference to it. You could use reflection all the way, i.e.

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

Method m1 = tm.getClass().getDeclaredMethod("getITelephony");
m1.setAccessible(true);
Object iTelephony = m1.invoke(tm);

Method m2 = iTelephony.getClass().getDeclaredMethod("silenceRinger"); 
Method m3 = iTelephony.getClass().getDeclaredMethod("endCall"); 

m2.invoke(iTelephony);
m3.invoke(iTelephony);

But either way those methods need the MODIFY_PHONE_STATE permission, which can only be granted to system apps. So I’m afraid it won’t work anyway.

Leave a Comment