You can use reflection methods to invoke the ITelephony object, thereby avoiding the need to specify a type and add an AIDL file. For example, ending a call:
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Class<?> c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); Object telephonyService = m.invoke(tm); Class<?> telephonyServiceClass = Class.forName(telephonyService.getClass().getName()); Method endCallMethod = telephonyServiceClass.getDeclaredMethod("endCall"); endCallMethod.invoke(telephonyService);
source share