fixed permission issues; added green notification icon; improved root/su checking logic
svn:r23269
This commit is contained in:
parent
573ade18f5
commit
81f31ffde6
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<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" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3"/>
|
<uses-sdk android:minSdkVersion="4"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<!--
|
||||||
<receiver android:name=".OnBootReceiver">
|
<receiver android:name=".OnBootReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action
|
<action
|
||||||
|
@ -48,11 +49,11 @@
|
||||||
<category android:name="android.intent.category.HOME" />
|
<category android:name="android.intent.category.HOME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
-->
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3"/>
|
<uses-sdk android:minSdkVersion="4"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<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"
|
<activity android:name=".Orbot"
|
||||||
android:theme="@android:style/Theme.NoTitleBar">
|
android:theme="@android:style/Theme.NoTitleBar">
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3"/>
|
<uses-sdk android:minSdkVersion="4"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,10 @@ NOTE: Specific #s below correspond to Trac tickets logged and maintained at http
|
||||||
1.0.4
|
1.0.4
|
||||||
- Added Russian, Persian, Arabic and other .po translations (see res/values-* folders)
|
- Added Russian, Persian, Arabic and other .po translations (see res/values-* folders)
|
||||||
- Fixed incorrect try to clear iptables rules for non-root devices
|
- 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
|
1.0.3
|
||||||
- Fixed spanish language issues with settings screen
|
- Fixed spanish language issues with settings screen
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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.
|
<!-- 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
|
It contains the path to the SDK. It should *NOT* be checked in in Version
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 828 B |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 828 B |
Binary file not shown.
After Width: | Height: | Size: 875 B |
|
@ -49,7 +49,7 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imgStatus"
|
android:id="@+id/imgStatus"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="175px"
|
android:layout_height="225px"
|
||||||
android:src="@drawable/toroff"/>
|
android:src="@drawable/toroff"/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:width="240px"
|
android:width="320px"
|
||||||
android:height="50px"
|
android:height="100px"
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
/>
|
/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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">
|
<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_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:padding="3px" />
|
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>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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_width="fill_parent"
|
||||||
android:layout_height="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>
|
||||||
|
|
||||||
|
<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>
|
||||||
|
|
||||||
|
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox>
|
||||||
|
|
||||||
<ImageView android:id="@+id/itemicon" android:layout_width="48px" android:layout_height="48px"></ImageView>
|
</TableRow>
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
<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="48px" android:layout_height="48px" android:id="@+id/itemcheck"></CheckBox>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
|
@ -58,8 +58,8 @@
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:width="240px"
|
android:width="320px"
|
||||||
android:height="50px"
|
android:height="100px"
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
/>
|
/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
@ -12,12 +12,10 @@ import java.util.StringTokenizer;
|
||||||
import org.torproject.android.service.ITorService;
|
import org.torproject.android.service.ITorService;
|
||||||
import org.torproject.android.service.ITorServiceCallback;
|
import org.torproject.android.service.ITorServiceCallback;
|
||||||
import org.torproject.android.service.TorServiceConstants;
|
import org.torproject.android.service.TorServiceConstants;
|
||||||
import org.torproject.android.service.TorTransProxy;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -34,18 +32,11 @@ import android.os.RemoteException;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
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.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -720,9 +711,9 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
|
||||||
if (torStatus == STATUS_ON)
|
if (torStatus == STATUS_ON)
|
||||||
{
|
{
|
||||||
imgStatus.setImageResource(R.drawable.toron);
|
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);
|
lblStatus.setText(lblMsg);
|
||||||
|
|
||||||
|
@ -769,7 +760,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
|
||||||
|
|
||||||
lblStatus.setText(torServiceMsg);
|
lblStatus.setText(torServiceMsg);
|
||||||
|
|
||||||
|
/*
|
||||||
int idx = torServiceMsg.indexOf("%");
|
int idx = torServiceMsg.indexOf("%");
|
||||||
|
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
|
@ -778,13 +769,13 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
|
||||||
int ipComp = Integer.parseInt(pComp);
|
int ipComp = Integer.parseInt(pComp);
|
||||||
// progressDialog.setProgress(ipComp);
|
// progressDialog.setProgress(ipComp);
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (torStatus == STATUS_OFF)
|
else if (torStatus == STATUS_OFF)
|
||||||
{
|
{
|
||||||
imgStatus.setImageResource(R.drawable.torstopping);
|
imgStatus.setImageResource(R.drawable.torstopping);
|
||||||
imgStatus.clearAnimation();
|
// imgStatus.clearAnimation();
|
||||||
|
|
||||||
lblStatus.setText(getString(R.string.status_shutting_down));
|
lblStatus.setText(getString(R.string.status_shutting_down));
|
||||||
|
|
||||||
|
@ -793,10 +784,10 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
imgStatus.clearAnimation();
|
// imgStatus.clearAnimation();
|
||||||
|
|
||||||
imgStatus.setImageResource(R.drawable.toroff);
|
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));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -826,12 +817,14 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopTor () throws RemoteException
|
private void stopTor () throws RemoteException
|
||||||
|
{
|
||||||
|
if (mService != null)
|
||||||
{
|
{
|
||||||
mService.setProfile(PROFILE_ONDEMAND); //these means turn off
|
mService.setProfile(PROFILE_ONDEMAND); //these means turn off
|
||||||
|
|
||||||
Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
|
Message msg = mHandler.obtainMessage(DISABLE_TOR_MSG);
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,12 @@ import org.torproject.android.service.TorServiceUtils;
|
||||||
import org.torproject.android.service.TorTransProxy;
|
import org.torproject.android.service.TorTransProxy;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
|
@ -23,7 +26,6 @@ public class SettingsPreferences
|
||||||
private Preference prefTransProxyApps = null;
|
private Preference prefTransProxyApps = null;
|
||||||
private CheckBoxPreference prefHiddenServices = null;
|
private CheckBoxPreference prefHiddenServices = null;
|
||||||
|
|
||||||
|
|
||||||
private boolean hasRoot = false;
|
private boolean hasRoot = false;
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
@ -31,8 +33,19 @@ public class SettingsPreferences
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,12 @@ public class WizardHelper implements TorConstants {
|
||||||
|
|
||||||
boolean hasRoot = TorServiceUtils.checkRootAccess();
|
boolean hasRoot = TorServiceUtils.checkRootAccess();
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
Editor pEdit = prefs.edit();
|
||||||
|
pEdit.putBoolean("has_root",hasRoot);
|
||||||
|
pEdit.commit();
|
||||||
|
|
||||||
if (hasRoot)
|
if (hasRoot)
|
||||||
{
|
{
|
||||||
currentDialog.dismiss();
|
currentDialog.dismiss();
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
@ -42,6 +43,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
private static int currentStatus = STATUS_READY;
|
private static int currentStatus = STATUS_READY;
|
||||||
|
|
||||||
private TorControlConnection conn = null;
|
private TorControlConnection conn = null;
|
||||||
|
private Socket torConnSocket = null;
|
||||||
|
|
||||||
private static TorService _torInstance;
|
private static TorService _torInstance;
|
||||||
|
|
||||||
|
@ -51,11 +53,11 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
private ArrayList<String> configBuffer = null;
|
private ArrayList<String> configBuffer = null;
|
||||||
|
|
||||||
private boolean isBound = false;
|
|
||||||
|
|
||||||
private String appHome = null;
|
private String appHome = "/data/data/" + TOR_APP_USERNAME + "/";;
|
||||||
private String torBinaryPath = null;
|
private String torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
|
||||||
private String privoxyPath = null;
|
private String privoxyPath = appHome + PRIVOXY_ASSET_KEY;
|
||||||
|
|
||||||
|
|
||||||
private boolean hasRoot = false;
|
private boolean hasRoot = false;
|
||||||
|
|
||||||
|
@ -83,7 +85,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
initControlConnection();
|
initControlConnection();
|
||||||
|
|
||||||
|
|
||||||
currentStatus = STATUS_ON;
|
currentStatus = STATUS_ON;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -124,7 +125,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
// logNotice( "onUnbind Called: " + intent.getAction());
|
// logNotice( "onUnbind Called: " + intent.getAction());
|
||||||
|
|
||||||
isBound = false;
|
|
||||||
|
|
||||||
return super.onUnbind(intent);
|
return super.onUnbind(intent);
|
||||||
|
|
||||||
|
@ -172,7 +173,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
public void onRebind(Intent intent) {
|
public void onRebind(Intent intent) {
|
||||||
super.onRebind(intent);
|
super.onRebind(intent);
|
||||||
|
|
||||||
isBound = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +183,12 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
public void onStart(Intent intent, int startId) {
|
public void onStart(Intent intent, int startId) {
|
||||||
super.onStart(intent, startId);
|
super.onStart(intent, startId);
|
||||||
|
|
||||||
hasRoot = TorServiceUtils.checkRootAccess();
|
try {
|
||||||
|
checkTorBinaries ();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
Log.e(TAG, "error checking tor binaries", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run ()
|
public void run ()
|
||||||
|
@ -272,21 +276,33 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
private void killTorProcess () throws Exception
|
private void killTorProcess () throws Exception
|
||||||
{
|
{
|
||||||
|
//android.os.Debug.waitForDebugger();
|
||||||
|
|
||||||
|
StringBuilder log = new StringBuilder();
|
||||||
|
int procId = -1;
|
||||||
|
|
||||||
if (conn != null)
|
if (conn != null)
|
||||||
{
|
{
|
||||||
|
logNotice("Using control port to shutdown Tor");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logNotice("sending SHUTDOWN signal to Tor process");
|
logNotice("sending SHUTDOWN signal to Tor process");
|
||||||
conn.signal("SHUTDOWN");
|
conn.signal("SHUTDOWN");
|
||||||
|
//torConnSocket.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG,"error shutting down Tor via connection",e);
|
Log.d(TAG,"error shutting down Tor via connection",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = null;
|
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)
|
while (procId != -1)
|
||||||
{
|
{
|
||||||
|
@ -299,6 +315,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
procId = TorServiceUtils.findProcessId(torBinaryPath);
|
procId = TorServiceUtils.findProcessId(torBinaryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
logNotice("Checking for existing Privoxy process via path: " + privoxyPath);
|
||||||
procId = TorServiceUtils.findProcessId(privoxyPath);
|
procId = TorServiceUtils.findProcessId(privoxyPath);
|
||||||
|
|
||||||
while (procId != -1)
|
while (procId != -1)
|
||||||
|
@ -383,12 +401,14 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
logNotice( "checking Tor binaries");
|
|
||||||
|
|
||||||
//appHome = getApplicationContext().getFilesDir().getAbsolutePath();
|
|
||||||
appHome = "/data/data/" + TOR_APP_USERNAME + "/";
|
appHome = "/data/data/" + TOR_APP_USERNAME + "/";
|
||||||
|
//appHome = getApplicationContext().getFilesDir().getAbsolutePath();
|
||||||
|
|
||||||
logNotice( "appHome=" + appHome);
|
logNotice( "appHome=" + appHome);
|
||||||
|
torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
|
||||||
|
privoxyPath = appHome + PRIVOXY_ASSET_KEY;
|
||||||
|
|
||||||
|
logNotice( "checking Tor binaries");
|
||||||
|
|
||||||
String apkPath = findAPK();
|
String apkPath = findAPK();
|
||||||
|
|
||||||
|
@ -400,11 +420,11 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
{
|
{
|
||||||
Log.w(TAG,"APK file not found at: " + apkPath);
|
Log.w(TAG,"APK file not found at: " + apkPath);
|
||||||
Log.w(TAG,"Binary installation aborted");
|
Log.w(TAG,"Binary installation aborted");
|
||||||
|
logNotice(getString(R.string.status_install_fail));
|
||||||
|
sendCallbackStatusMessage(getString(R.string.status_install_fail));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
torBinaryPath = appHome + TOR_BINARY_ASSET_KEY;
|
|
||||||
privoxyPath = appHome + PRIVOXY_ASSET_KEY;
|
|
||||||
|
|
||||||
boolean torBinaryExists = new File(torBinaryPath).exists();
|
boolean torBinaryExists = new File(torBinaryPath).exists();
|
||||||
boolean privoxyBinaryExists = new File(privoxyPath).exists();
|
boolean privoxyBinaryExists = new File(privoxyPath).exists();
|
||||||
|
@ -440,10 +460,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logNotice("Found Tor binary: " + torBinaryPath);
|
logNotice("Found Tor binary: " + torBinaryPath);
|
||||||
|
|
||||||
logNotice("Found Privoxy binary: " + privoxyPath);
|
logNotice("Found Privoxy binary: " + privoxyPath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder ();
|
StringBuilder log = new StringBuilder ();
|
||||||
|
@ -472,25 +490,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
killTorProcess ();
|
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()
|
new Thread()
|
||||||
{
|
{
|
||||||
|
@ -501,6 +500,9 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
setupTransProxy(true);
|
setupTransProxy(true);
|
||||||
|
|
||||||
|
runPrivoxyShellCmd();
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG,"Unable to start Tor: " + e.getMessage(),e);
|
Log.d(TAG,"Unable to start Tor: " + e.getMessage(),e);
|
||||||
sendCallbackStatusMessage("Unable to start Tor: " + e.getMessage());
|
sendCallbackStatusMessage("Unable to start Tor: " + e.getMessage());
|
||||||
|
@ -518,34 +520,38 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
String torrcPath = appHome + TORRC_ASSET_KEY;
|
String torrcPath = appHome + TORRC_ASSET_KEY;
|
||||||
|
|
||||||
String[] torCmd = {torBinaryPath + " -f " + torrcPath + " || exit\n"};
|
String[] torCmd = {torBinaryPath + " -f " + torrcPath + " || exit\n"};
|
||||||
TorServiceUtils.doShellCommand(torCmd, log, false, false);
|
|
||||||
|
|
||||||
logNotice( "Starting tor process: " + torCmd[0]);
|
boolean runAsRootFalse = false;
|
||||||
|
boolean waitForProcess = false;
|
||||||
Thread.sleep(1000);
|
|
||||||
int procId = TorServiceUtils.findProcessId(torBinaryPath);
|
|
||||||
|
|
||||||
|
int procId = -1;
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
|
|
||||||
|
int torRetryWaitTimeMS = 5000;
|
||||||
|
|
||||||
while (procId == -1 && attempts < MAX_START_TRIES)
|
while (procId == -1 && attempts < MAX_START_TRIES)
|
||||||
{
|
{
|
||||||
log = new StringBuilder();
|
log = new StringBuilder();
|
||||||
|
|
||||||
logNotice(torCmd[0]);
|
logNotice(torCmd[0]);
|
||||||
|
sendCallbackStatusMessage(getString(R.string.status_starting_up));
|
||||||
|
|
||||||
|
TorServiceUtils.doShellCommand(torCmd, log, runAsRootFalse, waitForProcess);
|
||||||
|
|
||||||
|
Thread.sleep(torRetryWaitTimeMS);
|
||||||
|
|
||||||
TorServiceUtils.doShellCommand(torCmd, log, false, false);
|
|
||||||
procId = TorServiceUtils.findProcessId(torBinaryPath);
|
procId = TorServiceUtils.findProcessId(torBinaryPath);
|
||||||
|
|
||||||
|
logNotice("got tor proc id: " + procId);
|
||||||
|
|
||||||
if (procId == -1)
|
if (procId == -1)
|
||||||
{
|
{
|
||||||
sendCallbackStatusMessage("Couldn't start Tor process...\n" + log.toString());
|
|
||||||
Thread.sleep(1000);
|
sendCallbackStatusMessage("Couldn't start Tor process.\nretrying..." + log.toString());
|
||||||
sendCallbackStatusMessage(getString(R.string.status_starting_up));
|
Thread.sleep(torRetryWaitTimeMS);
|
||||||
Thread.sleep(3000);
|
|
||||||
attempts++;
|
attempts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,8 +643,8 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
String baseMessage = getString(R.string.tor_process_connecting);
|
String baseMessage = getString(R.string.tor_process_connecting);
|
||||||
sendCallbackStatusMessage(baseMessage);
|
sendCallbackStatusMessage(baseMessage);
|
||||||
|
|
||||||
Socket s = new Socket(IP_LOCALHOST, TOR_CONTROL_PORT);
|
torConnSocket = new Socket(IP_LOCALHOST, TOR_CONTROL_PORT);
|
||||||
conn = TorControlConnection.getConnection(s);
|
conn = TorControlConnection.getConnection(torConnSocket);
|
||||||
// conn.authenticate(new byte[0]); // See section 3.2
|
// conn.authenticate(new byte[0]); // See section 3.2
|
||||||
|
|
||||||
sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2));
|
sendCallbackStatusMessage(getString(R.string.tor_process_connecting_step2));
|
||||||
|
@ -790,7 +796,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
if (msg.indexOf(TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)!=-1)
|
if (msg.indexOf(TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE)!=-1)
|
||||||
{
|
{
|
||||||
currentStatus = STATUS_ON;
|
currentStatus = STATUS_ON;
|
||||||
showToolbarNotification (getString(R.string.status_activated),R.drawable.tornotification);
|
showToolbarNotification (getString(R.string.status_activated),R.drawable.tornotificationon);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,10 +899,10 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
// a single interface, you can just return it here without checking
|
// a single interface, you can just return it here without checking
|
||||||
// the Intent.
|
// the Intent.
|
||||||
|
|
||||||
if (appHome == null)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
checkTorBinaries();
|
checkTorBinaries();
|
||||||
|
|
||||||
findExistingProc ();
|
findExistingProc ();
|
||||||
|
@ -908,7 +914,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
Log.d(TAG,"Unable to check for Tor binaries",e);
|
Log.d(TAG,"Unable to check for Tor binaries",e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ITorService.class.getName().equals(intent.getAction())) {
|
if (ITorService.class.getName().equals(intent.getAction())) {
|
||||||
return mBinder;
|
return mBinder;
|
||||||
|
@ -1058,7 +1063,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
private void sendCallbackStatusMessage (String newStatus)
|
private void sendCallbackStatusMessage (String newStatus)
|
||||||
{
|
{
|
||||||
sendCallbackLogMessage (newStatus); //we want everything to go to the log!
|
|
||||||
|
|
||||||
// Broadcast to all clients the new value.
|
// Broadcast to all clients the new value.
|
||||||
final int N = mCallbacks.beginBroadcast();
|
final int N = mCallbacks.beginBroadcast();
|
||||||
|
@ -1277,6 +1281,18 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
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 enableTransparentProxy = prefs.getBoolean("pref_transparent", false);
|
||||||
boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
|
boolean transProxyAll = prefs.getBoolean("pref_transparent_all", false);
|
||||||
|
|
||||||
|
@ -1309,13 +1325,10 @@ public class TorService extends Service implements TorServiceConstants, Runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (hasRoot)
|
||||||
{
|
|
||||||
if (hasRoot)
|
|
||||||
{
|
{
|
||||||
TorTransProxy.purgeIptables(this,AppManager.getApps(this));
|
TorTransProxy.purgeIptables(this,AppManager.getApps(this));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,9 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// 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
|
public static int redirectDNSResolvConf () throws Exception
|
||||||
{
|
{
|
||||||
StringBuilder script = new StringBuilder();
|
StringBuilder script = new StringBuilder();
|
||||||
|
@ -160,6 +162,7 @@ public class TorTransProxy implements TorServiceConstants {
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
|
public static int setTransparentProxyingByApp(Context context, TorifiedApp[] apps, boolean forceAll) throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue