]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebView.java
Use GMS (Google Mobile Services) to update OpenSSL on API 19. Possible fix for https...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebView.java
index 5fdd814eda2675b948a340002e9fff145495d909..00ea17818b35ef6ce111c33c0dabcee5be73c8f7 100644 (file)
@@ -52,6 +52,7 @@ import android.support.v7.app.AppCompatDialogFragment;
 import android.support.v7.widget.Toolbar;
 import android.text.Editable;
 import android.text.TextWatcher;
+import android.util.Log;
 import android.util.Patterns;
 import android.view.ContextMenu;
 import android.view.KeyEvent;
@@ -76,6 +77,11 @@ import android.widget.ProgressBar;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+// These three GMS (Google Mobile Services) lines need to be removed for F-Droid to build correctly.
+import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
+import com.google.android.gms.common.GooglePlayServicesRepairableException;
+import com.google.android.gms.security.ProviderInstaller;
+
 import com.stoutner.privacybrowser.BannerAd;
 import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.helpers.OrbotProxyHelper;
@@ -184,6 +190,18 @@ public class MainWebView extends AppCompatActivity implements NavigationView.OnN
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main_coordinatorlayout);
 
+        // API 19 uses an old version of OpenSSL, which exposes users to man-in-the-middle attacks.
+        if (Build.VERSION.SDK_INT == 19) {
+            try {
+                // Update OpenSSL using Google Play Services.  This command must be removed for the build to succeed on F-Droid.
+                ProviderInstaller.installIfNeeded(this);
+            } catch (GooglePlayServicesRepairableException exception) {
+                Log.i("Privacy Browser", "OpenSSL needs to be updated");
+            } catch (GooglePlayServicesNotAvailableException exception) {
+                Log.i("Privacy Browser", "OpenSSL cannot be updated because Google Play Services are not available");
+            }
+        }
+
         // Get a handle for `inputMethodManager`.
         inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);