From 45105572d945998013cca9d4173e796064f658c8 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Wed, 16 Nov 2016 07:50:40 -0500 Subject: [PATCH 1/3] if there is no status intent yet, then create one, and don't NPE --- .../java/org/torproject/android/OrbotMainActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index c43928e5..7706c0f5 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -103,7 +103,7 @@ public class OrbotMainActivity extends AppCompatActivity private ActionBarDrawerToggle mDrawerToggle; /* Some tracking bits */ - private String torStatus = null; //latest status reported from the tor service + private String torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service private Intent lastStatusIntent; // the last ACTION_STATUS Intent received private SharedPreferences mPrefs = null; @@ -1193,7 +1193,11 @@ public class OrbotMainActivity extends AppCompatActivity if (autoStartFromIntent) { autoStartFromIntent = false; - Intent resultIntent = lastStatusIntent; + Intent resultIntent = lastStatusIntent; + + if (resultIntent == null) + resultIntent = new Intent(TorServiceConstants.ACTION_START); + resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus); setResult(RESULT_OK, resultIntent); finish(); From d09c2b59b4337eb799365423a8321a1222ccfb1d Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Wed, 16 Nov 2016 07:52:06 -0500 Subject: [PATCH 2/3] put short status display back on main screen --- app/src/main/res/layout/layout_main.xml | 15 ++++++++++++++- app/src/main/res/layout/layout_orbot_control.xml | 12 +----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml index ab566ec4..5edfc32b 100644 --- a/app/src/main/res/layout/layout_main.xml +++ b/app/src/main/res/layout/layout_main.xml @@ -78,7 +78,20 @@ - + diff --git a/app/src/main/res/layout/layout_orbot_control.xml b/app/src/main/res/layout/layout_orbot_control.xml index 870eda4e..f7d15d85 100644 --- a/app/src/main/res/layout/layout_orbot_control.xml +++ b/app/src/main/res/layout/layout_orbot_control.xml @@ -107,17 +107,7 @@ /> - + From ff61d66bcfbb65baa7673857d420670c4f220c8c Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Wed, 16 Nov 2016 07:52:21 -0500 Subject: [PATCH 3/3] make sure tor network is re-enabled when user tries to restart --- .../android/service/TorService.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java index d55e1cf3..53dd07af 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java @@ -581,14 +581,13 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon if (mNotificationManager == null) { - - IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); - registerReceiver(mNetworkStateReceiver , mNetworkStateFilter); - mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - } - + + IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); + registerReceiver(mNetworkStateReceiver , mNetworkStateFilter); + + new Thread(new Runnable () { public void run () @@ -773,7 +772,8 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon } else if (mCurrentStatus == STATUS_ON) { sendCallbackLogMessage("Ignoring start request, already started."); - + setTorNetworkEnabled (true); + return; } @@ -1521,7 +1521,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon mNetworkType = newNetType; mConnectivity = newConnectivityState; - if (doNetworKSleep) + if (doNetworKSleep && mCurrentStatus != STATUS_OFF) { setTorNetworkEnabled (mConnectivity); @@ -1539,18 +1539,15 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon try { - if (mCurrentStatus != STATUS_OFF) + if (mConnectivity) { - if (mConnectivity) + if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh()) { - if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh()) - { - disableTransparentProxy(); - enableTransparentProxy(); + disableTransparentProxy(); + enableTransparentProxy(); - } } }