[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] fix handling of foreground intent starts, and set bg start off by default
commit 225ad9d1ac1a73bbf061fbbc4d2d5e41feb60dfe
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Mon Jun 22 12:37:51 2015 -0400
fix handling of foreground intent starts, and set bg start off by default
---
res/xml/preferences.xml | 2 +-
src/org/torproject/android/OrbotMainActivity.java | 33 +++++++++++++--------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index e1e1828..08eddfa 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -23,7 +23,7 @@ android:enabled="true"
android:title="@string/pref_use_expanded_notifications_title"/>
<CheckBoxPreference
-android:defaultValue="true"
+android:defaultValue="false"
android:key="pref_allow_background_starts"
android:summary="@string/pref_allow_background_starts_summary"
android:title="@string/pref_allow_background_starts_title"/>
diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java
index 54fe5f1..2fd68d3 100644
--- a/src/org/torproject/android/OrbotMainActivity.java
+++ b/src/org/torproject/android/OrbotMainActivity.java
@@ -99,6 +99,10 @@ public class OrbotMainActivity extends Activity
private final static int STATUS_UPDATE = 1;
private static final int MESSAGE_TRAFFIC_COUNT = 2;
+ public final static String INTENT_ACTION_REQUEST_HIDDEN_SERVICE = "org.torproject.android.REQUEST_HS_PORT";
+ public final static String INTENT_ACTION_REQUEST_START_TOR = "org.torproject.android.START_TOR";
+
+
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -501,8 +505,7 @@ public class OrbotMainActivity extends Activity
}
}
-
-
+
private synchronized void handleIntents ()
{
if (getIntent() == null)
@@ -518,7 +521,7 @@ public class OrbotMainActivity extends Activity
if (action == null)
return;
- if (action.equals("org.torproject.android.REQUEST_HS_PORT"))
+ if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE))
{
final int hiddenServicePortRequest = getIntent().getIntExtra("hs_port", -1);
@@ -558,21 +561,24 @@ public class OrbotMainActivity extends Activity
return; //don't null the setIntent() as we need it later
}
- else if (action.equals("org.torproject.android.START_TOR"))
+ else if (action.equals(INTENT_ACTION_REQUEST_START_TOR))
{
autoStartFromIntent = true;
startTor();
- Intent resultIntent;
- if (lastStatusIntent == null) {
- resultIntent = new Intent(intent);
- } else {
- resultIntent = lastStatusIntent;
+ if (Prefs.allowBackgroundStarts())
+ {
+ Intent resultIntent;
+ if (lastStatusIntent == null) {
+ resultIntent = new Intent(intent);
+ } else {
+ resultIntent = lastStatusIntent;
+ }
+ resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
+ setResult(RESULT_OK, resultIntent);
+ finish();
}
- resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
- setResult(RESULT_OK, resultIntent);
- finish();
}
else if (action.equals(Intent.ACTION_VIEW))
@@ -1086,6 +1092,9 @@ public class OrbotMainActivity extends Activity
if (autoStartFromIntent)
{
autoStartFromIntent = false;
+ Intent resultIntent = lastStatusIntent;
+ resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
+ setResult(RESULT_OK, resultIntent);
finish();
Log.d(TAG, "autoStartFromIntent finish");
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits