diff --git a/.idea/libraries/support_v4_19_1_0.xml b/.idea/libraries/support_v4_19_1_0.xml
deleted file mode 100755
index 5c5cddd..0000000
--- a/.idea/libraries/support_v4_19_1_0.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java b/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java
index ce5c6db..0e3a035 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java
@@ -11,33 +11,36 @@ import java.io.Serializable;
*/
public abstract class UeBehaviour implements Serializable{
private static final Logger log = Logger.getLogger(UeBehaviour.class);
+ /** A sleep period for visual queue, mainly for behaviours that instantly finnish **/
+ public static final int VISUAL_SLEEP_PERIOD = 200;
- private transient boolean running;
private transient long execTime = -1;
private transient BehaviourExecutionListener execListener;
+ private transient UeControlExecutor executor;
- public synchronized void preRun() {
- running = true;
- }
+ public synchronized void preRun() { }
/**
* Starts to run the behaviour, this method will block until the execution is done
*/
- public void run(){
+ public synchronized void run(UeControlExecutor exec){
execTime = -1;
- long startTime = System.currentTimeMillis();
+ this.executor = exec;
if(execListener != null)
execListener.executionStarted();
+ setProgress(0);
+
+ long startTime = System.currentTimeMillis();
try {
- setProgress(0);
execute();
} catch(Exception e){
if(execListener != null) execListener.exception(e);
log.warn(null, e);
}
- running = false;
execTime = System.currentTimeMillis() - startTime;
+
+ executor = null;
if(execListener != null)
execListener.executionStopped(execTime);
}
@@ -46,7 +49,7 @@ public abstract class UeBehaviour implements Serializable{
* Will stop the currently running behaviour
*/
public void terminate(){
- running = false;
+ executor = null;
}
public void reset(){
@@ -62,14 +65,18 @@ public abstract class UeBehaviour implements Serializable{
}
public boolean isRunning(){
- return running;
+ return executor != null;
}
/**
* @return if currently running behaviour should be terminated
*/
protected boolean stopExecution(){
- return !running;
+ return !isRunning();
+ }
+
+ protected UeControlExecutor getExecutor(){
+ return executor;
}
diff --git a/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java b/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java
index a1c01f4..1203fed 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java
@@ -36,6 +36,7 @@ public class UeControlExecutor implements Runnable{
private Handler handler;
private ThroughputUpdateRunnable throughputUpdateRunnable;
private ThroughputListener throughputListener;
+ private ExecutionListener execListener;
public UeControlExecutor(){
@@ -90,7 +91,7 @@ public class UeControlExecutor implements Runnable{
try{ Thread.sleep(20); }catch(Exception e){log.error(null,e);}
}
- private void terminateNonBlock(){
+ public void terminateNonBlock(){
terminate = true;
handler.removeCallbacks(throughputUpdateRunnable);
if(currentlyActive != null)
@@ -105,14 +106,14 @@ public class UeControlExecutor implements Runnable{
try {
thread.wait();
while(isRunning()) // Just to make sure it has stopped
- Thread.sleep(10);
+ Thread.sleep(100);
}catch(InterruptedException e) {log.error(null,e);}
}
}
}
public synchronized void reset(){
- terminate();
+ terminateNonBlock();
currentlyActive = null;
for(int i=0; i inputs;
+ private HashMap inputs;
private Configurator confer;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- inputs = new HashMap();
+ inputs = new HashMap();
// Fix for CopyPaste bar not visible
Context context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light);
@@ -62,20 +64,33 @@ public class ConfigureDialog extends DialogFragment {
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
layout.addView(label);
+ if(confParam.getType() == ConfigType.STRING || confParam.getType() == ConfigType.INT) {
+ EditText input = new EditText(context);
+ input.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT));
+ input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
+ // Set previous value
+ if (savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
+ input.setText(savedInstanceState.getString(confParam.getName()), TextView.BufferType.EDITABLE);
+ else
+ input.setText(confParam.getString(), TextView.BufferType.EDITABLE);
- EditText input = new EditText(context);
- input.setLayoutParams(new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
- // Set previous value
- if(savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
- input.setText(savedInstanceState.getString(confParam.getName()), TextView.BufferType.EDITABLE);
- else
- input.setText(confParam.getString(), TextView.BufferType.EDITABLE);
- // store inputs for later use
- inputs.put(confParam.getName(), input);
- layout.addView(input);
+ // store inputs for later use
+ inputs.put(confParam.getName(), input);
+ layout.addView(input);
+ }
+ else if(confParam.getType() == ConfigType.BOOLEAN) {
+ CheckBox input = new CheckBox(context);
+ // Set previous value
+ if (savedInstanceState != null && savedInstanceState.containsKey(confParam.getName()))
+ input.setChecked(Boolean.parseBoolean(savedInstanceState.getString(confParam.getName())));
+ else
+ input.setChecked(Boolean.parseBoolean(confParam.getString()));
+ // store inputs for later use
+ inputs.put(confParam.getName(), input);
+ layout.addView(input);
+ }
root.addView(layout);
}
@@ -83,8 +98,11 @@ public class ConfigureDialog extends DialogFragment {
builder.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- for(ConfigurationParam confParam : confer.getConfiguration()){
- confParam.setString(inputs.get(confParam.getName()).getText().toString());
+ for (ConfigurationParam confParam : confer.getConfiguration()) {
+ if(inputs.get(confParam.getName()) instanceof EditText)
+ confParam.setString(((EditText)inputs.get(confParam.getName())).getText().toString());
+ else if(inputs.get(confParam.getName()) instanceof CheckBox)
+ confParam.setString(""+ ((CheckBox)inputs.get(confParam.getName())).isChecked());
}
confer.setConfiguration();
}
@@ -103,7 +121,10 @@ public class ConfigureDialog extends DialogFragment {
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
for(String key : inputs.keySet()){
- outState.putString(key, inputs.get(key).getText().toString());
+ if(inputs.get(key) instanceof EditText)
+ outState.putString(key, ((EditText)inputs.get(key)).getText().toString());
+ else if(inputs.get(key) instanceof CheckBox)
+ outState.putString(key, ""+ ((CheckBox)inputs.get(key)).isChecked());
}
}
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 9625edb..127730e 100755
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -10,6 +10,9 @@
- com.ericsson.uecontrol.core.behaviour.UeBehaviourSpeechCall
- com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing
- com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming
+
+ - com.ericsson.uecontrol.core.logic.UeBehaviourIterator
+ - com.ericsson.uecontrol.core.logic.UeBehaviourStop