fix handling of foreground intent starts, and set bg start off by default
This commit is contained in:
parent
e132a79a61
commit
225ad9d1ac
|
@ -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"/>
|
||||
|
|
|
@ -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);
|
||||
|
@ -502,7 +506,6 @@ 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,12 +561,14 @@ 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();
|
||||
|
||||
if (Prefs.allowBackgroundStarts())
|
||||
{
|
||||
Intent resultIntent;
|
||||
if (lastStatusIntent == null) {
|
||||
resultIntent = new Intent(intent);
|
||||
|
@ -573,6 +578,7 @@ public class OrbotMainActivity extends Activity
|
|||
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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue