|
|
@ -3,6 +3,7 @@ package acr.browser.lightning.utils; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface; |
|
|
|
|
|
|
|
import android.os.Build; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
|
|
|
@ -12,8 +13,8 @@ import acr.browser.lightning.R; |
|
|
|
import acr.browser.lightning.activity.BrowserApp; |
|
|
|
import acr.browser.lightning.activity.BrowserApp; |
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
import info.guardianproject.onionkit.ui.OrbotHelper; |
|
|
|
import info.guardianproject.netcipher.proxy.OrbotHelper; |
|
|
|
import info.guardianproject.onionkit.web.WebkitProxy; |
|
|
|
import info.guardianproject.netcipher.web.WebkitProxy; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 6/4/2015 Anthony Restaino |
|
|
|
* 6/4/2015 Anthony Restaino |
|
|
@ -45,8 +46,7 @@ public class ProxyUtils { |
|
|
|
public void checkForProxy(final Activity activity) { |
|
|
|
public void checkForProxy(final Activity activity) { |
|
|
|
boolean useProxy = mPreferences.getUseProxy(); |
|
|
|
boolean useProxy = mPreferences.getUseProxy(); |
|
|
|
|
|
|
|
|
|
|
|
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); |
|
|
|
final boolean orbotInstalled = OrbotHelper.isOrbotInstalled(activity); |
|
|
|
final boolean orbotInstalled = oh.isOrbotInstalled(); |
|
|
|
|
|
|
|
boolean orbotChecked = mPreferences.getCheckedForTor(); |
|
|
|
boolean orbotChecked = mPreferences.getCheckedForTor(); |
|
|
|
boolean orbot = orbotInstalled && !orbotChecked; |
|
|
|
boolean orbot = orbotInstalled && !orbotChecked; |
|
|
|
|
|
|
|
|
|
|
@ -116,10 +116,8 @@ public class ProxyUtils { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); |
|
|
|
if (!OrbotHelper.isOrbotRunning(activity)) |
|
|
|
if (!oh.isOrbotRunning()) { |
|
|
|
OrbotHelper.requestShowOrbotStart(activity); |
|
|
|
oh.requestOrbotStart(activity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
host = "localhost"; |
|
|
|
host = "localhost"; |
|
|
|
port = 8118; |
|
|
|
port = 8118; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -139,8 +137,7 @@ public class ProxyUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), |
|
|
|
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port); |
|
|
|
host, port); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Log.d(Constants.TAG, "error enabling web proxying", e); |
|
|
|
Log.d(Constants.TAG, "error enabling web proxying", e); |
|
|
|
} |
|
|
|
} |
|
|
@ -165,11 +162,18 @@ public class ProxyUtils { |
|
|
|
if (mPreferences.getUseProxy()) { |
|
|
|
if (mPreferences.getUseProxy()) { |
|
|
|
initializeProxy(activity); |
|
|
|
initializeProxy(activity); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
try { |
|
|
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) { |
|
|
|
WebkitProxy.resetProxy(BrowserApp.class.getName(), |
|
|
|
try { |
|
|
|
activity.getApplicationContext()); |
|
|
|
WebkitProxy.resetProxy(BrowserApp.class.getName(), activity.getApplicationContext()); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
WebkitProxy.resetLollipopProxy(BrowserApp.class.getName(), activity.getApplicationContext()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mI2PProxyInitialized = false; |
|
|
|
mI2PProxyInitialized = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -197,8 +201,7 @@ public class ProxyUtils { |
|
|
|
public int setProxyChoice(int choice, Activity activity) { |
|
|
|
public int setProxyChoice(int choice, Activity activity) { |
|
|
|
switch (choice) { |
|
|
|
switch (choice) { |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext()); |
|
|
|
if (!OrbotHelper.isOrbotInstalled(activity)) { |
|
|
|
if (!oh.isOrbotInstalled()) { |
|
|
|
|
|
|
|
choice = Constants.NO_PROXY; |
|
|
|
choice = Constants.NO_PROXY; |
|
|
|
Utils.showToast(activity, activity.getResources().getString(R.string.install_orbot)); |
|
|
|
Utils.showToast(activity, activity.getResources().getString(R.string.install_orbot)); |
|
|
|
} |
|
|
|
} |
|
|
|