From 5b6e83c6f6373147712dd49c404785c1839f7e65 Mon Sep 17 00:00:00 2001 From: Sathyanarayanan Gunasekaran Date: Tue, 26 Jul 2011 13:16:30 -0400 Subject: [PATCH] Total Bandwidth prep code --- res/layout/layout_main.xml | 3 +- src/org/torproject/android/Orbot.java | 13 +++++++- .../android/service/ITorService.aidl | 5 +++ .../android/service/TorService.java | 33 ++++++++++++------- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/res/layout/layout_main.xml b/res/layout/layout_main.xml index 4fae7196..1a25febc 100644 --- a/res/layout/layout_main.xml +++ b/res/layout/layout_main.xml @@ -105,7 +105,8 @@ android:gravity="center_vertical|center_horizontal" android:textStyle="bold" /> - + + diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java index 68e4aafd..f9c949df 100644 --- a/src/org/torproject/android/Orbot.java +++ b/src/org/torproject/android/Orbot.java @@ -768,7 +768,18 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener uploadText.setText(formatCount(datacount.Upload)); downloadText.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; default: diff --git a/src/org/torproject/android/service/ITorService.aidl b/src/org/torproject/android/service/ITorService.aidl index e643b4db..07fa8089 100644 --- a/src/org/torproject/android/service/ITorService.aidl +++ b/src/org/torproject/android/service/ITorService.aidl @@ -48,4 +48,9 @@ interface ITorService { */ String getConfiguration (String name); + /** + * Get information + */ + String getInfo (String args); + } diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 01c693c2..23921a98 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.StringTokenizer; import net.freehaven.tor.control.ConfigEntry; @@ -1120,14 +1121,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst sb.append("kb read / "); sb.append(written/1000); 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()); } @@ -1136,7 +1130,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst } - + 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) {