Added marking log ability.
This commit is contained in:
parent
c1b2da18d5
commit
bd82634b6b
4 changed files with 30 additions and 5 deletions
|
|
@ -5,8 +5,6 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
@ -21,7 +19,6 @@ import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
|
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep;
|
||||||
import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing;
|
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.StatusFragment;
|
import com.ericsson.uecontrol.gui.fragments.StatusFragment;
|
||||||
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
import com.ericsson.uecontrol.gui.util.CSVWriter;
|
||||||
|
|
||||||
|
|
@ -42,6 +39,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
/** Fragments **/
|
/** Fragments **/
|
||||||
private StatusFragment statusFragment;
|
private StatusFragment statusFragment;
|
||||||
private MenuItem action_execute;
|
private MenuItem action_execute;
|
||||||
|
private MenuItem action_mark;
|
||||||
private boolean backButtonPressed = false;
|
private boolean backButtonPressed = false;
|
||||||
|
|
||||||
private static UeControlExecutor currentExecutor;
|
private static UeControlExecutor currentExecutor;
|
||||||
|
|
@ -54,6 +52,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// Set static fields
|
// Set static fields
|
||||||
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||||
uid = getApplicationInfo().uid;
|
uid = getApplicationInfo().uid;
|
||||||
context = this;
|
context = this;
|
||||||
|
|
||||||
|
|
@ -139,6 +138,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||||
actionBar.setDisplayShowTitleEnabled(true);
|
actionBar.setDisplayShowTitleEnabled(true);
|
||||||
action_execute = (MenuItem) menu.findItem(R.id.action_execute);
|
action_execute = (MenuItem) menu.findItem(R.id.action_execute);
|
||||||
|
action_mark = (MenuItem) menu.findItem(R.id.action_mark);
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -167,11 +167,18 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (id == R.id.action_mark) {
|
||||||
|
if(csvLogger != null) {
|
||||||
|
csvLogger.addComment("--- Mark ---");
|
||||||
|
Toast.makeText(this, "Mark added to log", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (id == R.id.action_reset) {
|
else if (id == R.id.action_reset) {
|
||||||
if(currentExecutor != null)
|
if(currentExecutor != null)
|
||||||
currentExecutor.reset();
|
currentExecutor.reset();
|
||||||
if(statusFragment != null)
|
if(statusFragment != null)
|
||||||
statusFragment.reset();
|
statusFragment.reset();
|
||||||
|
csvLogger = null;
|
||||||
updateExecutionState();
|
updateExecutionState();
|
||||||
}
|
}
|
||||||
else if (id == R.id.action_edit) {
|
else if (id == R.id.action_edit) {
|
||||||
|
|
@ -195,11 +202,14 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
if(action_execute != null) {
|
if(action_execute != null) {
|
||||||
if (currentExecutor.isRunning()) {
|
if (currentExecutor.isRunning()) {
|
||||||
action_execute.setTitle(R.string.action_stop);
|
action_execute.setTitle(R.string.action_stop);
|
||||||
|
if(action_mark != null && csvLogger != null)
|
||||||
|
action_mark.setEnabled(true);
|
||||||
if(prefs.getBoolean("screen_on", false))
|
if(prefs.getBoolean("screen_on", false))
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action_execute.setTitle(R.string.action_run);
|
action_execute.setTitle(R.string.action_run);
|
||||||
|
action_mark.setEnabled(false);
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,20 @@ public class CSVWriter {
|
||||||
private static final Logger log = Logger.getLogger(CSVWriter.class);
|
private static final Logger log = Logger.getLogger(CSVWriter.class);
|
||||||
public static final String[] HEADINGS = new String[]{
|
public static final String[] HEADINGS = new String[]{
|
||||||
"Timestamp", "Behaviour", "RX Throughput(b/s)", "TX Throughput(b/s)",
|
"Timestamp", "Behaviour", "RX Throughput(b/s)", "TX Throughput(b/s)",
|
||||||
"RAT", "CellIds", "WIFI SSID", "WIFI RSSI"
|
"RAT", "CellIds", "WIFI SSID", "WIFI RSSI", "Comment"
|
||||||
};
|
};
|
||||||
public static final String DELIMITER = ";";
|
public static final String DELIMITER = ";";
|
||||||
protected static final SimpleDateFormat fileDateFormater = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
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");
|
protected static final SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
|
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
|
private String comment;
|
||||||
|
|
||||||
public CSVWriter(){
|
public CSVWriter(){
|
||||||
Context context = MainActivity.getContext();
|
Context context = MainActivity.getContext();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
comment = "";
|
||||||
|
|
||||||
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
String path = prefs.getString("logging_path", "/sdcard/uecontrol/");
|
||||||
if(!path.endsWith(File.separator)) path += File.separator;
|
if(!path.endsWith(File.separator)) path += File.separator;
|
||||||
file = new File(
|
file = new File(
|
||||||
|
|
@ -75,7 +77,10 @@ public class CSVWriter {
|
||||||
line.append(getCellIds()).append(DELIMITER);
|
line.append(getCellIds()).append(DELIMITER);
|
||||||
line.append(getSSID()).append(DELIMITER);
|
line.append(getSSID()).append(DELIMITER);
|
||||||
line.append(getRssi()).append(DELIMITER);
|
line.append(getRssi()).append(DELIMITER);
|
||||||
|
line.append(comment).append(DELIMITER);
|
||||||
writeLine(line.toString());
|
writeLine(line.toString());
|
||||||
|
|
||||||
|
comment = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeLine(String line){
|
protected void writeLine(String line){
|
||||||
|
|
@ -88,6 +93,10 @@ public class CSVWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addComment(String str){
|
||||||
|
comment = str;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getRat(){
|
public static String getRat(){
|
||||||
Context context = MainActivity.getContext();
|
Context context = MainActivity.getContext();
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,11 @@
|
||||||
android:title="@string/action_run"
|
android:title="@string/action_run"
|
||||||
android:showAsAction="withText|ifRoom" />
|
android:showAsAction="withText|ifRoom" />
|
||||||
|
|
||||||
|
<item android:id="@+id/action_mark"
|
||||||
|
android:title="@string/action_mark"
|
||||||
|
android:orderInCategory="0"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:enabled="false" />
|
||||||
<item android:id="@+id/action_reset"
|
<item android:id="@+id/action_reset"
|
||||||
android:title="@string/action_reset"
|
android:title="@string/action_reset"
|
||||||
android:orderInCategory="50"
|
android:orderInCategory="50"
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,6 @@
|
||||||
<string name="action_reset">Reset</string>
|
<string name="action_reset">Reset</string>
|
||||||
<string name="pref_screen_on_summ">Keep screen on while execution</string>
|
<string name="pref_screen_on_summ">Keep screen on while execution</string>
|
||||||
<string name="pref_screen_on">Keep Screen On</string>
|
<string name="pref_screen_on">Keep Screen On</string>
|
||||||
|
<string name="action_mark">Add Mark</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue