Block calls in Android

126 Views Asked by At

I am trying to develop a basic code to block calls in Android. My code was working initially but now it is not.

code to block all calls

    @Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    try {
        Class<?> c = Class.forName(tm.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);

ITelephony is the interface used

        telephony = (ITelephony) m.invoke(tm);

cannot call any of the available functions

        telephony.endCall();
        telephony.notifyAll();
    } catch (Exception e) {
        // TODO: handle exception
    }
}
1

There are 1 best solutions below

0
On

When you do this:

m.setAccessible(true);

you effectively are trying to bypass Java security. On some devices with old Android version it may have worked, but on more locked down devices it is not guaranteed to.