Data stats - ARRRRRRRR not working
This commit is contained in:
parent
26464765a9
commit
f181f26d4e
|
@ -57,6 +57,55 @@
|
||||||
|
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
/>
|
/>
|
||||||
|
<RelativeLayout android:id="@+id/trafficRow"
|
||||||
|
android:gravity="bottom"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:background="#A0909090">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trafficDownLabel"
|
||||||
|
android:textColor="#FFFFFFFF"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:text="@string/main_layout_download"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trafficUpLabel"
|
||||||
|
android:textColor="#FFFFFFFF"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="@string/main_layout_upload"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trafficDown"
|
||||||
|
android:textColor="#FF00B627"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_below="@+id/trafficDownLabel"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/trafficUp"
|
||||||
|
android:textColor="#FFFF2211"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_below="@+id/trafficUpLabel"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="menu_wizard">Wizard</string>
|
<string name="menu_wizard">Wizard</string>
|
||||||
|
|
||||||
|
<string name="main_layout_download">Download</string>
|
||||||
|
<string name="main_layout_upload">Upload</string>
|
||||||
|
|
||||||
<string name="button_help">Help</string>
|
<string name="button_help">Help</string>
|
||||||
<string name="button_close">Close</string>
|
<string name="button_close">Close</string>
|
||||||
|
|
|
@ -42,57 +42,64 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnLongClickListener;
|
import android.view.View.OnLongClickListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/* Useful UI bits */
|
|
||||||
// so this is probably pretty obvious, here, but also an area
|
|
||||||
// which we might see quite a bit of change+complexity was the main screen
|
|
||||||
// UI gets new features
|
|
||||||
private TextView lblStatus = null; //the main text display widget
|
|
||||||
private ImageView imgStatus = null; //the main touchable image for activating Orbot
|
|
||||||
private ProgressDialog progressDialog; //the spinning progress dialog that shows up now and then
|
|
||||||
private MenuItem mItemOnOff = null; //the menu item which we toggle based on Orbot state
|
|
||||||
|
|
||||||
/* Some tracking bits */
|
|
||||||
private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
|
|
||||||
// this is a value we get passed back from the TorService
|
|
||||||
|
|
||||||
/* Tor Service interaction */
|
|
||||||
/* The primary interface we will be calling on the service. */
|
|
||||||
ITorService mService = null; //interface to remote TorService
|
|
||||||
private boolean autoStartOnBind = false; //controls whether service starts when class binds to it
|
|
||||||
|
|
||||||
SharedPreferences prefs; //what the user really wants!
|
private static final int VISIBLE = 0;
|
||||||
|
/* Useful UI bits */
|
||||||
/**
|
private TextView lblStatus = null; //the main text display widget
|
||||||
* When the Orbot activity is created, we call startService
|
private ImageView imgStatus = null; //the main touchable image for activating Orbot
|
||||||
* to ensure the Tor remote service is running. However, it may
|
private ProgressDialog progressDialog;
|
||||||
* already be running, and this should not create more than one instnace
|
private MenuItem mItemOnOff = null;
|
||||||
*/
|
private RelativeLayout trafficRow = null; // the row showing the traffic
|
||||||
|
private TextView downloadText = null;
|
||||||
|
private TextView uploadText = null;
|
||||||
|
|
||||||
|
/* Some tracking bits */
|
||||||
|
private int torStatus = STATUS_READY; //latest status reported from the tor service
|
||||||
|
|
||||||
|
/* Tor Service interaction */
|
||||||
|
/* The primary interface we will be calling on the service. */
|
||||||
|
ITorService mService = null;
|
||||||
|
private boolean autoStartOnBind = false;
|
||||||
|
|
||||||
|
SharedPreferences prefs;
|
||||||
|
|
||||||
|
public static Orbot currentInstance = null;
|
||||||
|
|
||||||
|
private static void setCurrent(Orbot current){
|
||||||
|
Orbot.currentInstance = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Orbot.setCurrent(this);
|
||||||
|
|
||||||
//if Tor binary is not running, then start the service up
|
//if Tor binary is not running, then start the service up
|
||||||
//might want to look at whether we need to call this every time
|
//might want to look at whether we need to call this every time
|
||||||
//or whether binding to the service is enough
|
//or whether binding to the service is enough
|
||||||
|
|
||||||
setLocale();
|
setLocale();
|
||||||
|
|
||||||
|
startService(new Intent(INTENT_TOR_SERVICE));
|
||||||
|
|
||||||
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
setContentView(R.layout.layout_main);
|
||||||
|
|
||||||
|
lblStatus = (TextView)findViewById(R.id.lblStatus);
|
||||||
|
lblStatus.setOnLongClickListener(this);
|
||||||
|
imgStatus = (ImageView)findViewById(R.id.imgStatus);
|
||||||
|
imgStatus.setOnLongClickListener(this);
|
||||||
|
trafficRow = (RelativeLayout)findViewById(R.id.trafficRow);
|
||||||
|
downloadText = (TextView)findViewById(R.id.trafficDown);
|
||||||
|
uploadText = (TextView)findViewById(R.id.trafficUp);
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
|
|
||||||
setContentView(R.layout.layout_main);
|
|
||||||
|
|
||||||
//obvious? -yep got everything so far
|
|
||||||
lblStatus = (TextView)findViewById(R.id.lblStatus);
|
|
||||||
|
|
||||||
imgStatus = (ImageView)findViewById(R.id.imgStatus);
|
|
||||||
imgStatus.setOnLongClickListener(this);
|
|
||||||
|
|
||||||
startService(new Intent(INTENT_TOR_SERVICE));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -608,6 +615,8 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
msg.getData().putString(HANDLER_TOR_MSG, getString(R.string.status_starting_up));
|
msg.getData().putString(HANDLER_TOR_MSG, getString(R.string.status_starting_up));
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessage(msg);
|
||||||
|
|
||||||
|
trafficRow.setVisibility(VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//now we stop Tor! amazing!
|
//now we stop Tor! amazing!
|
||||||
|
@ -731,11 +740,22 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case TorServiceConstants.DISABLE_TOR_MSG:
|
case TorServiceConstants.DISABLE_TOR_MSG:
|
||||||
|
|
||||||
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
|
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case TorServiceConstants.MESSAGE_TRAFFIC_COUNT :
|
||||||
|
|
||||||
|
DataCount datacount = (DataCount) msg.obj;
|
||||||
|
downloadText.setText(formatCount(datacount.Download));
|
||||||
|
uploadText.setText(formatCount(datacount.Upload));
|
||||||
|
downloadText.invalidate();
|
||||||
|
uploadText.invalidate();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
super.handleMessage(msg);
|
super.handleMessage(msg);
|
||||||
}
|
}
|
||||||
|
@ -885,5 +905,21 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DataCount {
|
||||||
|
// data uploaded
|
||||||
|
public long Upload;
|
||||||
|
// data downloaded
|
||||||
|
public long Download;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatCount(long count) {
|
||||||
|
// Converts the supplied argument into a string.
|
||||||
|
// Under 2Mb, returns "xxx.xKb"
|
||||||
|
// Over 2Mb, returns "xxx.xxMb"
|
||||||
|
if (count < 1e6 * 2)
|
||||||
|
return ((float)((int)(count*10/1024))/10 + "kB");
|
||||||
|
return ((float)((int)(count*100/1024/1024))/100 + "MB");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -50,7 +52,7 @@ import android.util.Log;
|
||||||
public class TorService extends Service implements TorServiceConstants, TorConstants, Runnable, EventHandler
|
public class TorService extends Service implements TorServiceConstants, TorConstants, Runnable, EventHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public static boolean ENABLE_DEBUG_LOG = false;
|
public static boolean ENABLE_DEBUG_LOG = true;
|
||||||
|
|
||||||
private static int currentStatus = STATUS_OFF;
|
private static int currentStatus = STATUS_OFF;
|
||||||
|
|
||||||
|
@ -944,7 +946,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
conn.setEventHandler(this);
|
conn.setEventHandler(this);
|
||||||
|
|
||||||
conn.setEvents(Arrays.asList(new String[]{
|
conn.setEvents(Arrays.asList(new String[]{
|
||||||
"ORCONN", "CIRC", "NOTICE", "WARN", "ERR"}));
|
"ORCONN", "CIRC", "NOTICE", "WARN", "ERR","BW"}));
|
||||||
// conn.setEvents(Arrays.asList(new String[]{
|
// conn.setEvents(Arrays.asList(new String[]{
|
||||||
// "DEBUG", "INFO", "NOTICE", "WARN", "ERR"}));
|
// "DEBUG", "INFO", "NOTICE", "WARN", "ERR"}));
|
||||||
|
|
||||||
|
@ -1118,10 +1120,29 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
sb.append("kb written");
|
sb.append("kb written");
|
||||||
|
|
||||||
logNotice(sb.toString());
|
logNotice(sb.toString());
|
||||||
|
DataCount datacount = new DataCount();
|
||||||
|
|
||||||
|
datacount.Download = read/1000;
|
||||||
|
datacount.Upload = written/1000;
|
||||||
|
|
||||||
|
Message message = Message.obtain();
|
||||||
|
message.what = MESSAGE_TRAFFIC_COUNT;
|
||||||
|
message.obj = datacount;
|
||||||
|
Orbot.currentInstance.mHandler.sendMessage(message);
|
||||||
|
|
||||||
|
//sendCallbackStatusMessage(message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DataCount {
|
||||||
|
// data uploaded
|
||||||
|
public long Upload;
|
||||||
|
// data downloaded
|
||||||
|
public long Download;
|
||||||
|
}
|
||||||
|
|
||||||
public void circuitStatus(String status, String circID, String path) {
|
public void circuitStatus(String status, String circID, String path) {
|
||||||
|
|
||||||
if (ENABLE_DEBUG_LOG)
|
if (ENABLE_DEBUG_LOG)
|
||||||
|
@ -1441,8 +1462,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
{
|
{
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",true);
|
||||||
|
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
||||||
|
|
||||||
|
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||||
|
|
||||||
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
||||||
|
|
||||||
|
|
|
@ -85,4 +85,6 @@ public interface TorServiceConstants {
|
||||||
//obfsproxy
|
//obfsproxy
|
||||||
public static final String OBFSPROXY_ASSET_KEY = "obfsproxy";
|
public static final String OBFSPROXY_ASSET_KEY = "obfsproxy";
|
||||||
|
|
||||||
|
public static final int MESSAGE_TRAFFIC_COUNT = 5;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue