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.
This commit is contained in:
Hans-Christoph Steiner 2015-06-05 15:24:23 -04:00
parent d43a6cd2b2
commit 807b51fb43
1 changed files with 18 additions and 15 deletions

View File

@ -615,16 +615,19 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
else if (action.equals("org.torproject.android.START_TOR"))
{
autoStartFromIntent = true;
try {
Log.i(TAG, "action equals org.torproject.android.START_TOR");
startTor();
Intent nResult = new Intent();
//nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc
setResult(RESULT_OK,nResult);
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();
@ -1251,7 +1254,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
if (autoStartFromIntent)
{
setResult(RESULT_OK);
autoStartFromIntent = false;
finish();
}