Commit Graph

1358 Commits

Author SHA1 Message Date
Nathan Freitas f558a0a67c don't try to build external folders in eclipse 2015-06-25 10:37:48 -04:00
Nathan Freitas fa427a26f2 update tun2socks binaries 2015-06-25 10:37:29 -04:00
Nathan Freitas 76e424e695 update submodule pin 2015-06-25 10:35:28 -04:00
Nathan Freitas 765bc61ded enable background starts by default only for Service intent calls 2015-06-22 12:57:59 -04:00
Nathan Freitas dc16c98ff7 update manifest for v15.0.1 beta 1 2015-06-22 12:45:39 -04:00
Nathan Freitas e11cae883e Merge branch 'the-big-start-stop-makeover' of https://github.com/eighthave/orbot into eighthave-the-big-start-stop-makeover
Conflicts:
	src/org/torproject/android/OrbotMainActivity.java
	src/org/torproject/android/service/TorService.java
2015-06-22 12:43:42 -04:00
Nathan Freitas a8384bde74 Merge branch 'eighthave-the-big-start-stop-makeover' 2015-06-22 12:39:17 -04:00
Nathan Freitas 225ad9d1ac fix handling of foreground intent starts, and set bg start off by default 2015-06-22 12:37:51 -04:00
Nathan Freitas e132a79a61 improve status request/callback interaction and status UI layout 2015-06-22 12:25:37 -04:00
Nathan Freitas 67d1652e57 update tor to 0.2.6.9 2015-06-22 11:30:56 -04:00
Hans-Christoph Steiner aa87e6712a on start, check for running tor daemon, and if TorService stopped, then start
If Orbot was killed when the tor daemon was running, the tor daemon will
still be running when Orbot starts again.  OrbotMainActivity then checks to
see if tor daemon is running while TorService is stopped.  If so, TorService
is started so that the state of everything is in sync.
2015-06-17 12:08:52 -04:00
Hans-Christoph Steiner a81c0001d6 init file path variables (tor, polipo, etc) when the app starts
These file path variables can be set at the very start, OrbotApp.onCreate()
and they will not change during the lifetime of the app, so represent them
as globally accessible static variables.  This is needed for things like
OrbotMainActivity detecting whether the tor daemon is still running, even
though TorService is not.
2015-06-17 12:06:23 -04:00
Hans-Christoph Steiner 943edf094b "Allow Background Starts" prefs also controls the old START_TOR Intent 2015-06-17 11:45:07 -04:00
Hans-Christoph Steiner adf7c09f0e remove delayed handling of Intents in OrbotMainActivity
This is a leftover bit from the old structure, it should no longer be
needed and it causes the status updates to be noticeably delayed so when
OrbotMainActivity is started after being killed, it flashes OFF then ON.
2015-06-17 11:15:31 -04:00
Hans-Christoph Steiner c9e31020e0 prevent a status request from starting TorService
If some internal bit of Orbot is requesting the status of TorService, it
should not cause it to start.  So only request status from TorService if it
is running, otherwise keep status as OFF.

