From 8c177d4725f487bdc8d37deb6d861c5df460e66e Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Wed, 24 Feb 2010 05:09:24 +0000 Subject: [PATCH] added check for trans proxy preference svn:r21749 --- Orbot/src/org/torproject/android/Orbot.java | 13 +++++---- .../org/torproject/android/TorConstants.java | 3 ++ .../torproject/android/service/TorRoot.java | 29 +++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Orbot/src/org/torproject/android/Orbot.java b/Orbot/src/org/torproject/android/Orbot.java index ac79eb83..eac3d64e 100644 --- a/Orbot/src/org/torproject/android/Orbot.java +++ b/Orbot/src/org/torproject/android/Orbot.java @@ -63,8 +63,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setTheme(android.R.style.Theme_Black); - setTitle(getString(R.string.app_name) + ' ' + getString(R.string.app_version)); + setTheme(android.R.style.Theme_Black_NoTitleBar); + //setTitle(getString(R.string.app_name) + ' ' + getString(R.string.app_version)); showMain(); } @@ -328,7 +328,9 @@ public class Orbot extends Activity implements OnClickListener, TorConstants boolean useBridges = prefs.getBoolean(PREF_BRIDGES_ENABLED, false); boolean autoUpdateBridges = prefs.getBoolean(PREF_BRIDGES_UPDATED, false); - + + enableTransparentProxy = prefs.getBoolean(PREF_TRANSPARENT, false); + String bridgeList = prefs.getString(PREF_BRIDGES_LIST,""); if (useBridges) @@ -496,7 +498,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants processSettings(); mService.setProfile(PROFILE_ON); - if (hasRoot) + if (hasRoot && enableTransparentProxy) { TorRoot.enableDNSProxying(); TorRoot.enabledWebProxying(); @@ -507,7 +509,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants mService.setProfile(PROFILE_ONDEMAND); - if (hasRoot) + if (hasRoot && enableTransparentProxy) { TorRoot.purgeNatIptables(); } @@ -606,6 +608,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants boolean mIsBound = false; boolean hasRoot = false; + boolean enableTransparentProxy = false; private void bindService () { diff --git a/Orbot/src/org/torproject/android/TorConstants.java b/Orbot/src/org/torproject/android/TorConstants.java index 4346568e..c0930db2 100644 --- a/Orbot/src/org/torproject/android/TorConstants.java +++ b/Orbot/src/org/torproject/android/TorConstants.java @@ -34,4 +34,7 @@ public interface TorConstants { public final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled"; public final static String PREF_BRIDGES_UPDATED = "pref_bridges_enabled"; public final static String PREF_BRIDGES_LIST = "pref_bridges_list"; + public final static String PREF_TRANSPARENT = "pref_transparent"; + + } diff --git a/Orbot/src/org/torproject/android/service/TorRoot.java b/Orbot/src/org/torproject/android/service/TorRoot.java index 2224d227..92c3ee8e 100644 --- a/Orbot/src/org/torproject/android/service/TorRoot.java +++ b/Orbot/src/org/torproject/android/service/TorRoot.java @@ -5,6 +5,12 @@ package org.torproject.android.service; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.util.Iterator; +import java.util.List; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.util.Log; /** @@ -227,4 +233,27 @@ public final class TorRoot { exec = null; } } + + public void getApps (Context context) + { + PackageManager pMgr = context.getPackageManager(); + + List lAppInfo = pMgr.getInstalledApplications(0); + + Iterator itAppInfo = lAppInfo.iterator(); + + ApplicationInfo aInfo = null; + + while (itAppInfo.hasNext()) + { + aInfo = itAppInfo.next(); + + boolean appEnabled = aInfo.enabled; + int uid = aInfo.uid; //-m owner --uid-owner + String username = pMgr.getNameForUid(uid); + String procName = aInfo.processName; + String name = aInfo.name; + + } + } }