From d357022ff9938e78fbabaefc154b427898f555b5 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Fri, 17 Sep 2010 21:32:21 +0000 Subject: [PATCH] checking in what should be 1.0.4 svn:r23223 --- AndroidManifest.xml | 15 +--- AndroidManifest.xml.debug | 59 ++++++++++++ AndroidManifest.xml.production | 58 ++++++++++++ CHANGELOG | 5 ++ src/org/torproject/android/Orbot.java | 89 +++++++++---------- .../android/SettingsPreferences.java | 3 +- src/org/torproject/android/WizardHelper.java | 3 +- .../android/service/TorService.java | 22 +++-- .../android/service/TorServiceConstants.java | 2 +- .../android/service/TorServiceUtils.java | 32 +++++++ .../android/service/TorTransProxy.java | 28 +----- 11 files changed, 220 insertions(+), 96 deletions(-) create mode 100644 AndroidManifest.xml.debug create mode 100644 AndroidManifest.xml.production diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 471b1213..f7284f20 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,11 +1,11 @@ + package="org.torproject.android" android:versionName="1.0.4" android:versionCode="10"> - + @@ -33,22 +33,13 @@ - - + - - - - - - - diff --git a/AndroidManifest.xml.debug b/AndroidManifest.xml.debug new file mode 100644 index 00000000..471b1213 --- /dev/null +++ b/AndroidManifest.xml.debug @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AndroidManifest.xml.production b/AndroidManifest.xml.production new file mode 100644 index 00000000..de67238e --- /dev/null +++ b/AndroidManifest.xml.production @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CHANGELOG b/CHANGELOG index f528e20f..398b1641 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ NOTE: Specific #s below correspond to Trac tickets logged and maintained at https://trac.torproject.org/projects/tor/ +1.0.4 +- Added Russian, Persian, Arabic and other .po translations (see res/values-* folders) +- Fixed incorrect try to clear iptables rules for non-root devices +- Fixed bug that stopped wizard helper from showing + 1.0.3 - Fixed spanish language issues with settings screen - Cleaned up logging, and moved most of it to debug output only diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java index ccf1ef82..9108e994 100644 --- a/src/org/torproject/android/Orbot.java +++ b/src/org/torproject/android/Orbot.java @@ -322,51 +322,47 @@ public class Orbot extends Activity implements OnClickListener, TorConstants String action = getIntent().getAction(); - if (action != null) + if (action.equals("org.torproject.android.REQUEST_HS_PORT")) { - if (action.equals("org.torproject.android.REQUEST_HS_PORT")) - { - - DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - switch (which){ - case DialogInterface.BUTTON_POSITIVE: - - int hsPort = getIntent().getIntExtra("hs_port", -1); - - enableHiddenServicePort (hsPort); - - finish(); - - - break; - - case DialogInterface.BUTTON_NEGATIVE: - //No button clicked - finish(); - break; - } - } - }; - - int hsPort = getIntent().getIntExtra("hs_port", -1); - - String requestMsg = "An app wants to open a server port (" + hsPort + ") to the Tor network. This is safe if you trust the app."; - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) - .setNegativeButton("Deny", dialogClickListener).show(); - - } - else if (action.equals("org.torproject.android.START_TOR")) - { - autoStartOnBind = true; - - if (mService == null) - bindService(); - - } + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which){ + case DialogInterface.BUTTON_POSITIVE: + + int hsPort = getIntent().getIntExtra("hs_port", -1); + + enableHiddenServicePort (hsPort); + + finish(); + + + break; + + case DialogInterface.BUTTON_NEGATIVE: + //No button clicked + finish(); + break; + } + } + }; + + int hsPort = getIntent().getIntExtra("hs_port", -1); + + String requestMsg = "An app wants to open a server port (" + hsPort + ") to the Tor network. This is safe if you trust the app."; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) + .setNegativeButton("Deny", dialogClickListener).show(); + + + } + else if (action.equals("org.torproject.android.START_TOR")) + { + autoStartOnBind = true; + + if (mService == null) + bindService(); } else @@ -390,7 +386,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants pEdit.commit(); - showHelp(); + new WizardHelper(this).showWizard(); + } } } @@ -726,9 +723,9 @@ public class Orbot extends Activity implements OnClickListener, TorConstants SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mOrbot); - boolean showWizard = prefs.getBoolean("connect_first_time",true); + boolean showFirstTime = prefs.getBoolean("connect_first_time",true); - if (showWizard) + if (showFirstTime) { Editor pEdit = prefs.edit(); diff --git a/src/org/torproject/android/SettingsPreferences.java b/src/org/torproject/android/SettingsPreferences.java index e6173fa6..277f087d 100644 --- a/src/org/torproject/android/SettingsPreferences.java +++ b/src/org/torproject/android/SettingsPreferences.java @@ -3,6 +3,7 @@ package org.torproject.android; +import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorTransProxy; import android.content.Intent; @@ -30,7 +31,7 @@ public class SettingsPreferences super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); - hasRoot = TorTransProxy.hasRootAccess(); + hasRoot = TorServiceUtils.checkRootAccess(); } diff --git a/src/org/torproject/android/WizardHelper.java b/src/org/torproject/android/WizardHelper.java index e8810abc..2f127b06 100644 --- a/src/org/torproject/android/WizardHelper.java +++ b/src/org/torproject/android/WizardHelper.java @@ -1,5 +1,6 @@ package org.torproject.android; +import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorTransProxy; import android.app.AlertDialog; @@ -84,7 +85,7 @@ public class WizardHelper implements TorConstants { public void onClick(View view) { - boolean hasRoot = TorTransProxy.hasRootAccess(); + boolean hasRoot = TorServiceUtils.checkRootAccess(); if (hasRoot) { diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 08130071..96f99cd4 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -57,6 +57,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable private String torBinaryPath = null; private String privoxyPath = null; + private boolean hasRoot = false; + /** Called when the activity is first created. */ public void onCreate() { super.onCreate(); @@ -181,6 +183,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable public void onStart(Intent intent, int startId) { super.onStart(intent, startId); + hasRoot = TorServiceUtils.checkRootAccess(); + } public void run () @@ -1090,7 +1094,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable mCallbacks.finishBroadcast(); } - private void sendCallbackLogMessage (String logMessage) + private synchronized void sendCallbackLogMessage (String logMessage) { // Broadcast to all clients the new value. @@ -1278,14 +1282,15 @@ public class TorService extends Service implements TorServiceConstants, Runnable logNotice ("Transparent Proxying: " + enableTransparentProxy); - boolean hasRoot = TorTransProxy.hasRootAccess(); if (enabled) { - if (hasRoot && enableTransparentProxy) + if (hasRoot) { + if (enableTransparentProxy) + { //TorTransProxy.setDNSProxying(); @@ -1296,11 +1301,12 @@ public class TorService extends Service implements TorServiceConstants, Runnable return true; - } - else - { - TorTransProxy.purgeIptables(this,AppManager.getApps(this)); - + } + else + { + TorTransProxy.purgeIptables(this,AppManager.getApps(this)); + + } } } else diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java index dc51c2cc..5dbc031d 100644 --- a/src/org/torproject/android/service/TorServiceConstants.java +++ b/src/org/torproject/android/service/TorServiceConstants.java @@ -6,7 +6,7 @@ public interface TorServiceConstants { public final static String TAG = "ORBOT"; - public static boolean LOG_OUTPUT_TO_DEBUG = true; + public static boolean LOG_OUTPUT_TO_DEBUG = false; public final static String TOR_APP_USERNAME = "org.torproject.android"; diff --git a/src/org/torproject/android/service/TorServiceUtils.java b/src/org/torproject/android/service/TorServiceUtils.java index 6329fd24..9d0c7c60 100644 --- a/src/org/torproject/android/service/TorServiceUtils.java +++ b/src/org/torproject/android/service/TorServiceUtils.java @@ -3,6 +3,7 @@ package org.torproject.android.service; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.StringTokenizer; @@ -11,6 +12,37 @@ import android.util.Log; public class TorServiceUtils implements TorServiceConstants { + /** + * Check if we have root access + * @return boolean true if we have root + */ + public static boolean checkRootAccess() { + + + StringBuilder log = new StringBuilder(); + + try { + + // Run an empty script just to check root access + String[] cmd = {"exit 0"}; + int exitCode = TorServiceUtils.doShellCommand(cmd, log, true, true); + if (exitCode == 0) { + + return true; + } + + } catch (IOException e) { + //this means that there is no root to be had (normally) so we won't log anything + } + catch (Exception e) { + Log.w(TAG,"Error checking for root access: " + e.getMessage()); + //this means that there is no root to be had (normally) + } + + logNotice("Could not acquire root permissions"); + return false; + } + private static void logNotice (String msg) { diff --git a/src/org/torproject/android/service/TorTransProxy.java b/src/org/torproject/android/service/TorTransProxy.java index 170feea0..883cb136 100644 --- a/src/org/torproject/android/service/TorTransProxy.java +++ b/src/org/torproject/android/service/TorTransProxy.java @@ -16,33 +16,7 @@ public class TorTransProxy implements TorServiceConstants { if (LOG_OUTPUT_TO_DEBUG) Log.d(TAG, msg); } - /** - * Check if we have root access - * @return boolean true if we have root - */ - public static boolean hasRootAccess() { - - StringBuilder log = new StringBuilder(); - - try { - - // Run an empty script just to check root access - String[] cmd = {"exit 0"}; - int exitCode = TorServiceUtils.doShellCommand(cmd, log, true, true); - if (exitCode == 0) { - - return true; - } - - } catch (Exception e) { - Log.w(TAG,"Error checking for root access: " + e.getMessage() ,e); - } - - logNotice("Could not acquire root access: " + log.toString()); - return false; - } - /** * Check if we have root access * @return boolean true if we have root @@ -190,7 +164,7 @@ public class TorTransProxy implements TorServiceConstants { public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception { - android.os.Debug.waitForDebugger(); + //android.os.Debug.waitForDebugger(); //redirectDNSResolvConf(); //not working yet