use of android.net.ProxyInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiConfigController method showProxyFields.
private void showProxyFields() {
WifiConfiguration config = null;
mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE);
if (mAccessPoint != null && mAccessPoint.isSaved()) {
config = mAccessPoint.getConfig();
}
if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
setVisibility(R.id.proxy_warning_limited_support, View.VISIBLE);
setVisibility(R.id.proxy_fields, View.VISIBLE);
setVisibility(R.id.proxy_pac_field, View.GONE);
if (mProxyHostView == null) {
mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname);
mProxyHostView.addTextChangedListener(this);
mProxyPortView = (TextView) mView.findViewById(R.id.proxy_port);
mProxyPortView.addTextChangedListener(this);
mProxyExclusionListView = (TextView) mView.findViewById(R.id.proxy_exclusionlist);
mProxyExclusionListView.addTextChangedListener(this);
}
if (config != null) {
ProxyInfo proxyProperties = config.getHttpProxy();
if (proxyProperties != null) {
mProxyHostView.setText(proxyProperties.getHost());
mProxyPortView.setText(Integer.toString(proxyProperties.getPort()));
mProxyExclusionListView.setText(proxyProperties.getExclusionListAsString());
}
}
} else if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_PAC) {
setVisibility(R.id.proxy_warning_limited_support, View.GONE);
setVisibility(R.id.proxy_fields, View.GONE);
setVisibility(R.id.proxy_pac_field, View.VISIBLE);
if (mProxyPacView == null) {
mProxyPacView = (TextView) mView.findViewById(R.id.proxy_pac);
mProxyPacView.addTextChangedListener(this);
}
if (config != null) {
ProxyInfo proxyInfo = config.getHttpProxy();
if (proxyInfo != null) {
mProxyPacView.setText(proxyInfo.getPacFileUrl().toString());
}
}
} else {
setVisibility(R.id.proxy_warning_limited_support, View.GONE);
setVisibility(R.id.proxy_fields, View.GONE);
setVisibility(R.id.proxy_pac_field, View.GONE);
}
}
use of android.net.ProxyInfo in project AgentWeb by Justson.
the class WebViewProxySettings method printProxy.
/**
* 打印系统代理设置
*
* @param context
*/
private static void printProxy(Context context) {
StringBuilder sb = new StringBuilder();
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
ProxyInfo proxyInfo = (ProxyInfo) invokeMethod(cm, "getGlobalProxy", null);
sb.append("\nconnectivityManager.getGlobalProxy.proxyInfo = " + proxyInfo);
sb.append("\nProxy.getDefaultHost():Proxy.getDefaultPort() = " + Proxy.getDefaultHost() + ":" + Proxy.getDefaultPort());
sb.append("\nSystem.getProperty(\"http.proxyHost\"):System.getProperty(\"http.proxyPort\") = " + System.getProperty("http.proxyHost") + ":" + System.getProperty("http.proxyPort"));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
String host = (String) invokeStaticMethod("android.net.ProxyProperties", "getHost", null);
int port = (int) invokeStaticMethod("android.net.ProxyProperties", "getPort", null);
sb.append("\nProxyProperties.getHost():ProxyProperties.getPort() = " + host + ":" + port);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Uri.parse("content://telephony/carriers"), null, " apn = ? and current = 1", null, null);
if (cursor != null && cursor.moveToFirst()) {
cursor.moveToFirst();
String apn = cursor.getString(cursor.getColumnIndex("apn"));
String proxy = cursor.getString(cursor.getColumnIndex("proxy"));
int port = cursor.getInt(cursor.getColumnIndex("port"));
sb.append("\nAPN:proxy:port = " + apn + ":" + proxy + ":" + port);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
if (DEBUG) {
Log.d(TAG, "printProxy.proxy: " + sb);
}
}
use of android.net.ProxyInfo in project android_frameworks_base by ResurrectionRemix.
the class PacManager method sendProxyIfNeeded.
private synchronized void sendProxyIfNeeded() {
if (!mHasDownloaded || (mLastPort == -1)) {
return;
}
if (!mHasSentBroadcast) {
sendPacBroadcast(new ProxyInfo(mPacUrl, mLastPort));
mHasSentBroadcast = true;
}
}
use of android.net.ProxyInfo in project android_frameworks_base by crdroidandroid.
the class ConnectivityService method getProxyForNetwork.
@Override
public ProxyInfo getProxyForNetwork(Network network) {
if (network == null)
return getDefaultProxy();
final ProxyInfo globalProxy = getGlobalProxy();
if (globalProxy != null)
return globalProxy;
if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId))
return null;
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
// caller may not have.
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai == null)
return null;
synchronized (nai) {
final ProxyInfo proxyInfo = nai.linkProperties.getHttpProxy();
if (proxyInfo == null)
return null;
return new ProxyInfo(proxyInfo);
}
}
use of android.net.ProxyInfo in project android_frameworks_base by crdroidandroid.
the class ConnectivityService method updateProxy.
// If the proxy has changed from oldLp to newLp, resend proxy broadcast with default proxy.
// This method gets called when any network changes proxy, but the broadcast only ever contains
// the default proxy (even if it hasn't changed).
// TODO: Deprecate the broadcast extras as they aren't necessarily applicable in a multi-network
// world where an app might be bound to a non-default network.
private void updateProxy(LinkProperties newLp, LinkProperties oldLp, NetworkAgentInfo nai) {
ProxyInfo newProxyInfo = newLp == null ? null : newLp.getHttpProxy();
ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy();
if (!proxyInfoEqual(newProxyInfo, oldProxyInfo)) {
sendProxyBroadcast(getDefaultProxy());
}
}
Aggregations