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:
parent
d43a6cd2b2
commit
807b51fb43
|
@ -615,20 +615,23 @@ 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();
|
||||
|
||||
try {
|
||||
startTor();
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue