Speech call is now working

This commit is contained in:
Ziver Koc 2014-08-08 17:41:17 +02:00
parent a666888ef8
commit 7a3c4d66ee
3 changed files with 17 additions and 3 deletions

View file

@ -9,6 +9,8 @@ import com.ericsson.uecontrol.core.UeBehaviour;
import com.ericsson.uecontrol.gui.MainActivity;
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
import org.apache.log4j.Logger;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -18,6 +20,7 @@ import java.lang.reflect.Method;
* Created by ezivkoc on 2014-07-15.
*/
public class UeBehaviourSpeechCall extends UeBehaviour{
private static final Logger log = Logger.getLogger(UeBehaviourSpeechCall.class);
public static final int SLEEP_PERIOD = 100;
@Configurable("Phone Number")
@ -35,7 +38,9 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
@Override
protected void execute() throws InterruptedException {
protected void execute() throws InterruptedException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
startCall();
int elapsedTime = 0;
while(elapsedTime < length){
super.setProgress((float)elapsedTime/length);
@ -43,17 +48,24 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
Thread.sleep(SLEEP_PERIOD);
elapsedTime += SLEEP_PERIOD;
}
endCall();
}
private void startCall(){
log.debug("Starting Speech Call");
Context context = MainActivity.getContext();
Uri number = Uri.parse("tel:" + phoneNumber);
Intent intent = new Intent(Intent.ACTION_DIAL, number);
Intent intent = new Intent();
//intent.setAction(Intent.ACTION_DIAL);
intent.setAction(Intent.ACTION_CALL);
intent.setData(number);
context.startActivity(intent);
}
private void endCall() throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchMethodException {
log.debug("Ending Speech Call");
Context context = MainActivity.getContext();
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);