fixes #1947 bug; adds Start on Boot option; v1.0.4-RC5

svn:r23290
This commit is contained in:
Nathan Freitas 2010-09-23 19:47:25 +00:00
parent ed6f809827
commit 91b9c09c32
10 changed files with 184 additions and 96 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.torproject.android" android:versionName="0.2.2.14-orbot-alpha-1.0.3" android:versionCode="9">
package="org.torproject.android" android:versionName="1.0.4" android:versionCode="11">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".Orbot"
@ -33,13 +33,21 @@
<activity android:name=".AppManager" android:label="@string/app_name"/>
<activity android:name=".WizardActivity" android:label="@string/app_name"/>
<service android:name=".service.TorService" android:process=":remote">
<!-- <service android:name=".service.TorService" android:process=":remote"> -->
<service android:name=".service.TorService">
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
</intent-filter>
</service>
<receiver android:name=".boot.OnbootBroadcastReceiver">
<intent-filter>
<action
android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
</application>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.torproject.android" android:versionName="0.2.2.14-orbot-alpha-1.0.3" android:versionCode="9">
package="org.torproject.android" android:versionName="1.0.4" android:versionCode="10">
<uses-permission android:name="android.permission.INTERNET" />

View File

@ -1,5 +1,6 @@
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
@ -7,6 +8,9 @@ NOTE: Specific #s below correspond to Trac tickets logged and maintained at http
- 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
- Fixed log screen touch disable tor bug
- Debugged issues around network status change causing FC/crash
- Added "Start on Boot" option
1.0.3
- Fixed spanish language issues with settings screen

View File

@ -43,7 +43,7 @@
android:layout_width="fill_parent"
android:layout_x="2px"
android:layout_y="2px"
android:textSize="12px"
android:textSize="14px"
android:background="#A0222222"
/>

View File

@ -58,8 +58,8 @@
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textStyle="bold"
android:width="320px"
android:height="100px"
android:width="300px"
android:height="75px"
android:textColor="#ffffff"
/>
</TableRow>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pref_hs_group">Hidden Services</string>
<string name="app_name">Orbot</string>
<string name="app_version">1.0.4</string>
@ -110,4 +109,12 @@
<string name="connect_first_time"> You\'ve successfully connected to the Tor network - but this does NOT mean your device is secure. You can use the \'Check\' option from the menu to test your browser. \n\nVisit us at https://guardianproject.info/apps/orbot or send an email to help@guardianproject.info to learn more.</string>
<string name="tor_check">This will open your default web browser to https://check.torproject.org in order to see if Orbot is probably configured and you are connected to Tor.</string>
<string name="pref_hs_group">Hidden Services</string>
<string name="pref_general_group">General</string>
<string name="pref_start_boot_title">Start Orbot on Boot</string>
<string name="pref_start_boot_summary">Automatically start Orbot and connect Tor when your Android device boots</string>
</resources>

View File

@ -1,5 +1,14 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_general_group">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_start_boot"
android:title="@string/pref_start_boot_title"
android:summary="@string/pref_start_boot_summary"
android:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_trans_proxy_group">
<CheckBoxPreference

View File

@ -176,10 +176,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
stopTor();
unbindService();
stopService(new Intent(ITorService.class.getName()));
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();
@ -826,43 +823,45 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
mHandler.sendMessage(msg);
}
//unbindService();
//stopService(new Intent(ITorService.class.getName()));
}
/*
@Override
public boolean onTouchEvent(MotionEvent event) {
try
{
if (mService == null)
{
}
else if (mService.getStatus() == STATUS_READY)
if (currentView == R.layout.layout_main)
{
try
{
if (mService == null)
{
if (event.getAction() == MotionEvent.ACTION_UP)
}
else if (mService.getStatus() == STATUS_READY)
{
startTor();
}
}
else
{
if (event.getAction() == MotionEvent.ACTION_DOWN)
else
{
stopTor();
}
}
}
catch (Exception e)
{
Log.d(TAG,"error onclick",e);
}
catch (Exception e)
{
Log.d(TAG,"error onclick",e);
}
}
return super.onTouchEvent(event);
}
}*/
/*
* (non-Javadoc)
@ -870,9 +869,8 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
*/
public void onClick(View view) {
// the start button
// if (view.getId()==R.id.imgStatus || view.getId()==R.id.lblStatus)
// {
if (currentView == R.layout.layout_main)
{
try
{
@ -899,7 +897,7 @@ public class Orbot extends Activity implements OnClickListener, TorConstants
Log.d(TAG,"error onclick",e);
}
// }
}
}

