[or-cvs] r23269: {projects} fixed permission issues; added green notification icon; impr (in projects/android/trunk/Orbot: . res/drawable res/layout res/layout-land src/org/torproject/android src/org/torproject/android/service)
Nathan Freitas
nathan at freitas.net
Tue Sep 21 01:26:40 UTC 2010
Author: n8fr8
Date: 2010-09-21 01:26:40 +0000 (Tue, 21 Sep 2010)
New Revision: 23269
Added:
projects/android/trunk/Orbot/res/drawable/tornotificationgimpsrc.xcf
projects/android/trunk/Orbot/res/drawable/tornotificationon.png
Modified:
projects/android/trunk/Orbot/AndroidManifest.xml
projects/android/trunk/Orbot/AndroidManifest.xml.debug
projects/android/trunk/Orbot/AndroidManifest.xml.production
projects/android/trunk/Orbot/CHANGELOG
projects/android/trunk/Orbot/build.xml
projects/android/trunk/Orbot/res/drawable/tornotification.png
projects/android/trunk/Orbot/res/drawable/tornotificationoff.png
projects/android/trunk/Orbot/res/layout-land/layout_main.xml
projects/android/trunk/Orbot/res/layout/layout_apps.xml
projects/android/trunk/Orbot/res/layout/layout_apps_item.xml
projects/android/trunk/Orbot/res/layout/layout_main.xml
projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java
projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java
Log:
fixed permission issues; added green notification icon; improved root/su checking logic
Modified: projects/android/trunk/Orbot/AndroidManifest.xml
===================================================================
--- projects/android/trunk/Orbot/AndroidManifest.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/AndroidManifest.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.torproject.android" android:versionName="1.0.4" android:versionCode="10">
+ package="org.torproject.android" android:versionName="0.2.2.14-orbot-alpha-1.0.3" android:versionCode="9">
<uses-permission android:name="android.permission.INTERNET" />
- <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".Orbot"
android:theme="@android:style/Theme.NoTitleBar">
@@ -44,7 +44,7 @@
</application>
- <uses-sdk android:minSdkVersion="3"/>
+ <uses-sdk android:minSdkVersion="4"/>
Modified: projects/android/trunk/Orbot/AndroidManifest.xml.debug
===================================================================
--- projects/android/trunk/Orbot/AndroidManifest.xml.debug 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/AndroidManifest.xml.debug 2010-09-21 01:26:40 UTC (rev 23269)
@@ -41,6 +41,7 @@
</intent-filter>
</service>
+ <!--
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action
@@ -48,11 +49,11 @@
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
+ -->
-
</application>
- <uses-sdk android:minSdkVersion="3"/>
+ <uses-sdk android:minSdkVersion="4"/>
Modified: projects/android/trunk/Orbot/AndroidManifest.xml.production
===================================================================
--- projects/android/trunk/Orbot/AndroidManifest.xml.production 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/AndroidManifest.xml.production 2010-09-21 01:26:40 UTC (rev 23269)
@@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".Orbot"
android:theme="@android:style/Theme.NoTitleBar">
@@ -44,7 +44,7 @@
</application>
- <uses-sdk android:minSdkVersion="3"/>
+ <uses-sdk android:minSdkVersion="4"/>
Modified: projects/android/trunk/Orbot/CHANGELOG
===================================================================
--- projects/android/trunk/Orbot/CHANGELOG 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/CHANGELOG 2010-09-21 01:26:40 UTC (rev 23269)
@@ -3,7 +3,10 @@
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
+- Fixed bug that stopped wizard helper from showing first time
+- Added new green notification icon when Tor is connected
+- Fixed app selector layout in settings
+- Moved minSDK to 4 (Android 1.6); discontinued 1.5 support
1.0.3
- Fixed spanish language issues with settings screen
Modified: projects/android/trunk/Orbot/build.xml
===================================================================
--- projects/android/trunk/Orbot/build.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/build.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="Orbot" default="help">
+<project name="Orbot">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked in in Version
Modified: projects/android/trunk/Orbot/res/drawable/tornotification.png
===================================================================
(Binary files differ)
Added: projects/android/trunk/Orbot/res/drawable/tornotificationgimpsrc.xcf
===================================================================
(Binary files differ)
Property changes on: projects/android/trunk/Orbot/res/drawable/tornotificationgimpsrc.xcf
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: projects/android/trunk/Orbot/res/drawable/tornotificationoff.png
===================================================================
(Binary files differ)
Added: projects/android/trunk/Orbot/res/drawable/tornotificationon.png
===================================================================
(Binary files differ)
Property changes on: projects/android/trunk/Orbot/res/drawable/tornotificationon.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: projects/android/trunk/Orbot/res/layout/layout_apps.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout/layout_apps.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/res/layout/layout_apps.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:duplicateParentState="false">
-<TextView android:text="Select apps for Tor:"
+<TextView android:text="Select apps to use with Tor:"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:padding="3px" />
- <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/applistview"></ListView>
+ <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/applistview"></ListView>
</LinearLayout>
Modified: projects/android/trunk/Orbot/res/layout/layout_apps_item.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout/layout_apps_item.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/res/layout/layout_apps_item.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -1,18 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
+
+<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- >
-
-
+ android:stretchColumns="1">
+ <TableRow>
+ <ImageView android:id="@+id/itemicon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip"></ImageView>
-<ImageView android:id="@+id/itemicon" android:layout_width="48px" android:layout_height="48px"></ImageView>
+<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>
-<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages"
-android:layout_width="220px" android:textSize="18sp"></TextView>
+<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox>
+
+ </TableRow>
+</TableLayout>
-<CheckBox android:layout_width="48px" android:layout_height="48px" android:id="@+id/itemcheck"></CheckBox>
-
-
-</LinearLayout>
Modified: projects/android/trunk/Orbot/res/layout/layout_main.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout/layout_main.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/res/layout/layout_main.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -58,8 +58,8 @@
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textStyle="bold"
- android:width="240px"
- android:height="50px"
+ android:width="320px"
+ android:height="100px"
android:textColor="#ffffff"
/>
</TableRow>
Modified: projects/android/trunk/Orbot/res/layout-land/layout_main.xml
===================================================================
--- projects/android/trunk/Orbot/res/layout-land/layout_main.xml 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/res/layout-land/layout_main.xml 2010-09-21 01:26:40 UTC (rev 23269)
@@ -49,7 +49,7 @@
<ImageView
android:id="@+id/imgStatus"
android:layout_width="wrap_content"
- android:layout_height="175px"
+ android:layout_height="225px"
android:src="@drawable/toroff"/>
</TableRow>
<TableRow>
@@ -58,8 +58,8 @@
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textStyle="bold"
- android:width="240px"
- android:height="50px"
+ android:width="320px"
+ android:height="100px"
android:textColor="#ffffff"
/>
</TableRow>
Modified: projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java 2010-09-21 01:26:40 UTC (rev 23269)
@@ -12,12 +12,10 @@
import org.torproject.android.service.ITorService;
import org.torproject.android.service.ITorServiceCallback;
import org.torproject.android.service.TorServiceConstants;
-import org.torproject.android.service.TorTransProxy;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.NotificationManager;
-import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -34,18 +32,11 @@
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
@@ -720,9 +711,9 @@
if (torStatus == STATUS_ON)
{
imgStatus.setImageResource(R.drawable.toron);
- imgStatus.clearAnimation();
+ // imgStatus.clearAnimation();
- String lblMsg = getString(R.string.status_activated) + ": " + torServiceMsg;
+ String lblMsg = getString(R.string.status_activated) + "\n" + torServiceMsg;
lblStatus.setText(lblMsg);
@@ -769,7 +760,7 @@
lblStatus.setText(torServiceMsg);
-
+ /*
int idx = torServiceMsg.indexOf("%");
if (idx != -1)
@@ -778,13 +769,13 @@
int ipComp = Integer.parseInt(pComp);
// progressDialog.setProgress(ipComp);
- }
+ }*/
}
else if (torStatus == STATUS_OFF)
{
imgStatus.setImageResource(R.drawable.torstopping);
- imgStatus.clearAnimation();
+ // imgStatus.clearAnimation();
lblStatus.setText(getString(R.string.status_shutting_down));
@@ -793,10 +784,10 @@
{
- imgStatus.clearAnimation();
+ // imgStatus.clearAnimation();
imgStatus.setImageResource(R.drawable.toroff);
- lblStatus.setText(getString(R.string.status_disabled));
+ lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
@@ -827,12 +818,14 @@
private void stopTor () throws RemoteException
{
- mService.setProfile(PROFILE_ONDEMAND); //these means turn off
+ if (mService != null)
+ {
+ mService.setProfile(PROFILE_ONDEMAND); //these means turn off
- Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
- mHandler.sendMessage(msg);
+ Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
+ mHandler.sendMessage(msg);
+ }
-
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/src/org/torproject/android/SettingsPreferences.java 2010-09-21 01:26:40 UTC (rev 23269)
@@ -7,9 +7,12 @@
import org.torproject.android.service.TorTransProxy;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
+import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
@@ -23,7 +26,6 @@
private Preference prefTransProxyApps = null;
private CheckBoxPreference prefHiddenServices = null;
-
private boolean hasRoot = false;
protected void onCreate(Bundle savedInstanceState)
@@ -31,8 +33,19 @@
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
- hasRoot = TorServiceUtils.checkRootAccess();
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ if (prefs.contains("has_root"))
+ {
+ hasRoot = prefs.getBoolean("has_root",false);//TorServiceUtils.checkRootAccess();
+ }
+ else
+ {
+ hasRoot = TorServiceUtils.checkRootAccess();
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("has_root",hasRoot);
+ pEdit.commit();
+ }
}
Modified: projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/src/org/torproject/android/WizardHelper.java 2010-09-21 01:26:40 UTC (rev 23269)
@@ -87,6 +87,12 @@
boolean hasRoot = TorServiceUtils.checkRootAccess();
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("has_root",hasRoot);
+ pEdit.commit();
+
if (hasRoot)
{
currentDialog.dismiss();
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorService.java 2010-09-21 01:26:40 UTC (rev 23269)
@@ -29,6 +29,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -42,6 +43,7 @@
private static int currentStatus = STATUS_READY;
private TorControlConnection conn = null;
+ private Socket torConnSocket = null;
private static TorService _torInstance;
@@ -51,12 +53,12 @@
private ArrayList<String> configBuffer = null;
- private boolean isBound = false;
+
+ private String appHome = "/data/data/" + TOR_APP_USERNAME + "/";;
+ private String torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
+ private String privoxyPath = appHome + PRIVOXY_ASSET_KEY;
- private String appHome = null;
- private String torBinaryPath = null;
- private String privoxyPath = null;
-
+
private boolean hasRoot = false;
/** Called when the activity is first created. */
@@ -83,7 +85,6 @@
initControlConnection();
-
currentStatus = STATUS_ON;
return true;
@@ -124,8 +125,8 @@
// logNotice( "onUnbind Called: " + intent.getAction());
- isBound = false;
+
return super.onUnbind(intent);
@@ -172,7 +173,6 @@
public void onRebind(Intent intent) {
super.onRebind(intent);
- isBound = true;
}
@@ -182,9 +182,13 @@
*/
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
+
+ try {
+ checkTorBinaries ();
+ } catch (Exception e) {
- hasRoot = TorServiceUtils.checkRootAccess();
-
+ Log.e(TAG, "error checking tor binaries", e);
+ }
}
public void run ()
@@ -272,21 +276,33 @@
private void killTorProcess () throws Exception
{
+ //android.os.Debug.waitForDebugger();
+ StringBuilder log = new StringBuilder();
+ int procId = -1;
+
if (conn != null)
{
+ logNotice("Using control port to shutdown Tor");
+
try {
logNotice("sending SHUTDOWN signal to Tor process");
conn.signal("SHUTDOWN");
+ //torConnSocket.close();
+
} catch (Exception e) {
Log.d(TAG,"error shutting down Tor via connection",e);
}
+
conn = null;
}
- StringBuilder log = new StringBuilder();
+ try //wait a second for this
+ { Thread.sleep(1000); }
+ catch (Exception e) {}
- int procId = TorServiceUtils.findProcessId(torBinaryPath);
+ logNotice("Checking for existing Tor process via path: " + torBinaryPath);
+ procId = TorServiceUtils.findProcessId(torBinaryPath);
while (procId != -1)
{
@@ -298,7 +314,9 @@
procId = TorServiceUtils.findProcessId(torBinaryPath);
}
+
+ logNotice("Checking for existing Privoxy process via path: " + privoxyPath);
procId = TorServiceUtils.findProcessId(privoxyPath);
while (procId != -1)
@@ -383,15 +401,17 @@
{
- logNotice( "checking Tor binaries");
+ appHome = "/data/data/" + TOR_APP_USERNAME + "/";
+ //appHome = getApplicationContext().getFilesDir().getAbsolutePath();
- //appHome = getApplicationContext().getFilesDir().getAbsolutePath();
- appHome = "/data/data/" + TOR_APP_USERNAME + "/";
+ logNotice( "appHome=" + appHome);
+ torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
+ privoxyPath = appHome + PRIVOXY_ASSET_KEY;
- logNotice( "appHome=" + appHome);
-
+ logNotice( "checking Tor binaries");
+
String apkPath = findAPK();
-
+
logNotice( "found apk at: " + apkPath);
boolean apkExists = new File(apkPath).exists();
@@ -400,11 +420,11 @@
{
Log.w(TAG,"APK file not found at: " + apkPath);
Log.w(TAG,"Binary installation aborted");
+ logNotice(getString(R.string.status_install_fail));
+ sendCallbackStatusMessage(getString(R.string.status_install_fail));
return false;
}
- torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
- privoxyPath = appHome + PRIVOXY_ASSET_KEY;
boolean torBinaryExists = new File(torBinaryPath).exists();
boolean privoxyBinaryExists = new File(privoxyPath).exists();
@@ -440,12 +460,10 @@
else
{
logNotice("Found Tor binary: " + torBinaryPath);
-
logNotice("Found Privoxy binary: " + privoxyPath);
-
}
-
+
StringBuilder log = new StringBuilder ();
logNotice("(re)Setting permission on Tor binary");
@@ -455,8 +473,8 @@
logNotice("(re)Setting permission on Privoxy binary");
String[] cmd2 = {SHELL_CMD_CHMOD + ' ' + CHMOD_EXE_VALUE + ' ' + privoxyPath};
TorServiceUtils.doShellCommand(cmd2, log, false, true);
-
+
return true;
}
@@ -472,35 +490,19 @@
killTorProcess ();
- checkTorBinaries ();
-
-
new Thread()
{
public void run ()
{
try {
- runPrivoxyShellCmd();
-
- } catch (Exception e) {
- currentStatus = STATUS_OFF;
- Log.d(TAG,"Unable to start Privoxy: " + e.getMessage(),e);
- sendCallbackLogMessage("Unable to start Privoxy: " + e.getMessage());
-
- }
- }
- }.start();
-
- new Thread()
- {
- public void run ()
- {
- try {
runTorShellCmd();
setupTransProxy(true);
+
+ runPrivoxyShellCmd();
+
} catch (Exception e) {
Log.d(TAG,"Unable to start Tor: " + e.getMessage(),e);
sendCallbackStatusMessage("Unable to start Tor: " + e.getMessage());
@@ -518,34 +520,38 @@
StringBuilder log = new StringBuilder();
-
String torrcPath = appHome + TORRC_ASSET_KEY;
String[] torCmd = {torBinaryPath + " -f " + torrcPath + " || exit\n"};
- TorServiceUtils.doShellCommand(torCmd, log, false, false);
-
- logNotice( "Starting tor process: " + torCmd[0]);
- Thread.sleep(1000);
- int procId = TorServiceUtils.findProcessId(torBinaryPath);
+ boolean runAsRootFalse = false;
+ boolean waitForProcess = false;
+
+ int procId = -1;
+ int attempts = 0;
- int attempts = 0;
+ int torRetryWaitTimeMS = 5000;
while (procId == -1 && attempts < MAX_START_TRIES)
{
log = new StringBuilder();
logNotice(torCmd[0]);
+ sendCallbackStatusMessage(getString(R.string.status_starting_up));
- TorServiceUtils.doShellCommand(torCmd, log, false, false);
+ TorServiceUtils.doShellCommand(torCmd, log, runAsRootFalse, waitForProcess);
+
+ Thread.sleep(torRetryWaitTimeMS);
+
procId = TorServiceUtils.findProcessId(torBinaryPath);
+ logNotice("got tor proc id: " + procId);
+
if (procId == -1)
{
- sendCallbackStatusMessage("Couldn't start Tor process...\n" + log.toString());
- Thread.sleep(1000);
- sendCallbackStatusMessage(getString(R.string.status_starting_up));
- Thread.sleep(3000);
+
+ sendCallbackStatusMessage("Couldn't start Tor process.\nretrying..." + log.toString());
+ Thread.sleep(torRetryWaitTimeMS);
attempts++;
}
@@ -637,8 +643,8 @@
String baseMessage = getString(R.string.tor_process_connecting);
sendCallbackStatusMessage(baseMessage);
- Socket s = new Socket(IP_LOCALHOST, TOR_CONTROL_PORT);
- conn = TorControlConnection.getConnection(s);
+ torConnSocket = new Socket(IP_LOCALHOST, TOR_CONTROL_PORT);
+ conn = TorControlConnection.getConnection(torConnSocket);
// conn.authenticate(new byte[0]); // See section 3.2
sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2));
@@ -790,7 +796,7 @@
if (msg.indexOf(TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)!=-1)
{
currentStatus = STATUS_ON;
- showToolbarNotification (getString(R.string.status_activated),R.drawable.tornotification);
+ showToolbarNotification (getString(R.string.status_activated),R.drawable.tornotificationon);
}
@@ -893,23 +899,22 @@
// a single interface, you can just return it here without checking
// the Intent.
- if (appHome == null)
- {
- try
- {
- checkTorBinaries();
-
- findExistingProc ();
-
- _torInstance = this;
- }
- catch (Exception e)
- {
- Log.d(TAG,"Unable to check for Tor binaries",e);
- return null;
- }
- }
+ try
+ {
+
+ checkTorBinaries();
+
+ findExistingProc ();
+
+ _torInstance = this;
+ }
+ catch (Exception e)
+ {
+ Log.d(TAG,"Unable to check for Tor binaries",e);
+ return null;
+ }
+
if (ITorService.class.getName().equals(intent.getAction())) {
return mBinder;
}
@@ -1058,7 +1063,6 @@
private void sendCallbackStatusMessage (String newStatus)
{
- sendCallbackLogMessage (newStatus); //we want everything to go to the log!
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
@@ -1277,6 +1281,18 @@
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
+ if (prefs.contains("has_root"))
+ {
+ hasRoot = prefs.getBoolean("has_root",false);//TorServiceUtils.checkRootAccess();
+ }
+ else
+ {
+ hasRoot = TorServiceUtils.checkRootAccess();
+ Editor pEdit = prefs.edit();
+ pEdit.putBoolean("has_root",hasRoot);
+ pEdit.commit();
+ }
+
boolean enableTransparentProxy = prefs.getBoolean("pref_transparent", false);
boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
@@ -1309,12 +1325,9 @@
}
}
}
- else
+ else if (hasRoot)
{
- if (hasRoot)
- {
- TorTransProxy.purgeIptables(this,AppManager.getApps(this));
- }
+ TorTransProxy.purgeIptables(this,AppManager.getApps(this));
}
return true;
Modified: projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java 2010-09-20 20:17:44 UTC (rev 23268)
+++ projects/android/trunk/Orbot/src/org/torproject/android/service/TorTransProxy.java 2010-09-21 01:26:40 UTC (rev 23269)
@@ -95,32 +95,34 @@
StringBuilder res = new StringBuilder();
int code = -1;
- for (int i = 0; i < apps.length; i++)
- {
+ for (int i = 0; i < apps.length; i++)
+ {
- //flush nat for every app
- script.append(baseDir);
- script.append("iptables -t nat -m owner --uid-owner ");
- script.append(apps[i].getUid());
- script.append(" -F || exit\n");
- script.append("iptables -t filter -m owner --uid-owner ");
- script.append(apps[i].getUid());
- script.append(" -F || exit\n");
-
- }
+ //flush nat for every app
+ script.append(baseDir);
+ script.append("iptables -t nat -m owner --uid-owner ");
+ script.append(apps[i].getUid());
+ script.append(" -F || exit\n");
+ script.append("iptables -t filter -m owner --uid-owner ");
+ script.append(apps[i].getUid());
+ script.append(" -F || exit\n");
+
+ }
+
+
+ String[] cmd = {script.toString()};
+ code = TorServiceUtils.doShellCommand(cmd, res, true, true);
+ String msg = res.toString();
+ logNotice(cmd[0] + ";errCode=" + code + ";resp=" + msg);
-
- String[] cmd = {script.toString()};
- code = TorServiceUtils.doShellCommand(cmd, res, true, true);
- String msg = res.toString();
- logNotice(cmd[0] + ";errCode=" + code + ";resp=" + msg);
-
return code;
}
-
+ /*
+ // 9/19/2010 - NF This code is in process... /etc path on System partition
+ // is read-only on Android for now.
public static int redirectDNSResolvConf () throws Exception
{
StringBuilder script = new StringBuilder();
@@ -160,6 +162,7 @@
return code;
}
+ */
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
{
More information about the tor-commits
mailing list