the big imports change is because of the Android auto-formatter
2015-06-17 11:13:35 -04:00
Hans-Christoph Steiner e5c2e1a040 when OrbotMainActivity starts, query TorService for current status
If OrbotMainActivity gets killed while TorService is running, then when
OrbotMainActivity starts again, it needs to get the current status from
TorService to correctly represent things to the user.
2015-06-17 11:00:48 -04:00
Hans-Christoph Steiner f16394b7db include all status messages with "start" in them in the starting sequence
Before, the startup sequence showed "Orbot is starting..." for a long time,
then quickly showed the final tor percentage messages.  This adds a few
more messages to provide useful feedback.
2015-06-12 14:55:17 -04:00
Hans-Christoph Steiner ddaae1d941 drive main screen UI updated entirely from TorService status updates
Now that STATUS_STARTING is sent in TorService.onCreate(), the response
time is snappy enough that we don't need hacks in OrbotMainActivity to
show that long press happened.
2015-06-12 14:54:04 -04:00
Hans-Christoph Steiner 232098eeaf set STATUS_STARTING in TorService.onCreate(), that's where it begins
The very first place that the whole tor start sequence starts is from
TorService's onCreate(), so that is where STATUS_STARTING should be
announced from.  The open question is whether Intents besides ACTION_START
ever cause TorService to start.  In theory, TorService should already be
running when any Intent is sent besides ACTION_START.
2015-06-12 14:49:19 -04:00
Hans-Christoph Steiner 8f57b42e68 rename TorStarter to IncomingIntentRouter, it handles all Intents
TorStarter does lots of things besides starting Tor
2015-06-12 14:46:47 -04:00
Hans-Christoph Steiner ff04bde300 announce Orbot is ON once the first circuit is complete
Before, it was announcing tor was started when it had completed starting
the daemons.  But that does not guarantee that Tor is actually connected
and working.  So instead, this waits for the first circuit to be built,
then announces Tor is ON.
2015-06-12 14:24:57 -04:00
Hans-Christoph Steiner b620f828a1 include dynamic proxy config info in ACTION_STATUS replies
This includes extras in the Intents that are sent as replies to the two
different requests to start tor (ACTION_START and ACTION_START_TOR).  These
extras give all of the current SOCKS and HTTP proxy settings, so that the
app can dynamically use the correct settings.  Sometimes there are port
conflicts, so apps should dynamically adjust in order to reliably find tor.

closes #3612 https://dev.guardianproject.info/issues/3612
refs #4419 https://dev.guardianproject.info/issues/4419
refs #3690 https://dev.guardianproject.info/issues/3690
refs #3687 https://dev.guardianproject.info/issues/3687
refs #3859 https://dev.guardianproject.info/issues/3859
2015-06-11 17:02:56 -04:00
Hans-Christoph Steiner 0937c8838f use constants for setting default ports, and variables when running 2015-06-11 16:32:31 -04:00
Hans-Christoph Steiner 623084548d standardize network port constant variables
use consistent naming and types for code clarity
2015-06-11 16:31:39 -04:00
Hans-Christoph Steiner 775135d07a let the requesting app know that the user has disabled starting via Intent
If an app is using ACTION_START to start Orbot in the background, but the
user had disabled that using the allowBackgroundStarts pref, then the app
will want to know about that so it can fallback on prompting the user to
bring up Orbot itself for the user to manually start it.

refs #3117 https://dev.guardianproject.info/issues/3117
2015-06-10 18:15:29 -04:00
Hans-Christoph Steiner ac8329c7f2 create a new pref: "Allow Background Starts"
This lets the user disable the new ACTION_START Intent, in case they have
more sensitive needs.
2015-06-10 18:02:43 -04:00
Hans-Christoph Steiner 77b1bdfbc5 on receiving ACTION_START, only send status reply if EXTRA_PACKAGE_NAME set
In order to receive a targeted reply, an app has to send its packageName to
Orbot as an String extra in an ACTION_START Intent.  Also, when Orbot
internally uses ACTION_START, it shouldn't receive replies.
2015-06-10 18:02:43 -04:00
Hans-Christoph Steiner f433a5e655 expose start action via a BroadcastReceiver that any app can send to
This allows any app to broadcast an Intent to Orbot in order to make Orbot
start in the background.

closes #3117 https://dev.guardianproject.info/issues/3117
2015-06-10 18:02:43 -04:00
Hans-Christoph Steiner 13d29878f9 a couple tweaks to make the long press feel more responsive 2015-06-10 18:02:43 -04:00
Hans-Christoph Steiner 25a6bb63b2 force all UI status updates through mStatusUpdateHandler
The Handler is a message queue for the main thread, so it should help keep
the UI working while status updates are coming in.

* This removes the constants in TorServiceConstants because the Handler
  messages are only for OrbotMainActivity

* this uses the handy shortcut msg.obj for the status message
2015-06-10 18:02:43 -04:00
Hans-Christoph Steiner 5c2d4501fa make updateStatus() more closely match the state given from TorService
This aims to make the UI more tighly in sync with the data coming from
TorService.  It is not currently perfect in the UI, but it means that the
UI will represent the status bugs in TorService.  This is important because
that status info is now broadcast to any app that wants it.  So the visible
part of Orbot should show want the apps are seeing to aid debugging.  And
status report bugs should be fixed in TorService so that everyone gets the
correctinfo.
2015-06-09 22:01:53 -04:00
Hans-Christoph Steiner 2f1d52f02d purge unused code from OrbotMainActivity
mItemOnOff no longer exists, there is no more start/stop button on the menu
and this code was trying to update menu.getItem(0), which is currently the
settings button.

