Merge branch 'master' into hidden_services

# Conflicts:
#	app/src/main/java/org/torproject/android/OrbotMainActivity.java
This commit is contained in:
Juan Ezquerro LLanes 2016-11-29 11:09:49 +01:00
commit 3ba1d395ea
4 changed files with 834 additions and 727 deletions

View File

@ -3,6 +3,31 @@
package org.torproject.android;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;
import org.json.JSONArray;
import org.torproject.android.service.OrbotConstants;
import org.torproject.android.service.util.Prefs;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.AppManager;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
import org.torproject.android.vpn.VPNEnableActivity;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
@ -58,37 +83,6 @@ import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import org.json.JSONArray;
import org.torproject.android.service.OrbotConstants;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.util.Prefs;
import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.AppManager;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
import org.torproject.android.ui.hiddenservices.HiddenServicesActivity;
import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
import org.torproject.android.vpn.VPNEnableActivity;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;
import static android.support.v4.content.FileProvider.getUriForFile;
public class OrbotMainActivity extends AppCompatActivity
implements OrbotConstants, OnLongClickListener, OnTouchListener {
@ -133,17 +127,18 @@ public class OrbotMainActivity extends AppCompatActivity
public final static String INTENT_ACTION_REQUEST_START_TOR = "org.torproject.android.START_TOR";
// for bridge loading from the assets default bridges.txt file
class Bridge {
class Bridge
{
String type;
String config;
}
private ArrayList<Bridge> alBridges = null;
//this is needed for backwards compat back to Android 2.3.*
@SuppressLint("NewApi")
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
public View onCreateView(View parent, String name, Context context, AttributeSet attrs)
{
if(Build.VERSION.SDK_INT >= 11)
return super.onCreateView(parent, name, context, attrs);
return null;
@ -258,7 +253,8 @@ public class OrbotMainActivity extends AppCompatActivity
}
};
private void doLayout() {
private void doLayout ()
{
setContentView(R.layout.layout_main);
setTitle(R.string.app_name);
@ -298,7 +294,8 @@ public class OrbotMainActivity extends AppCompatActivity
mGestureDetector = new GestureDetector(this, new MyGestureDetector());
mBtnStart =(Button)findViewById(R.id.btnStart);
mBtnStart.setOnClickListener(new View.OnClickListener() {
mBtnStart.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
@ -314,7 +311,8 @@ public class OrbotMainActivity extends AppCompatActivity
});
mBtnBrowser = (Button)findViewById(R.id.btnBrowser);
mBtnBrowser.setOnClickListener(new View.OnClickListener() {
mBtnBrowser.setOnClickListener(new View.OnClickListener ()
{
@Override
public void onClick(View v) {
@ -330,21 +328,27 @@ public class OrbotMainActivity extends AppCompatActivity
boolean canDoVPN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
if (!canDoVPN) {
if (!canDoVPN)
{
//if not SDK 14 or higher, we can't use the VPN feature
mBtnVPN.setVisibility(View.GONE);
} else {
}
else
{
boolean useVPN = Prefs.useVpn();
mBtnVPN.setChecked(useVPN);
//auto start VPN if VPN is enabled
if (useVPN) {
if (useVPN)
{
startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
}
mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
enableVPN(isChecked);
@ -357,14 +361,18 @@ public class OrbotMainActivity extends AppCompatActivity
mBtnBridges = (SwitchCompat)findViewById(R.id.btnBridges);
mBtnBridges.setChecked(Prefs.bridgesEnabled());
mBtnBridges.setOnClickListener(new View.OnClickListener() {
mBtnBridges.setOnClickListener(new View.OnClickListener ()
{
@Override
public void onClick(View v) {
if (Build.CPU_ABI.contains("arm")) {
if (Build.CPU_ABI.contains("arm"))
{
promptSetupBridges (); //if ARM processor, show all bridge options
} else {
}
else
{
showGetBridgePrompt(""); //if other chip ar, only stock bridges are supported
}
}
@ -379,7 +387,8 @@ public class OrbotMainActivity extends AppCompatActivity
ArrayList<String> cList = new ArrayList<String>();
cList.add(0, getString(R.string.vpn_default_world));
for (int i = 0; i < TorServiceConstants.COUNTRY_CODES.length; i++) {
for (int i = 0; i < TorServiceConstants.COUNTRY_CODES.length; i++)
{
Locale locale = new Locale("",TorServiceConstants.COUNTRY_CODES[i]);
cList.add(locale.getDisplayCountry());
@ -444,10 +453,12 @@ public class OrbotMainActivity extends AppCompatActivity
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_settings) {
if (item.getItemId() == R.id.menu_settings)
{
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
startActivityForResult(intent, REQUEST_SETTINGS);
}
@ -457,23 +468,31 @@ public class OrbotMainActivity extends AppCompatActivity
startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class));
}*/
else if (item.getItemId() == R.id.menu_exit) {
else if (item.getItemId() == R.id.menu_exit)
{
//exit app
doExit();
} else if (item.getItemId() == R.id.menu_about) {
}
else if (item.getItemId() == R.id.menu_about)
{
showAbout();
} else if (item.getItemId() == R.id.menu_scan) {
}
else if (item.getItemId() == R.id.menu_scan)
{
IntentIntegrator integrator = new IntentIntegrator(OrbotMainActivity.this);
integrator.initiateScan();
} else if (item.getItemId() == R.id.menu_share_bridge) {
}
else if (item.getItemId() == R.id.menu_share_bridge)
{
String bridges = Prefs.getBridgesList();
if (bridges != null && bridges.length() > 0) {
if (bridges != null && bridges.length() > 0)
{
try {
bridges = "bridge://" + URLEncoder.encode(bridges,"UTF-8");
@ -486,14 +505,13 @@ public class OrbotMainActivity extends AppCompatActivity
}
}
} else if (item.getItemId() == R.id.menu_hidden_services) {
startActivity(new Intent(this, HiddenServicesActivity.class));
}
return super.onOptionsItemSelected(item);
}
private void showAbout() {
private void showAbout ()
{
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.layout_about, null);
@ -531,24 +549,29 @@ public class OrbotMainActivity extends AppCompatActivity
}
protected void onPause() {
try {
try
{
super.onPause();
if (aDialog != null)
aDialog.dismiss();
} catch (IllegalStateException ise) {
}
catch (IllegalStateException ise)
{
//can happen on exit/shutdown
}
}
private void doTorCheck() {
private void doTorCheck ()
{
openBrowser(URL_TOR_CHECK,false);
}
private void enableVPN(boolean enable) {
private void enableVPN (boolean enable)
{
Prefs.putUseVpn(enable);
if (enable) {
@ -788,21 +811,30 @@ public class OrbotMainActivity extends AppCompatActivity
/*
* Launch the system activity for Uri viewing with the provided url
*/
private void openBrowser(final String browserLaunchUrl, boolean forceExternal) {
private void openBrowser(final String browserLaunchUrl,boolean forceExternal)
{
boolean isBrowserInstalled = appInstalledOrNot(TorServiceConstants.BROWSER_APP_USERNAME);
if (isBrowserInstalled) {
if (isBrowserInstalled)
{
startIntent(TorServiceConstants.BROWSER_APP_USERNAME,Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl));
} else if (mBtnVPN.isChecked() || forceExternal) {
}
else if (mBtnVPN.isChecked()||forceExternal)
{
//use the system browser since VPN is on
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
} else if (Prefs.useTransparentProxying()) {
}
else if (Prefs.useTransparentProxying())
{
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
} else {
}
else
{
AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
.setTitle(R.string.install_apps_)
.setMessage(R.string.it_doesn_t_seem_like_you_have_orweb_installed_want_help_with_that_or_should_we_just_open_the_browser_)
.setPositiveButton(R.string.install_orweb, new Dialog.OnClickListener() {
.setPositiveButton(R.string.install_orweb, new Dialog.OnClickListener ()
{
@Override
public void onClick(DialogInterface dialog, int which) {
@ -824,7 +856,8 @@ public class OrbotMainActivity extends AppCompatActivity
mBtnVPN.setChecked(true);
}
})
.setNegativeButton(R.string.standard_browser, new Dialog.OnClickListener() {
.setNegativeButton(R.string.standard_browser, new Dialog.OnClickListener ()
{
@Override
public void onClick(DialogInterface dialog, int which) {
@ -839,7 +872,12 @@ public class OrbotMainActivity extends AppCompatActivity
}
private void startIntent(String pkg, String action, Uri data) {
private void startIntent (String pkg, String action, Uri data)
{
Intent i;
PackageManager pm = getPackageManager();
@ -848,7 +886,9 @@ public class OrbotMainActivity extends AppCompatActivity
i = pm.getLaunchIntentForPackage(pkg);
if (i == null)
throw new PackageManager.NameNotFoundException();
} else {
}
else
{
i = new Intent();
}
@ -863,12 +903,16 @@ public class OrbotMainActivity extends AppCompatActivity
}
}
private boolean appInstalledOrNot(String uri) {
private boolean appInstalledOrNot(String uri)
{
PackageManager pm = getPackageManager();
try {
try
{
PackageInfo pi = pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return pi.applicationInfo.enabled;
} catch (PackageManager.NameNotFoundException e) {
}
catch (PackageManager.NameNotFoundException e)
{
return false;
}
}
@ -877,35 +921,48 @@ public class OrbotMainActivity extends AppCompatActivity
protected void onActivityResult(int request, int response, Intent data) {
super.onActivityResult(request, response, data);
if (request == REQUEST_SETTINGS && response == RESULT_OK) {
if (request == REQUEST_SETTINGS && response == RESULT_OK)
{
OrbotApp.forceChangeLanguage(this);
if (data != null && data.getBooleanExtra("transproxywipe", false)) {
if (data != null && data.getBooleanExtra("transproxywipe", false))
{
boolean result = flushTransProxy();
if (result) {
if (result)
{
Toast.makeText(this, R.string.transparent_proxy_rules_flushed_, Toast.LENGTH_SHORT).show();
} else {
}
else
{
Toast.makeText(this, R.string.you_do_not_have_root_access_enabled, Toast.LENGTH_SHORT).show();
}
} else if (torStatus == TorServiceConstants.STATUS_ON) {
}
else if (torStatus == TorServiceConstants.STATUS_ON)
{
updateTransProxy();
// Toast.makeText(this, R.string.you_may_need_to_stop_and_start_orbot_for_settings_change_to_be_enabled_, Toast.LENGTH_SHORT).show();
}
} else if (request == REQUEST_VPN) {
}
else if (request == REQUEST_VPN)
{
if (response == RESULT_OK) {
sendIntentToService(TorServiceConstants.CMD_VPN);
} else {
}
else
{
Prefs.putUseVpn(false);
}
} else if (request == REQUEST_VPN_APPS_SELECT) {
}
else if (request == REQUEST_VPN_APPS_SELECT)
{
startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
}
@ -915,23 +972,28 @@ public class OrbotMainActivity extends AppCompatActivity
String results = scanResult.getContents();
if (results != null && results.length() > 0) {
if (results != null && results.length() > 0)
{
try {
int urlIdx = results.indexOf("://");
if (urlIdx != -1) {
if (urlIdx!=-1)
{
results = URLDecoder.decode(results, "UTF-8");
results = results.substring(urlIdx+3);
showAlert(getString(R.string.bridges_updated),getString(R.string.restart_orbot_to_use_this_bridge_) + results,false);
setNewBridges(results);
} else {
}
else
{
JSONArray bridgeJson = new JSONArray(results);
StringBuffer bridgeLines = new StringBuffer();
for (int i = 0; i < bridgeJson.length(); i++) {
for (int i = 0; i < bridgeJson.length(); i++)
{
String bridgeLine = bridgeJson.getString(i);
bridgeLines.append(bridgeLine).append("\n");
}
@ -949,7 +1011,8 @@ public class OrbotMainActivity extends AppCompatActivity
}
public void promptSetupBridges() {
public void promptSetupBridges ()
{
loadBridgeDefaults();
LayoutInflater li = LayoutInflater.from(this);
@ -958,7 +1021,8 @@ public class OrbotMainActivity extends AppCompatActivity
TextView versionName = (TextView)view.findViewById(R.id.diaglog);
versionName.setText(R.string.if_your_mobile_network_actively_blocks_tor_you_can_use_a_tor_bridge_to_access_the_network_another_way_to_get_bridges_is_to_send_an_email_to_bridges_torproject_org_please_note_that_you_must_send_the_email_using_an_address_from_one_of_the_following_email_providers_riseup_gmail_or_yahoo_);
if (mBtnBridges.isChecked()) {
if (mBtnBridges.isChecked())
{
new AlertDialog.Builder(this)
.setTitle(R.string.bridge_mode)
.setView(view)
@ -967,7 +1031,8 @@ public class OrbotMainActivity extends AppCompatActivity
// The 'which' argument contains the index position
// of the selected item
switch (which) {
switch (which)
{
case 0: //obfs 4;
setupBridgeType("obfs4");
enableBridges(true);
@ -991,7 +1056,8 @@ public class OrbotMainActivity extends AppCompatActivity
}
}
}).setNegativeButton(R.string.btn_cancel, new Dialog.OnClickListener() {
}).setNegativeButton(R.string.btn_cancel, new Dialog.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
@ -1002,13 +1068,16 @@ public class OrbotMainActivity extends AppCompatActivity
.show();
} else {
}
else
{
enableBridges(false);
}
}
private void showGetBridgePrompt(final String type) {
private void showGetBridgePrompt (final String type)
{
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.layout_diag, null);
@ -1018,13 +1087,15 @@ public class OrbotMainActivity extends AppCompatActivity
new AlertDialog.Builder(this)
.setTitle(R.string.bridge_mode)
.setView(view)
.setNegativeButton(R.string.btn_cancel, new Dialog.OnClickListener() {
.setNegativeButton(R.string.btn_cancel, new Dialog.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
//do nothing
}
})
.setNeutralButton(R.string.get_bridges_email, new Dialog.OnClickListener() {
.setNeutralButton(R.string.get_bridges_email, new Dialog.OnClickListener ()
{
@Override
public void onClick(DialogInterface dialog, int which) {
@ -1036,7 +1107,8 @@ public class OrbotMainActivity extends AppCompatActivity
})
.setPositiveButton(R.string.get_bridges_web, new Dialog.OnClickListener() {
.setPositiveButton(R.string.get_bridges_web, new Dialog.OnClickListener ()
{
@Override
public void onClick(DialogInterface dialog, int which) {
@ -1049,16 +1121,20 @@ public class OrbotMainActivity extends AppCompatActivity
}).show();
}
private void sendGetBridgeEmail(String type) {
private void sendGetBridgeEmail (String type)
{
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL , new String[]{"bridges@torproject.org"});
if (type != null) {
if (type != null)
{
intent.putExtra(Intent.EXTRA_SUBJECT, "get transport " + type);
intent.putExtra(Intent.EXTRA_TEXT, "get transport " + type);
} else {
}
else
{
intent.putExtra(Intent.EXTRA_SUBJECT, "get bridges");
intent.putExtra(Intent.EXTRA_TEXT, "get bridges");
@ -1067,12 +1143,15 @@ public class OrbotMainActivity extends AppCompatActivity
startActivity(Intent.createChooser(intent, getString(R.string.send_email)));
}
private void enableBridges(boolean enable) {
private void enableBridges (boolean enable)
{
Prefs.putBridgesEnabled(enable);
if (torStatus == TorServiceConstants.STATUS_ON) {
if (torStatus == TorServiceConstants.STATUS_ON)
{
String bridgeList = Prefs.getBridgesList();
if (bridgeList != null && bridgeList.length() > 0) {
if (bridgeList != null && bridgeList.length() > 0)
{
requestTorRereadConfig ();
}
}
@ -1082,16 +1161,19 @@ public class OrbotMainActivity extends AppCompatActivity
sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
}
public void stopVpnService() {
public void stopVpnService ()
{
sendIntentToService(TorServiceConstants.CMD_VPN_CLEAR);
}
private boolean flushTransProxy() {
private boolean flushTransProxy ()
{
sendIntentToService(TorServiceConstants.CMD_FLUSH);
return true;
}
private boolean updateTransProxy() {
private boolean updateTransProxy ()
{
sendIntentToService(TorServiceConstants.CMD_UPDATE_TRANS_PROXY);
return true;
}
@ -1114,21 +1196,26 @@ public class OrbotMainActivity extends AppCompatActivity
//sometimes this can go haywire or crazy with too many error
//messages from Tor, and the user cannot stop or exit Orbot
//so need to ensure repeated error messages are not spamming this method
private void showAlert(String title, String msg, boolean button) {
try {
private void showAlert(String title, String msg, boolean button)
{
try
{
if (aDialog != null && aDialog.isShowing())
aDialog.dismiss();
} catch (Exception e) {
} //swallow any errors
}
catch (Exception e){} //swallow any errors
if (button) {
if (button)
{
aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
.setIcon(R.drawable.onion32)
.setTitle(title)
.setMessage(msg)
.setPositiveButton(R.string.btn_okay, null)
.show();
} else {
}
else
{
aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
.setIcon(R.drawable.onion32)
.setTitle(title)
@ -1155,17 +1242,20 @@ public class OrbotMainActivity extends AppCompatActivity
mBtnBrowser.setEnabled(true);
mBtnStart.setText(R.string.menu_stop);
if (torServiceMsg != null) {
if (torServiceMsg != null)
{
if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER)) {
lblStatus.setText(torServiceMsg);
}
} else
}
else
lblStatus.setText(getString(R.string.status_activated));
boolean showFirstTime = mPrefs.getBoolean("connect_first_time", true);
if (showFirstTime) {
if (showFirstTime)
{
Editor pEdit = mPrefs.edit();
pEdit.putBoolean("connect_first_time", false);
pEdit.commit();
@ -1173,7 +1263,8 @@ public class OrbotMainActivity extends AppCompatActivity
getString(R.string.connect_first_time), true);
}
if (autoStartFromIntent) {
if (autoStartFromIntent)
{
autoStartFromIntent = false;
Intent resultIntent = lastStatusIntent;
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
@ -1183,14 +1274,17 @@ public class OrbotMainActivity extends AppCompatActivity
}
} else if (torStatus == TorServiceConstants.STATUS_STARTING) {
imgStatus.setImageResource(R.drawable.torstarting);
if (torServiceMsg != null) {
if (torServiceMsg != null)
{
if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_BOOTSTRAPPED))
lblStatus.setText(torServiceMsg);
} else
}
else
lblStatus.setText(getString(R.string.status_starting_up));
mBtnStart.setText("...");
@ -1216,7 +1310,8 @@ public class OrbotMainActivity extends AppCompatActivity
}
if (torServiceMsg != null && torServiceMsg.length() > 0) {
if (torServiceMsg != null && torServiceMsg.length() > 0)
{
mTxtOrbotLog.append(torServiceMsg + '\n');
}
}
@ -1284,11 +1379,13 @@ public class OrbotMainActivity extends AppCompatActivity
//now you can handle the intents properly
handleIntents();
} else if (newTorStatus != null && !torStatus.equals(newTorStatus)) //status changed
}
else if (newTorStatus != null && !torStatus.equals(newTorStatus)) //status changed
{
torStatus = newTorStatus;
updateStatus(log);
} else if (log != null) //it is just a log
}
else if (log != null) //it is just a log
updateStatus(log);
switch (msg.what) {
@ -1360,7 +1457,8 @@ public class OrbotMainActivity extends AppCompatActivity
private static final float ROTATE_FROM = 0.0f;
private static final float ROTATE_TO = 360.0f*4f;// 3.141592654f * 32.0f;
public void spinOrbot(float direction) {
public void spinOrbot (float direction)
{
sendIntentToService (TorServiceConstants.CMD_NEWNYM);
@ -1381,7 +1479,8 @@ public class OrbotMainActivity extends AppCompatActivity
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (torStatus == TorServiceConstants.STATUS_ON) {
if (torStatus == TorServiceConstants.STATUS_ON)
{
float direction = 1f;
if (velocityX < 0)
direction = -1f;
@ -1394,11 +1493,14 @@ public class OrbotMainActivity extends AppCompatActivity
}
}
private void loadBridgeDefaults() {
if (alBridges == null) {
private void loadBridgeDefaults ()
{
if (alBridges == null)
{
alBridges = new ArrayList<Bridge>();
try {
try
{
BufferedReader in=
new BufferedReader(new InputStreamReader(getAssets().open("bridges.txt"), "UTF-8"));
String str;
@ -1421,14 +1523,17 @@ public class OrbotMainActivity extends AppCompatActivity
}
in.close();
} catch (Exception e) {
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
private void setupBridgeType(String type) {
private void setupBridgeType (String type)
{
StringBuffer sbConfig = new StringBuffer ();
//we should randomly sort alBridges so we don't have the same bridge order each time
@ -1440,8 +1545,10 @@ public class OrbotMainActivity extends AppCompatActivity
int bridgeCount = 0;
//now go through the list to find the bridges we want
for (Bridge b : alBridges) {
if (b.type.equals(type)) {
for (Bridge b : alBridges)
{
if (b.type.equals(type))
{
sbConfig.append(b.type);
sbConfig.append(' ');

View File

@ -78,7 +78,20 @@
</LinearLayout>
<TextView
android:id="@+id/lblStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:fontFamily="sans-serif-light"
android:text=""
android:lines="1"
android:maxLines="1"
android:layout_margin="12dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:ellipsize="end"
/>
</RelativeLayout>

View File

@ -107,17 +107,7 @@
/>
</RelativeLayout>
<TextView
android:id="@+id/lblStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:fontFamily="sans-serif-light"
android:text=""
android:lines="2"
android:maxLines="2"
android:layout_margin="12dp"
/>
</LinearLayout>

View File

@ -543,13 +543,12 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mNotificationManager == null)
{
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
}
new Thread(new Runnable ()
{
@ -735,6 +734,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
} else if (mCurrentStatus == STATUS_ON) {
sendCallbackLogMessage("Ignoring start request, already started.");
setTorNetworkEnabled (true);
return;
}
@ -1525,7 +1525,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
mNetworkType = newNetType;
mConnectivity = newConnectivityState;
if (doNetworKSleep)
if (doNetworKSleep && mCurrentStatus != STATUS_OFF)
{
setTorNetworkEnabled (mConnectivity);
@ -1543,8 +1543,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
try {
if (mCurrentStatus != STATUS_OFF)
{
if (mConnectivity)
{
if (Prefs.useRoot() && Prefs.useTransparentProxying() && Prefs.transProxyNetworkRefresh())
@ -1556,7 +1554,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
}
}
}
} catch (Exception e) {
logException ("error updating state after network restart",e);