commit 807b51fb4396fd81daf135bc2f8550561a14547d Author: Hans-Christoph Steiner hans@eds.org Date: Fri Jun 5 15:24:23 2015 -0400
include proxy config info when returning from START_TOR Intent
The recommended way to send a START_TOR Intent is using startActivityWithResult() so that the sender knows when Tor is actually started. The return includes an Intent that can also include the config info for the proxies that Orbot runs. Right now, this is based on the app defaults, but ultimately, it should dynamically get the port numbers for cases like Samsung devices where there is a port conflict. --- src/org/torproject/android/OrbotMainActivity.java | 33 +++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index a595e8b..3e577ad 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -615,21 +615,24 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon else if (action.equals("org.torproject.android.START_TOR")) { autoStartFromIntent = true; - - try { - startTor(); + try { + Log.i(TAG, "action equals org.torproject.android.START_TOR"); + startTor(); + + Intent resultIntent = new Intent(intent); + resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT); + resultIntent.putExtra("socks_proxy_host", "127.0.0.1"); + resultIntent.putExtra("socks_proxy_port", TorServiceConstants.PORT_SOCKS_DEFAULT); + resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.PORT_HTTP); + resultIntent.putExtra("http_proxy_host", "127.0.0.1"); + resultIntent.putExtra("http_proxy_port", TorServiceConstants.PORT_HTTP); + setResult(RESULT_OK, resultIntent); + finish(); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }
- Intent nResult = new Intent(); - - //nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc - - setResult(RESULT_OK,nResult); - - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else if (action.equals(Intent.ACTION_VIEW)) { @@ -1251,7 +1254,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
if (autoStartFromIntent) { - setResult(RESULT_OK); + autoStartFromIntent = false; finish(); }