commit 2b6abd7e659b8d3ca5fad061d4f284342ad72ab2 Author: lexi dnsake@protonmail.com Date: Fri Mar 29 13:57:00 2019 -0400
Removed Obsolete Version Checks
I took out all of the version checks that considered SDK Versions that are < API Level 16 (the lowest SDK version supported by Orbot) --- .../org/torproject/android/OrbotMainActivity.java | 55 +++++----------------- .../android/service/util/CustomNativeLoader.java | 12 ++--- .../android/service/util/TorServiceUtils.java | 10 +--- 3 files changed, 19 insertions(+), 58 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index 9676abc9..d1929f88 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -12,10 +12,8 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.text.NumberFormat; import java.util.ArrayList; -import java.util.List; import java.util.Locale; import java.util.StringTokenizer; -import java.util.TimerTask;
import org.json.JSONArray; import org.torproject.android.service.OrbotConstants; @@ -37,7 +35,6 @@ import org.torproject.android.ui.hiddenservices.permissions.PermissionManager; import org.torproject.android.ui.hiddenservices.providers.HSContentProvider; import org.torproject.android.vpn.VPNEnableActivity;
-import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.AlertDialog; @@ -54,10 +51,8 @@ import android.content.SharedPreferences.Editor; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.ResolveInfo; import android.database.Cursor; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -69,7 +64,6 @@ import android.support.v7.widget.SwitchCompat; import android.support.v7.widget.Toolbar; import android.text.Html; import android.text.TextUtils; -import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; @@ -141,16 +135,6 @@ public class OrbotMainActivity extends AppCompatActivity
PulsatorLayout mPulsator;
- - //this is needed for backwards compat back to Android 2.3.* - @SuppressLint("NewApi") - 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; - } - private void migratePreferences() { String hsPortString = mPrefs.getString("pref_hs_ports", ""); if (hsPortString.length() > 0) { @@ -320,34 +304,21 @@ public class OrbotMainActivity extends AppCompatActivity
mBtnVPN = (SwitchCompat)findViewById(R.id.btnVPN); - boolean canDoVPN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; + boolean useVPN = Prefs.useVpn(); + mBtnVPN.setChecked(useVPN);
- if (!canDoVPN) - { - //if not SDK 14 or higher, we can't use the VPN feature - mBtnVPN.setVisibility(View.GONE); - } - else - { - boolean useVPN = Prefs.useVpn(); - mBtnVPN.setChecked(useVPN); - - //auto start VPN if VPN is enabled - if (useVPN) - { - startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class)); - } - - mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() - { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) - { - enableVPN(isChecked); - } - }); + //auto start VPN if VPN is enabled + if (useVPN) { + startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class)); + } + + mBtnVPN.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + enableVPN(isChecked); + } + });
- }
mBtnBridges = (SwitchCompat)findViewById(R.id.btnBridges); mBtnBridges.setChecked(Prefs.bridgesEnabled()); diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java b/orbotservice/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java index 6e75a98e..bae4b068 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java +++ b/orbotservice/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java @@ -1,7 +1,6 @@ package org.torproject.android.service.util;
import android.content.Context; -import android.content.pm.ApplicationInfo; import android.os.Build; import android.util.Log;
@@ -11,7 +10,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream;
public class CustomNativeLoader {
@@ -45,11 +43,9 @@ public class CustomNativeLoader { } out.close();
- if (Build.VERSION.SDK_INT >= 9) { - destLocalFile.setReadable(true, false); - destLocalFile.setExecutable(true, false); - destLocalFile.setWritable(true); - } + destLocalFile.setReadable(true, false); + destLocalFile.setExecutable(true, false); + destLocalFile.setWritable(true);
return true; } catch (Exception e) { @@ -122,7 +118,7 @@ public class CustomNativeLoader { }
} catch (Throwable e) { - Log.e(TAG, e.getMessage(),e); + Log.e(TAG, e.getMessage(), e); }
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java index 764bc9ec..78913a67 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java +++ b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java @@ -12,7 +12,6 @@ import java.net.Socket;
import android.content.Context; import android.content.SharedPreferences; -import android.os.Build;
import org.torproject.android.service.OrbotConstants; import org.torproject.android.service.TorServiceConstants; @@ -111,13 +110,8 @@ public class TorServiceUtils implements TorServiceConstants {
} - public static SharedPreferences getSharedPrefs (Context context) - { - if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) - return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS); - else - return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,Context.MODE_PRIVATE); - + public static SharedPreferences getSharedPrefs (Context context) { + return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS); } public static void killProcess(File fileProcBin) throws Exception {
tor-commits@lists.torproject.org