use of com.android.internal.telephony.ITelephony in project Gadgetbridge by Freeyourgadget.
the class GBCallControlReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
GBDeviceEventCallControl.Event callCmd = GBDeviceEventCallControl.Event.values()[intent.getIntExtra("event", 0)];
if (GBApplication.isRunningPieOrLater()) {
handleCallCmdTelecomManager(callCmd);
} else {
switch(callCmd) {
case END:
case REJECT:
case START:
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(telephonyManager.getClass().getName());
Method method = clazz.getDeclaredMethod("getITelephony");
method.setAccessible(true);
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
if (callCmd == GBDeviceEventCallControl.Event.END || callCmd == GBDeviceEventCallControl.Event.REJECT) {
telephonyService.endCall();
} else {
telephonyService.answerRingingCall();
}
} catch (Exception e) {
LOG.warn("could not start or hangup call");
}
break;
default:
}
}
}
Aggregations