Total Bandwidth prep code

This commit is contained in:
Sathyanarayanan Gunasekaran 2011-07-26 13:16:30 -04:00 committed by n8fr8
parent 92fbd45f4e
commit 5b6e83c6f6
4 changed files with 41 additions and 13 deletions

View File

@ -105,7 +105,8 @@
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:textStyle="bold" /> android:textStyle="bold" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View File

@ -768,7 +768,18 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
uploadText.setText(formatCount(datacount.Upload)); uploadText.setText(formatCount(datacount.Upload));
downloadText.invalidate(); downloadText.invalidate();
uploadText.invalidate(); uploadText.invalidate();
try {
String TotalUpload = mService.getInfo("traffic/written");
String TotalDownload = mService.getInfo("traffic/read");
StringBuilder sb = new StringBuilder();
sb.append("Total Upload " + TotalUpload);
sb.append("Total Download" + TotalDownload);
Log.d(TAG,sb.toString());
} catch (RemoteException e) {
Log.d(TAG,"Total bandwidth error"+e.getMessage());
}
break; break;
default: default:

View File

@ -48,4 +48,9 @@ interface ITorService {
*/ */
String getConfiguration (String name); String getConfiguration (String name);
/**
* Get information
*/
String getInfo (String args);
} }

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.freehaven.tor.control.ConfigEntry; import net.freehaven.tor.control.ConfigEntry;
@ -1120,14 +1121,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
sb.append("kb read / "); sb.append("kb read / ");
sb.append(written/1000); sb.append(written/1000);
sb.append("kb written"); sb.append("kb written");
/* try {
sb.append("Total upload :"+conn.getInfo("traffic/written"));
sb.append("Total Download "+conn.getInfo("traffic/read"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
logNotice(sb.toString()); logNotice(sb.toString());
} }
@ -1136,7 +1130,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
} }
public void circuitStatus(String status, String circID, String path) { public void circuitStatus(String status, String circID, String path) {
@ -1274,8 +1268,25 @@ public class TorService extends Service implements TorServiceConstants, TorConst
} }
} }
public String getInfo (String key) {
try
{
if(conn !=null)
{
String m = conn.getInfo(key);
return m;
}
}
catch(IOException ioe)
{
Log.e(TAG,"Unable to get Tor information",ioe);
logNotice("Unable to get Tor information"+ioe.getMessage());
}
return null;
}
public String getConfiguration (String name) public String getConfiguration (String name)
{ {