diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3517349..c0c351e 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -38,8 +38,8 @@
-
+
diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourReceiveCall.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourReceiveCall.java
index d24438e..c5022fb 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourReceiveCall.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourReceiveCall.java
@@ -24,7 +24,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
@Override
- protected void execute() throws InterruptedException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ protected void execute() throws Exception {
Context context = MainActivity.getContext();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
@@ -32,14 +32,18 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
while(tm.getCallState() != TelephonyManager.CALL_STATE_RINGING ){
if(super.stopExecution())
return;
+ super.setProgress(0.2f);
Thread.sleep(SLEEP_PERIOD);
}
log.debug("Phone is ringing, answering call");
+ Thread.sleep(1000);
+ CallUtil.answerCall();
// Wait for call to end
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
return;
+ super.setProgress(0.6f);
Thread.sleep(SLEEP_PERIOD);
}
log.debug("Call has ended");
diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSpeechCall.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSpeechCall.java
index 808acaf..a5b46cd 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSpeechCall.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSpeechCall.java
@@ -52,6 +52,7 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
while(tm.getCallState() != TelephonyManager.CALL_STATE_OFFHOOK){
if(super.stopExecution())
return;
+ super.setProgress(0.1f);
Thread.sleep(SLEEP_PERIOD);
}
@@ -71,6 +72,7 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
return;
+ super.setProgress(0.9f);
Thread.sleep(SLEEP_PERIOD);
}
}
diff --git a/app/src/main/java/com/ericsson/uecontrol/core/util/CallUtil.java b/app/src/main/java/com/ericsson/uecontrol/core/util/CallUtil.java
index e6df53f..1ef2264 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/util/CallUtil.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/util/CallUtil.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.media.AudioManager;
import android.net.Uri;
import android.telephony.TelephonyManager;
+import android.view.KeyEvent;
import com.ericsson.uecontrol.gui.MainActivity;
@@ -39,31 +40,34 @@ public class CallUtil {
}
- private static void answerCall() throws Exception {
+ public static void answerCall() throws Exception {
+ Context context = MainActivity.getContext();
log.debug("Answering Speech Call");
- Object telephonyService = getTelephonyServiceAidl();
- Class c = Class.forName(telephonyService.getClass().getName());
- // Silence ringer
- Method m = c.getDeclaredMethod("silenceRinger");
- m.setAccessible(true);
- m.invoke(telephonyService);
- // Answer Call
- m = c.getDeclaredMethod("answerRingingCall");
- m.setAccessible(true);
- m.invoke(telephonyService);
+ try {
+ Object telephonyService = getTelephonyServiceAidl();
+ Class c = Class.forName(telephonyService.getClass().getName());
+ // Silence ringer
+ Method m = c.getDeclaredMethod("silenceRinger");
+ m.setAccessible(true);
+ m.invoke(telephonyService);
+ // Answer Call
+ m = c.getDeclaredMethod("answerRingingCall");
+ m.setAccessible(true);
+ m.invoke(telephonyService);
+ }catch (Exception e){
+ log.debug("Using fallback call solution");
- /* Fallback Solution
- // Simulate a press of the headset button to pick up the call
- Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
- buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
- context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");
+ // Simulate a press of the headset button to pick up the call
+ Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
+ buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
+ context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");
- // froyo and beyond trigger on buttonUp instead of buttonDown
- Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
- buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
- context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
- */
+ // froyo and beyond trigger on buttonUp instead of buttonDown
+ Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
+ buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
+ context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
+ }
}