onSharedPreferenceChanged() was entirely empty, and the prefs are all
handled in their own Activity
2015-06-09 22:01:53 -04:00
Hans-Christoph Steiner bf3572eb82 use the same action string for local and broadcast status
No need to have separate action strings, using the LocalBroadcastManager
enforces the local-only messaging, and Orbot does not claim the global
broadcasts in any kind of receiver.
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 2f7ddc4423 purge unused OrbotLogActivity 2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 90b731cc8d strictly target local broadcasts
This sets an action for each kind of local broadcast, and uses the action
to choose how to handle it.  Before, it was a mix of the action and which
extras the Intent included.
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 65d8801005 rename mMessageReceiver to mLocalBroadcastReceiver 2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 21c3bfb3c5 use "SIGNAL HUP" to request Tor re-read its config
The tor daemon supports both "SIGNAL HUP" via its control port or the UNIX
signal `kill -HUP` via the terminal as a way to trigger the tor daemon to
reload its config.  This is needed for new bridges and hidden services. It
is not necessary to restart everything to add those.

https://stem.torproject.org/faq.html#how-do-i-reload-my-torrc
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 6ac9a2cee6 use context.stopService() to shutdown TorService instead of custom message
Since running stopService() automatically triggers Service.onDestroy(),
there is a nice way to hook in and run the shutdown procedure.  This
provides an obvious point of entry as well as simplifying the shutdown
procedure.
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner bfb0a80a18 rename mHandler to mStatusUpdateHandler
Hopefully this will make the code a little easier to follow...
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 4d8a9dab27 broadcast Tor state to any app that might want to know
In order for apps to follow the current state of Tor, this broadcasts the
state both locally, since global broadcasts are insecure, and globally, for
any app to receive.  The internal workings of Orbot need to use a local
broadcast, otherwise any app could trigger stop, start, etc or DoS in other
ways.
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 3580cbe05d only set mCurrentStatus in sendCallbackStatus(), the one stop shop
Make sendCallbackStatus() the one thing that updates the all of the bits
related to running status.
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 780abf003e rework start/stop procedure to have clear points for ON, OFF, STARTING, STOPPING
In order to send reliable information to any app using Tor, Orbot itself
needs reliable state broadcasts.  Before, there the ON/OFF/STARTING state
were being set multiple times during the process, and sometimes not even in
a useful order (i.e. STARTING ON STARTING ON ON).

This reworks the start/stop procedure into startTor() and stopTor().
2015-06-09 22:01:52 -04:00
Hans-Christoph Steiner 4470771c0d rename startService() to sendIntentToService() to reflect what it does
Even though this method is a wrapper around startService(), it is really
used to send various Intents to the Service, not only starting it.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner 82f82e1c10 mark TorService methods from EventHandler as overridden
This keeps me from getting confused...
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner 86593df6fb rename status to STARTING and STOPPING since it also starts/stops daemons
The CONNECTING status also is starting up daemons as well as connecting to
the tor daemon.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner cf0adc27d6 on start and tor daemon not running, kill all daemons before starting again
To make sure there are not any other daemons still running when trying to
start the whole thing again, kill all daemons before starting tor afresh.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner 2bc85a4a3a rework killing all daemons to continue trying after a failure
Before, it would quit the process on the first exception while killing.
This makes it keep on trying each daemon.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner 73658ce3cf use Java methods for setting permissions on native executables
As of android-9, java.io.File has native methods for setting permissions,
inherited from Java 1.6.  Using these will help deal with compatibility
across devices, since some devices might not have chmod installed.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner a3d37e8b2a make prefs called directly when needed instead of requiring refresh
The code was using global variables that were refreshed from the prefs on
certain occasions.  That means that the global vars could easily get out of
sync with the actual values.  Instead, just read the prefs directly when
the values are needed, and they will always be up-to-date.
2015-06-09 22:01:51 -04:00
Hans-Christoph Steiner 6e13a7e369 purge dead and unused code from TorService 2015-06-09 22:01:51 -04:00