1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 12:00:51 +02:00

preparations for acceppting calls

This commit is contained in:
Andreas Shimokawa 2015-03-17 21:42:31 +01:00
parent c56194c0e5
commit a971eca6fd
2 changed files with 7 additions and 3 deletions

View File

@ -21,15 +21,20 @@ public class GBCallControlReceiver extends BroadcastReceiver {
int keyCode; int keyCode;
switch (command) { switch (command) {
case CALL_END: case CALL_END:
case CALL_START:
try { try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = Class.forName(telephonyManager.getClass().getName()); Class clazz = Class.forName(telephonyManager.getClass().getName());
Method method = clazz.getDeclaredMethod("getITelephony"); Method method = clazz.getDeclaredMethod("getITelephony");
method.setAccessible(true); method.setAccessible(true);
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager); ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
telephonyService.endCall(); if (command == GBCommand.CALL_END) {
telephonyService.endCall();
} else {
telephonyService.answerRingingCall();
}
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG, "could not hangup call"); Log.w(TAG, "could not start or hangup call");
} }
break; break;
default: default:

View File

@ -8,7 +8,6 @@ public enum GBCommand {
CALL_END, CALL_END,
CALL_INCOMING, CALL_INCOMING,
CALL_OUTGOING, CALL_OUTGOING,
CALL_PICKUP,
CALL_REJECT, CALL_REJECT,
CALL_START, CALL_START,