diff --git a/app/app.iml b/app/app.iml
index ddfe5ae..bc22434 100755
--- a/app/app.iml
+++ b/app/app.iml
@@ -56,7 +56,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 d4fe8ee..d7eb466 100755
--- a/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java
+++ b/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java
@@ -34,19 +34,21 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
private UeBehaviour currentlyActive;
private boolean terminate;
private Thread thread;
+ private Gson gson;
private long previousRxBytes = TrafficStats.UNSUPPORTED;
private long previousTxBytes = TrafficStats.UNSUPPORTED;
+ private boolean deviceBasedThroughput;
private ThroughputCalculator downloadSpeed;
private ThroughputCalculator uploadSpeed;
private ThroughputListener throughputListener;
- private Gson gson;
public UeControlExecutor(){
behaviours = new ArrayList();
downloadSpeed = new ThroughputCalculator();
uploadSpeed = new ThroughputCalculator();
+ deviceBasedThroughput = false;
gson = new GsonBuilder()
.registerTypeAdapter(UeBehaviour.class, new AbstractElementAdapter())
@@ -62,15 +64,10 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
FileReader in = new FileReader(file);
Type type = new TypeToken>(){}.getType();
ArrayList newBehaviours = gson.fromJson(in, type);
- behaviours.addAll(newBehaviours);
- in.close();
-
- /*ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
- int size = in.readInt();
- for(int i=0; i getBehaviourList() {
return behaviours;
diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java b/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java
index 5b9693e..6d9c4c9 100755
--- a/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java
+++ b/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java
@@ -19,6 +19,7 @@ import com.ericsson.uecontrol.core.UeControlExecutor;
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
+import com.ericsson.uecontrol.gui.fragments.FileBrowserDialog;
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
import com.ericsson.uecontrol.gui.util.CSVWriter;
@@ -51,8 +52,12 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // Set static fields
+
+ // Set static fields and preferences
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
+ prefs.registerOnSharedPreferenceChangeListener(this);
+
uid = getApplicationInfo().uid;
context = this;
@@ -66,10 +71,11 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
getFragmentManager().beginTransaction()
.replace(R.id.container, new BehaviourListFragment()).commit();
-
+ // Setup Executor
if(currentExecutor == null) {
log.info("Creating new instance of executor");
currentExecutor = new UeControlExecutor();
+ currentExecutor.setDeviceBasedThroughput(Boolean.parseBoolean(prefs.getString("throughput_type", "false")));
File input = new File(this.getFilesDir(), BEHAVIOUR_SAVE_FILE);
if (input.exists()) {
try {
@@ -91,6 +97,9 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
}
currentExecutor.setThroughputListener(statusFragment.getThroughputListener());
+
+
+
updateExecutionState();
}
@@ -109,8 +118,6 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
// Set log level of a specific logger
logConfigurator.setLevel("org.apache", Level.ERROR);
logConfigurator.configure();
-
- prefs.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
@@ -124,6 +131,11 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
Logger.getRootLogger().setLevel(Level.WARN);
}
}
+ else if(key.equals("throughput_type")){
+ log.info("Device Throughput set to: "+sharedPreferences.getString("throughput_type", "false"));
+ if(currentExecutor != null)
+ currentExecutor.setDeviceBasedThroughput(Boolean.parseBoolean(sharedPreferences.getString("throughput_type", "false")));
+ }
}
@@ -190,6 +202,12 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
Toast.makeText(this, "Stop execution to edit behaviours", Toast.LENGTH_SHORT).show();
return true;
}
+ else if (id == R.id.action_import) {
+ //TODO:
+ }
+ else if (id == R.id.action_export) {
+ //TODO:
+ }
else if (id == R.id.action_settings) {
startActivity(new Intent(this, SettingsActivity.class));
return true;
@@ -197,6 +215,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
return super.onOptionsItemSelected(item);
}
+
private void updateExecutionState(){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(action_execute != null) {
@@ -253,5 +272,4 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
return uid;
}
public static Context getContext(){return context;}
-
}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 841b027..9625edb 100755
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -12,4 +12,12 @@
- com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming
+
+ - App Throughput
+ - Device Throughput
+
+
+ - false
+ - true
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index aa99ea5..c18ece4 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -32,5 +32,8 @@
Keep screen on while execution
Keep Screen On
Add Mark
+ Select
+ Throughput Type
+ The type of throughput that should be displayed and logged
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index fe41e7b..f7b392d 100755
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -15,6 +15,14 @@
android:summary="@string/pref_logging_path_summ"
android:defaultValue="/sdcard/uecontrol/" />
+
+