Some adjustments to Speech call
This commit is contained in:
parent
97798ababa
commit
10a77ecc96
1 changed files with 15 additions and 9 deletions
|
|
@ -39,42 +39,48 @@ public class UeBehaviourSpeechCall 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);
|
||||
|
||||
// Start Call
|
||||
log.debug("Starting Call");
|
||||
CallUtil.startCall(phoneNumber);
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(SLEEP_PERIOD);
|
||||
|
||||
// Wait for call to start
|
||||
log.debug("Waiting for an answer");
|
||||
log.debug("Waiting call to start");
|
||||
while(tm.getCallState() == TelephonyManager.CALL_STATE_RINGING){
|
||||
if(super.stopExecution())
|
||||
return;
|
||||
super.setProgress(0.1f);
|
||||
super.setProgress(0.2f);
|
||||
Thread.sleep(SLEEP_PERIOD);
|
||||
}
|
||||
|
||||
// Start timer
|
||||
log.debug("Starting call timer");
|
||||
int elapsedTime = 0;
|
||||
int lengthMillisec = length*1000;
|
||||
while(elapsedTime < lengthMillisec){
|
||||
if(super.stopExecution())
|
||||
return;
|
||||
super.setProgress((float)elapsedTime/lengthMillisec);
|
||||
if(tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
||||
log.debug("Call ended prematurely");
|
||||
return;
|
||||
}
|
||||
super.setProgress((float) elapsedTime / lengthMillisec);
|
||||
Thread.sleep(SLEEP_PERIOD);
|
||||
elapsedTime += SLEEP_PERIOD;
|
||||
}
|
||||
CallUtil.endCall();
|
||||
|
||||
log.debug("Waiting for call to end");
|
||||
// Wait for call to end
|
||||
// End Call
|
||||
log.debug("Ending call");
|
||||
CallUtil.endCall();
|
||||
log.debug("Waiting call to end");
|
||||
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
|
||||
if(super.stopExecution())
|
||||
return;
|
||||
super.setProgress(0.9f);
|
||||
super.setProgress(0.95f);
|
||||
Thread.sleep(SLEEP_PERIOD);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue