Fixed CSV crash when rotating
This commit is contained in:
parent
d7d729f6c1
commit
76b3790888
3 changed files with 20 additions and 17 deletions
|
|
@ -159,7 +159,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
else {
|
else {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
if(prefs.getBoolean("logging", true))
|
if(prefs.getBoolean("logging", true))
|
||||||
csvLogger = new CSVWriter(this);
|
csvLogger = new CSVWriter();
|
||||||
else
|
else
|
||||||
csvLogger = null;
|
csvLogger = null;
|
||||||
currentExecutor.execute();
|
currentExecutor.execute();
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class StatusFragment extends Fragment {
|
||||||
public void run() {
|
public void run() {
|
||||||
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
down_speed.setText(ThroughputCalculator.getBitThroughputString(downThroughput));
|
||||||
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
up_speed.setText(ThroughputCalculator.getBitThroughputString(upThroughput));
|
||||||
rat_type.setText(CSVWriter.getRat(getActivity()));
|
rat_type.setText(CSVWriter.getRat());
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ import android.telephony.NeighboringCellInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.gsm.GsmCellLocation;
|
import android.telephony.gsm.GsmCellLocation;
|
||||||
|
|
||||||
|
import com.ericsson.uecontrol.gui.MainActivity;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -41,10 +43,9 @@ public class CSVWriter {
|
||||||
|
|
||||||
|
|
||||||
private File file;
|
private File file;
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public CSVWriter(Context context){
|
public CSVWriter(){
|
||||||
this.context = context;
|
Context context = MainActivity.getContext();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
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;
|
||||||
|
|
@ -52,7 +53,6 @@ public class CSVWriter {
|
||||||
path,
|
path,
|
||||||
"log_"+fileDateFormater.format(System.currentTimeMillis())+".csv");
|
"log_"+fileDateFormater.format(System.currentTimeMillis())+".csv");
|
||||||
|
|
||||||
|
|
||||||
// Write Headings
|
// Write Headings
|
||||||
StringBuilder line = new StringBuilder();
|
StringBuilder line = new StringBuilder();
|
||||||
for(String header : HEADINGS){
|
for(String header : HEADINGS){
|
||||||
|
|
@ -71,10 +71,10 @@ public class CSVWriter {
|
||||||
line.append(behaviour).append(DELIMITER);
|
line.append(behaviour).append(DELIMITER);
|
||||||
line.append(down).append(DELIMITER);
|
line.append(down).append(DELIMITER);
|
||||||
line.append(up).append(DELIMITER);
|
line.append(up).append(DELIMITER);
|
||||||
line.append(getRat(context)).append(DELIMITER);
|
line.append(getRat()).append(DELIMITER);
|
||||||
line.append(getCellIds(context)).append(DELIMITER);
|
line.append(getCellIds()).append(DELIMITER);
|
||||||
line.append(getSSID(context)).append(DELIMITER);
|
line.append(getSSID()).append(DELIMITER);
|
||||||
line.append(getRssi(context)).append(DELIMITER);
|
line.append(getRssi()).append(DELIMITER);
|
||||||
writeLine(line.toString());
|
writeLine(line.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +88,8 @@ public class CSVWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRat(Context context){
|
public static String getRat(){
|
||||||
|
Context context = MainActivity.getContext();
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||||
if(netInfo == null)
|
if(netInfo == null)
|
||||||
|
|
@ -112,7 +113,8 @@ public class CSVWriter {
|
||||||
|
|
||||||
|
|
||||||
//******************* MOBILE ********************************************
|
//******************* MOBILE ********************************************
|
||||||
private static String getCellIds(Context context){
|
private static String getCellIds(){
|
||||||
|
Context context = MainActivity.getContext();
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||||
if(netInfo == null)
|
if(netInfo == null)
|
||||||
|
|
@ -170,7 +172,8 @@ public class CSVWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************* WIFI ********************************************
|
//******************* WIFI ********************************************
|
||||||
private static WifiInfo getWifiInfo(Context context){
|
private static WifiInfo getWifiInfo(){
|
||||||
|
Context context = MainActivity.getContext();
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||||
if(netInfo == null || netInfo.getType() != ConnectivityManager.TYPE_WIFI)
|
if(netInfo == null || netInfo.getType() != ConnectivityManager.TYPE_WIFI)
|
||||||
|
|
@ -180,15 +183,15 @@ public class CSVWriter {
|
||||||
WifiInfo wifiInfo = wm.getConnectionInfo();
|
WifiInfo wifiInfo = wm.getConnectionInfo();
|
||||||
return wifiInfo;
|
return wifiInfo;
|
||||||
}
|
}
|
||||||
private static String getSSID(Context context){
|
private static String getSSID(){
|
||||||
WifiInfo wifiInfo = getWifiInfo(context);
|
WifiInfo wifiInfo = getWifiInfo();
|
||||||
if(wifiInfo == null)
|
if(wifiInfo == null)
|
||||||
return "n/a";
|
return "n/a";
|
||||||
return wifiInfo.getSSID().replace("\"", "");
|
return wifiInfo.getSSID().replace("\"", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getRssi(Context context){
|
private static String getRssi(){
|
||||||
WifiInfo wifiInfo = getWifiInfo(context);
|
WifiInfo wifiInfo = getWifiInfo();
|
||||||
if(wifiInfo == null)
|
if(wifiInfo == null)
|
||||||
return "n/a";
|
return "n/a";
|
||||||
return ""+wifiInfo.getRssi();
|
return ""+wifiInfo.getRssi();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue