Added CSV logging
|
|
@ -59,7 +59,7 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 15 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" exported="" name="GraphView-3.1.2" level="project" />
|
<orderEntry type="library" exported="" name="GraphView-3.1.2" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 15
|
||||||
buildToolsVersion '19.1.0'
|
buildToolsVersion '19.1.0'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.ericsson.uecontrol"
|
applicationId "com.ericsson.uecontrol"
|
||||||
minSdkVersion 19
|
minSdkVersion 15
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 1
|
versionCode 3
|
||||||
versionName "1.0"
|
versionName "1.0.2"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,7 @@
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
||||||
|
|
@ -81,14 +81,14 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
||||||
public void handledIncomingData(long size) {
|
public void handledIncomingData(long size) {
|
||||||
downloadSpeed.setHandledData(size);
|
downloadSpeed.setHandledData(size);
|
||||||
if(throughputListener != null && downloadSpeed.isUpdated())
|
if(throughputListener != null && downloadSpeed.isUpdated())
|
||||||
throughputListener.throughputUpdate(downloadSpeed.getThroughput(), uploadSpeed.getThroughput());
|
throughputListener.throughputUpdate(downloadSpeed.getBitThroughput(), uploadSpeed.getBitThroughput());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handledOutgoingData(long size) {
|
public void handledOutgoingData(long size) {
|
||||||
uploadSpeed.setHandledData(size);
|
uploadSpeed.setHandledData(size);
|
||||||
if(throughputListener != null && uploadSpeed.isUpdated())
|
if(throughputListener != null && uploadSpeed.isUpdated())
|
||||||
throughputListener.throughputUpdate(downloadSpeed.getThroughput(), uploadSpeed.getThroughput());
|
throughputListener.throughputUpdate(downloadSpeed.getBitThroughput(), uploadSpeed.getBitThroughput());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThroughputListener(ThroughputListener listener){
|
public void setThroughputListener(ThroughputListener listener){
|
||||||
|
|
@ -99,6 +99,9 @@ public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListe
|
||||||
return behaviours;
|
return behaviours;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UeBehaviour getRunningBehaviour(){
|
||||||
|
return currentlyActive;
|
||||||
|
}
|
||||||
|
|
||||||
public static interface ThroughputListener{
|
public static interface ThroughputListener{
|
||||||
public void throughputUpdate(double downThroughput, double upThroughput);
|
public void throughputUpdate(double downThroughput, double upThroughput);
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.ericsson.uecontrol.core.behaviour;
|
|
||||||
|
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This behaviour simulates streaming data.
|
|
||||||
* E.g: video, music etc...
|
|
||||||
*
|
|
||||||
* Created by ezivkoc on 2014-07-15.
|
|
||||||
*/
|
|
||||||
public class UeBehaviourDownload extends UeBehaviour {
|
|
||||||
private long data_size;
|
|
||||||
|
|
||||||
public UeBehaviourDownload(long byte_amount){
|
|
||||||
data_size = byte_amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void execute() {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Download";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Will download "+ data_size/1000 +"kB";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.ericsson.uecontrol.core.behaviour;
|
|
||||||
|
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This behaviour simulates streaming data.
|
|
||||||
* E.g: video, music etc...
|
|
||||||
*
|
|
||||||
* Created by ezivkoc on 2014-07-15.
|
|
||||||
*/
|
|
||||||
public class UeBehaviourUpload extends UeBehaviour {
|
|
||||||
private long data_size;
|
|
||||||
|
|
||||||
public UeBehaviourUpload(long byte_amount){
|
|
||||||
data_size = byte_amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void execute() {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Upload";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Will Upload "+ data_size/1000 +"kB";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -24,11 +24,14 @@ public class ThroughputCalculator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getThroughput(){
|
public double getByeThroughput(){
|
||||||
setHandledData(0); // Update throughput
|
setHandledData(0); // Update throughput
|
||||||
updated = false;
|
updated = false;
|
||||||
return throughput;
|
return throughput;
|
||||||
}
|
}
|
||||||
|
public double getBitThroughput(){
|
||||||
|
return getByeThroughput()*8;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUpdated(){
|
public boolean isUpdated(){
|
||||||
return updated;
|
return updated;
|
||||||
|
|
@ -36,12 +39,12 @@ public class ThroughputCalculator {
|
||||||
|
|
||||||
|
|
||||||
private static final String[] DATA_SIZE = new String[]{"b/s", "kbit/s", "Mbit/s", "Gbit/s"};
|
private static final String[] DATA_SIZE = new String[]{"b/s", "kbit/s", "Mbit/s", "Gbit/s"};
|
||||||
public static String getThroughputString(double bits){
|
public static String getBitThroughputString(double bitsPerSec){
|
||||||
int index = 0;
|
int index = 0;
|
||||||
double value = bits;
|
double value = bitsPerSec;
|
||||||
|
|
||||||
for(; value > 1024 && index < DATA_SIZE.length ;index++) {
|
for(; value > 1000 && index < DATA_SIZE.length ;index++) {
|
||||||
value /= 1024;
|
value /= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = (int)(value*10) / 10.0;
|
value = (int)(value*10) / 10.0;
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,8 @@ public class EditActivity extends ListActivity implements AdapterView.OnItemClic
|
||||||
setContentView(R.layout.activity_edit);
|
setContentView(R.layout.activity_edit);
|
||||||
|
|
||||||
final List<UeBehaviour> list;
|
final List<UeBehaviour> list;
|
||||||
if(getIntent().hasExtra("executor")) {
|
executor = MainActivity.getExecutor();
|
||||||
int executorIndex = getIntent().getExtras().getInt("executor_index");
|
|
||||||
executor = MainActivity.getExecutor(executorIndex);
|
|
||||||
|
|
||||||
list = executor.getBehaviourList();
|
list = executor.getBehaviourList();
|
||||||
}
|
|
||||||
else
|
|
||||||
list = new ArrayList<UeBehaviour>();
|
|
||||||
|
|
||||||
adapter = new BehaviourListAdapter(this, list);
|
adapter = new BehaviourListAdapter(this, list);
|
||||||
adapter.setEditable(true);
|
adapter.setEditable(true);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@ package com.ericsson.uecontrol.gui;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
|
@ -16,8 +17,7 @@ import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
||||||
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment;
|
||||||
import com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment;
|
import com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment;
|
||||||
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
||||||
|
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends FragmentActivity
|
public class MainActivity extends FragmentActivity
|
||||||
|
|
@ -29,34 +29,31 @@ public class MainActivity extends FragmentActivity
|
||||||
private NavigationDrawerFragment navigationDrawerFragment;
|
private NavigationDrawerFragment navigationDrawerFragment;
|
||||||
private StatusFragment statusFragment;
|
private StatusFragment statusFragment;
|
||||||
|
|
||||||
private int currentExecutor;
|
private static UeControlExecutor currentExecutor;
|
||||||
|
private static CSVWriter logger;
|
||||||
|
|
||||||
private static ArrayList<UeControlExecutor> executors;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
navigationDrawerFragment = (NavigationDrawerFragment)
|
//navigationDrawerFragment = (NavigationDrawerFragment)
|
||||||
getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
// getFragmentManager().findFragmentById(R.id.navigation_drawer);
|
||||||
statusFragment = (StatusFragment)
|
statusFragment = (StatusFragment)
|
||||||
getFragmentManager().findFragmentById(R.id.status_fragment);
|
getFragmentManager().findFragmentById(R.id.status_fragment);
|
||||||
|
|
||||||
// Set up the drawer.
|
// Set up the drawer.
|
||||||
navigationDrawerFragment.setUp(
|
//navigationDrawerFragment.setUp(
|
||||||
R.id.navigation_drawer,
|
// R.id.navigation_drawer,
|
||||||
(DrawerLayout) findViewById(R.id.drawer_layout));
|
// (DrawerLayout) findViewById(R.id.drawer_layout));
|
||||||
|
|
||||||
executors = new ArrayList<UeControlExecutor>();
|
currentExecutor = new UeControlExecutor();
|
||||||
currentExecutor = 0;
|
currentExecutor.addBehaviour(new UeBehaviourSleep());
|
||||||
|
currentExecutor.addBehaviour(new UeBehaviourSurfing());
|
||||||
UeControlExecutor exec = new UeControlExecutor();
|
currentExecutor.addBehaviour(new UeBehaviourSleep(4000));
|
||||||
exec.addBehaviour(new UeBehaviourSleep());
|
currentExecutor.setThroughputListener(statusFragment.getThroughputListener());
|
||||||
exec.addBehaviour(new UeBehaviourSurfing());
|
onNavigationDrawerItemSelected(0);
|
||||||
exec.addBehaviour(new UeBehaviourSleep(4000));
|
|
||||||
exec.setThroughputListener(statusFragment.getThroughputListener());
|
|
||||||
executors.add(exec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -64,13 +61,12 @@ public class MainActivity extends FragmentActivity
|
||||||
// update the main content by replacing fragments
|
// update the main content by replacing fragments
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, BehaviourListFragment.newInstance(position)).commit();
|
.replace(R.id.container, BehaviourListFragment.newInstance()).commit();
|
||||||
currentExecutor = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
if (navigationDrawerFragment != null && !navigationDrawerFragment.isDrawerOpen()) {
|
if (navigationDrawerFragment == null || !navigationDrawerFragment.isDrawerOpen()) {
|
||||||
// Only show items in the action bar relevant to this screen
|
// Only show items in the action bar relevant to this screen
|
||||||
// if the drawer is not showing. Otherwise, let the drawer
|
// if the drawer is not showing. Otherwise, let the drawer
|
||||||
// decide what to show in the action bar.
|
// decide what to show in the action bar.
|
||||||
|
|
@ -93,20 +89,23 @@ public class MainActivity extends FragmentActivity
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
if (id == R.id.action_execute) {
|
if (id == R.id.action_execute) {
|
||||||
UeControlExecutor exec = executors.get(currentExecutor);
|
if(currentExecutor.isRunning()){
|
||||||
if(exec.isRunning()){
|
currentExecutor.terminate();
|
||||||
exec.terminate();
|
|
||||||
item.setTitle(R.string.action_run);
|
item.setTitle(R.string.action_run);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
exec.execute();
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
if(prefs.getBoolean("logging", false))
|
||||||
|
logger = new CSVWriter(this);
|
||||||
|
else
|
||||||
|
logger = null;
|
||||||
|
currentExecutor.execute();
|
||||||
item.setTitle(R.string.action_stop);
|
item.setTitle(R.string.action_stop);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (id == R.id.action_edit) {
|
if (id == R.id.action_edit) {
|
||||||
Intent intent = new Intent(this, EditActivity.class);
|
Intent intent = new Intent(this, EditActivity.class);
|
||||||
intent.putExtra("executor", currentExecutor);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -117,9 +116,14 @@ public class MainActivity extends FragmentActivity
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UeControlExecutor getExecutor(int index) {
|
public static UeControlExecutor getExecutor() {
|
||||||
if(index >= executors.size())
|
return currentExecutor;
|
||||||
return null;
|
}
|
||||||
return executors.get(index);
|
|
||||||
|
public static void logThroughput(double downThroughput, double upThroughput) {
|
||||||
|
if(logger == null || currentExecutor == null || currentExecutor.getRunningBehaviour() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
logger.write(currentExecutor.getRunningBehaviour().getName(), downThroughput, upThroughput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ public class BehaviourListFragment extends Fragment {
|
||||||
private BehaviourListAdapter adapter;
|
private BehaviourListAdapter adapter;
|
||||||
private UeControlExecutor executor;
|
private UeControlExecutor executor;
|
||||||
|
|
||||||
public static BehaviourListFragment newInstance(int index) {
|
public static BehaviourListFragment newInstance() {
|
||||||
BehaviourListFragment f = new BehaviourListFragment();
|
BehaviourListFragment f = new BehaviourListFragment();
|
||||||
// Supply index input as an argument.
|
// Supply index input as an argument.
|
||||||
Bundle args = new Bundle();
|
//Bundle args = new Bundle();
|
||||||
args.putInt("executor", index);
|
//args.putInt("executor", index);
|
||||||
f.setArguments(args);
|
//f.setArguments(args);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,11 +46,8 @@ public class BehaviourListFragment extends Fragment {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Bundle args = getArguments();
|
if(MainActivity.getExecutor() != null) {
|
||||||
int index = args.getInt("executor", 0);
|
UeControlExecutor executor = MainActivity.getExecutor();
|
||||||
|
|
||||||
if(MainActivity.getExecutor(index) != null) {
|
|
||||||
UeControlExecutor executor = MainActivity.getExecutor(index);
|
|
||||||
adapter = new BehaviourListAdapter(getActivity(), executor.getBehaviourList());
|
adapter = new BehaviourListAdapter(getActivity(), executor.getBehaviourList());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||||
private boolean mFromSavedInstanceState;
|
private boolean mFromSavedInstanceState;
|
||||||
private boolean mUserLearnedDrawer;
|
private boolean mUserLearnedDrawer;
|
||||||
|
|
||||||
public NavigationDrawerFragment() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
package com.ericsson.uecontrol.gui.fragments;
|
package com.ericsson.uecontrol.gui.fragments;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -13,6 +19,8 @@ import android.widget.TextView;
|
||||||
import com.ericsson.uecontrol.R;
|
import com.ericsson.uecontrol.R;
|
||||||
import com.ericsson.uecontrol.core.UeControlExecutor;
|
import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||||
import com.ericsson.uecontrol.core.util.ThroughputCalculator;
|
import com.ericsson.uecontrol.core.util.ThroughputCalculator;
|
||||||
|
import com.ericsson.uecontrol.gui.MainActivity;
|
||||||
|
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
||||||
import com.jjoe64.graphview.GraphView.GraphViewData;
|
import com.jjoe64.graphview.GraphView.GraphViewData;
|
||||||
import com.jjoe64.graphview.GraphViewSeries;
|
import com.jjoe64.graphview.GraphViewSeries;
|
||||||
import com.jjoe64.graphview.GraphViewSeries.GraphViewSeriesStyle;
|
import com.jjoe64.graphview.GraphViewSeries.GraphViewSeriesStyle;
|
||||||
|
|
@ -67,11 +75,13 @@ public class StatusFragment extends Fragment {
|
||||||
down_speed.post(new Runnable() {
|
down_speed.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
down_speed.setText(ThroughputCalculator.getThroughputString(downThroughput));
|
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
||||||
up_speed.setText(ThroughputCalculator.getThroughputString(upThroughput));
|
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
||||||
downGraph.appendData(new GraphViewData(x, downThroughput), true, 120);
|
downGraph.appendData(new GraphViewData(x, downThroughput), true, 120);
|
||||||
upGraph.appendData(new GraphViewData(x, upThroughput), true, 120);
|
upGraph.appendData(new GraphViewData(x, upThroughput), true, 120);
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
|
MainActivity.logThroughput(downThroughput, upThroughput);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
108
app/src/main/java/com/ericsson/uecontrol/gui/util/CSVWriter.java
Executable file
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.ericsson.uecontrol.gui.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ezivkoc on 2014-07-30.
|
||||||
|
*/
|
||||||
|
public class CSVWriter {
|
||||||
|
public static final String[] HEADINGS = new String[]{
|
||||||
|
"Timestamp", "Behaviour", "RX Throughput(b/s)", "TX Throughput(b/s)", "RAT"
|
||||||
|
};
|
||||||
|
public static final String DELIMITER = ",";
|
||||||
|
protected static final SimpleDateFormat fileDateFormater = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
protected static final SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
|
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
|
||||||
|
private NetworkInfo netInfo;
|
||||||
|
private WifiInfo wifiInfo;
|
||||||
|
private TelephonyManager telMan;
|
||||||
|
|
||||||
|
public CSVWriter(Context context){
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
file = new File(
|
||||||
|
prefs.getString("logging_path", "/sdcard/uecontrol/"),
|
||||||
|
"log_"+fileDateFormater.format(System.currentTimeMillis())+".log");
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
netInfo = cm.getActiveNetworkInfo();
|
||||||
|
|
||||||
|
WifiManager wm = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
wifiInfo = wm.getConnectionInfo();
|
||||||
|
|
||||||
|
telMan = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
|
||||||
|
// Write Headings
|
||||||
|
StringBuilder line = new StringBuilder();
|
||||||
|
for(String header : HEADINGS){
|
||||||
|
line.append(header).append(DELIMITER);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.delete();
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
writeLine(line.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void write(String behaviour){
|
||||||
|
StringBuilder line = new StringBuilder();
|
||||||
|
line.append(getTime()).append(DELIMITER);
|
||||||
|
line.append(behaviour).append(DELIMITER);
|
||||||
|
line.append(DELIMITER);
|
||||||
|
line.append(DELIMITER);
|
||||||
|
line.append(getRat()).append(DELIMITER);
|
||||||
|
writeLine(line.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(String behaviour, double down, double up){
|
||||||
|
StringBuilder line = new StringBuilder();
|
||||||
|
line.append(getTime()).append(DELIMITER);
|
||||||
|
line.append(behaviour).append(DELIMITER);
|
||||||
|
line.append(down).append(DELIMITER);
|
||||||
|
line.append(up).append(DELIMITER);
|
||||||
|
line.append(getRat()).append(DELIMITER);
|
||||||
|
writeLine(line.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeLine(String line){
|
||||||
|
try{
|
||||||
|
PrintWriter out = new PrintWriter(new FileOutputStream(file, true));
|
||||||
|
out.println(line);
|
||||||
|
out.close();
|
||||||
|
} catch(IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getRat(){
|
||||||
|
if(netInfo.getType() == ConnectivityManager.TYPE_MOBILE){
|
||||||
|
switch(telMan.getNetworkType()){
|
||||||
|
case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS";
|
||||||
|
case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE";
|
||||||
|
case TelephonyManager.NETWORK_TYPE_UMTS: return "UMTS";
|
||||||
|
case TelephonyManager.NETWORK_TYPE_HSPA: return "HSPA";
|
||||||
|
case TelephonyManager.NETWORK_TYPE_LTE: return "LTE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return netInfo.getTypeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getTime(){
|
||||||
|
return dateFormater.format(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
app/src/main/res/drawable-hdpi/ic_action.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
app/src/main/res/drawable-ldpi/ic_action.png
Normal file
|
After Width: | Height: | Size: 295 B |
BIN
app/src/main/res/drawable-mdpi/ic_action.png
Normal file
|
After Width: | Height: | Size: 351 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action.png
Normal file
|
After Width: | Height: | Size: 660 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action.png
Normal file
|
After Width: | Height: | Size: 1,004 B |
|
|
@ -34,11 +34,12 @@
|
||||||
android:layout_gravity="left" instead. -->
|
android:layout_gravity="left" instead. -->
|
||||||
<!-- The drawer is given a fixed width in dp and extends the full height of
|
<!-- The drawer is given a fixed width in dp and extends the full height of
|
||||||
the container. -->
|
the container. -->
|
||||||
|
<!--
|
||||||
<fragment android:id="@+id/navigation_drawer"
|
<fragment android:id="@+id/navigation_drawer"
|
||||||
android:layout_width="@dimen/navigation_drawer_width"
|
android:layout_width="@dimen/navigation_drawer_width"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:name="com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment"
|
android:name="com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment"
|
||||||
tools:layout="@layout/fragment_navigation_drawer" />
|
tools:layout="@layout/fragment_navigation_drawer" />
|
||||||
|
-->
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,19 @@
|
||||||
android:typeface="sans"
|
android:typeface="sans"
|
||||||
android:textSize="17dip"
|
android:textSize="17dip"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_toEndOf="@+id/draggable"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentTop="true" />
|
android:layout_toRightOf="@+id/draggable" />
|
||||||
|
|
||||||
<!-- Behaviour description -->
|
<!-- Behaviour description -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/title"
|
|
||||||
android:textColor="#343434"
|
android:textColor="#343434"
|
||||||
android:textSize="12dip"
|
android:textSize="12dip"
|
||||||
android:layout_marginTop="1dip"
|
|
||||||
android:text="Description"
|
android:text="Description"
|
||||||
android:layout_toEndOf="@+id/draggable"/>
|
android:layout_below="@+id/title"
|
||||||
|
android:layout_toRightOf="@+id/draggable" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Rightend -->
|
<!-- Rightend -->
|
||||||
|
|
@ -72,7 +71,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/description"
|
android:layout_below="@+id/description"
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:weightSum="1"
|
android:weightSum="1"
|
||||||
android:padding="10dp">
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
@ -55,8 +57,10 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/graph"
|
android:id="@+id/graph"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
android:key="logging_path"
|
android:key="logging_path"
|
||||||
android:title="@string/pref_logging_path"
|
android:title="@string/pref_logging_path"
|
||||||
android:summary="@string/pref_logging_path_summ"
|
android:summary="@string/pref_logging_path_summ"
|
||||||
android:defaultValue="/sdcard/uecontrol" />
|
android:defaultValue="/sdcard/uecontrol/" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
|
||||||
BIN
app_icon.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
device-2014-07-29-112156.png
Executable file
|
After Width: | Height: | Size: 116 KiB |
BIN
device-2014-07-29-112236.png
Executable file
|
After Width: | Height: | Size: 84 KiB |