View File

@ -54,15 +54,18 @@ public class SettingsPreferences
super.onResume();
int transProxyGroupIdx = 1;
if (!hasRoot)
{
getPreferenceScreen().getPreference(0).setEnabled(false);
getPreferenceScreen().getPreference(transProxyGroupIdx).setEnabled(false);
}
else
{
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(0));
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(1);
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(0)).getPreference(2);
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(0));
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(1);
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(2);
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
@ -74,10 +77,12 @@ public class SettingsPreferences
}
prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(4)).getPreference(0));
int hiddenGroupIdx = 5;
prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(hiddenGroupIdx)).getPreference(0));
prefHiddenServices.setOnPreferenceClickListener(this);
((PreferenceCategory)this.getPreferenceScreen().getPreference(4)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(4)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(hiddenGroupIdx)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(hiddenGroupIdx)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
};
@ -106,8 +111,8 @@ public class SettingsPreferences
else if (preference == prefHiddenServices)
{
((PreferenceCategory)this.getPreferenceScreen().getPreference(4)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(4)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(5)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
((PreferenceCategory)this.getPreferenceScreen().getPreference(5)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
}
else

View File

@ -65,7 +65,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
public void onCreate() {
super.onCreate();
Log.i(TAG, "serviced created");
}
@ -183,16 +183,38 @@ public class TorService extends Service implements TorServiceConstants, Runnable
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
_torInstance = this;
Log.i(TAG, "service started: " + intent.getAction());
try {
checkTorBinaries ();
} catch (Exception e) {
logNotice("unable to find tor binaries: " + e.getMessage());
showToolbarNotification(e.getMessage(), R.drawable.tornotificationoff);
Log.e(TAG, "error checking tor binaries", e);
}
if (intent.getAction()!=null && intent.getAction().equals("onboot"))
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
if (startOnBoot)
{
setTorProfile(PROFILE_ON);
}
}
}
public void run ()
{
boolean isRunning = _torInstance.findExistingProc ();
if (!isRunning)
@ -227,16 +249,12 @@ public class TorService extends Service implements TorServiceConstants, Runnable
{
currentStatus = STATUS_OFF;
sendCallbackLogMessage("Web proxy shutdown");
try
{
killTorProcess ();
currentStatus = STATUS_READY;
showToolbarNotification (getString(R.string.status_disabled),R.drawable.tornotificationoff);
sendCallbackStatusMessage(getString(R.string.status_disabled));
@ -276,8 +294,6 @@ public class TorService extends Service implements TorServiceConstants, Runnable
private void killTorProcess () throws Exception
{
//android.os.Debug.waitForDebugger();
StringBuilder log = new StringBuilder();
int procId = -1;
@ -287,8 +303,9 @@ public class TorService extends Service implements TorServiceConstants, Runnable
try {
logNotice("sending SHUTDOWN signal to Tor process");
conn.signal("SHUTDOWN");
//torConnSocket.close();
conn.shutdownTor("SHUTDOWN");
} catch (Exception e) {
Log.d(TAG,"error shutting down Tor via connection",e);
@ -296,25 +313,25 @@ public class TorService extends Service implements TorServiceConstants, Runnable
conn = null;
}
else
{
try //wait a second for this
{ Thread.sleep(1000); }
catch (Exception e) {}
logNotice("Checking for existing Tor process via path: " + torBinaryPath);
procId = TorServiceUtils.findProcessId(torBinaryPath);
while (procId != -1)
{
logNotice("Found Tor PID=" + procId + " - killing now...");
String[] cmd = { SHELL_CMD_KILL + ' ' + procId + "" };
TorServiceUtils.doShellCommand(cmd,log, false, false);
logNotice("Checking for existing Tor process via path: " + torBinaryPath);
procId = TorServiceUtils.findProcessId(torBinaryPath);
}
while (procId != -1)
{
logNotice("Found Tor PID=" + procId + " - killing now...");
String[] cmd = { SHELL_CMD_KILL + ' ' + procId + "" };
TorServiceUtils.doShellCommand(cmd,log, false, false);
procId = TorServiceUtils.findProcessId(torBinaryPath);
}
}
logNotice("Checking for existing Privoxy process via path: " + privoxyPath);
procId = TorServiceUtils.findProcessId(privoxyPath);
@ -393,6 +410,33 @@ public class TorService extends Service implements TorServiceConstants, Runnable
return fileApk.getAbsolutePath();
}
apkBase = "/sd-ext/app/";
APK_EXT = ".apk";
MAX_TRIES = 10;
buildPath = apkBase + TOR_APP_USERNAME + APK_EXT;
logNotice("Checking Apps2SD APK location: " + buildPath);
fileApk = new File(buildPath);
if (fileApk.exists())
return fileApk.getAbsolutePath();
for (int i = 0; i < MAX_TRIES; i++)
{
buildPath = apkBase + TOR_APP_USERNAME + '-' + i + APK_EXT;
fileApk = new File(buildPath);
logNotice( "Checking Apps2SD location: " + buildPath);
if (fileApk.exists())
return fileApk.getAbsolutePath();
}
return null;
}
@ -412,6 +456,9 @@ public class TorService extends Service implements TorServiceConstants, Runnable
String apkPath = findAPK();
if (apkPath == null)
throw new Exception ("Unable to locate Orbot binary APK file");
logNotice( "found apk at: " + apkPath);
boolean apkExists = new File(apkPath).exists();
@ -768,13 +815,15 @@ public class TorService extends Service implements TorServiceConstants, Runnable
}
public void setTorProfile(int profile) {
logNotice("Tor profile set to " + profile);
if (profile == PROFILE_ON)
{
currentStatus = STATUS_CONNECTING;
sendCallbackStatusMessage ("starting...");
new Thread(_torInstance).start();
Thread thread = new Thread(this);
thread.start();
}
else
@ -784,6 +833,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
_torInstance.stopTor();
}
}
@ -899,22 +949,25 @@ public class TorService extends Service implements TorServiceConstants, Runnable
// a single interface, you can just return it here without checking
// the Intent.
_torInstance = this;
try
{
checkTorBinaries();
findExistingProc ();
_torInstance = this;
}
catch (Exception e)
{
logNotice("unable to find tor binaries: " + e.getMessage());
showToolbarNotification(e.getMessage(), R.drawable.tornotificationoff);
Log.d(TAG,"Unable to check for Tor binaries",e);
return null;
}
findExistingProc ();
if (ITorService.class.getName().equals(intent.getAction())) {
return mBinder;
}
@ -1060,29 +1113,28 @@ public class TorService extends Service implements TorServiceConstants, Runnable
};
private ArrayList<String> callbackBuffer = new ArrayList<String>();
private boolean inCallbackStatus = false;
private boolean inCallbackLog = false;
private void sendCallbackStatusMessage (String newStatus)
{
if (mCallbacks == null)
return;
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
callbackBuffer.add(newStatus);
inCallbackStatus = true;
if (N > 0)
{
Iterator<String> it = callbackBuffer.iterator();
String status = null;
while (it.hasNext())
{
status = it.next();
for (int i=0; i<N; i++) {
for (int i=0; i<N; i++) {
try {
mCallbacks.getBroadcastItem(i).statusChanged(status);
mCallbacks.getBroadcastItem(i).statusChanged(newStatus);
} catch (RemoteException e) {
@ -1090,22 +1142,26 @@ public class TorService extends Service implements TorServiceConstants, Runnable
// the dead object for us.
}
}
}
callbackBuffer.clear();
}
mCallbacks.finishBroadcast();
inCallbackStatus = false;
}
private synchronized void sendCallbackLogMessage (String logMessage)
private void sendCallbackLogMessage (String logMessage)
{
if (mCallbacks == null)
return;
callbackBuffer.add(logMessage);
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
inCallbackLog = true;
callbackBuffer.add(logMessage);
if (N > 0)
{
@ -1133,6 +1189,7 @@ public class TorService extends Service implements TorServiceConstants, Runnable
}
mCallbacks.finishBroadcast();
inCallbackLog = false;
}
private void applyPreferences () throws RemoteException