use of android.net.ProxyProperties in project android_frameworks_base by ParanoidAndroid.
the class WifiConfigStore method writeIpAndProxyConfigurationsOnChange.
/* Compare current and new configuration and write to file on change */
private NetworkUpdateResult writeIpAndProxyConfigurationsOnChange(WifiConfiguration currentConfig, WifiConfiguration newConfig) {
boolean ipChanged = false;
boolean proxyChanged = false;
LinkProperties linkProperties = null;
switch(newConfig.ipAssignment) {
case STATIC:
Collection<LinkAddress> currentLinkAddresses = currentConfig.linkProperties.getLinkAddresses();
Collection<LinkAddress> newLinkAddresses = newConfig.linkProperties.getLinkAddresses();
Collection<InetAddress> currentDnses = currentConfig.linkProperties.getDnses();
Collection<InetAddress> newDnses = newConfig.linkProperties.getDnses();
Collection<RouteInfo> currentRoutes = currentConfig.linkProperties.getRoutes();
Collection<RouteInfo> newRoutes = newConfig.linkProperties.getRoutes();
boolean linkAddressesDiffer = (currentLinkAddresses.size() != newLinkAddresses.size()) || !currentLinkAddresses.containsAll(newLinkAddresses);
boolean dnsesDiffer = (currentDnses.size() != newDnses.size()) || !currentDnses.containsAll(newDnses);
boolean routesDiffer = (currentRoutes.size() != newRoutes.size()) || !currentRoutes.containsAll(newRoutes);
if ((currentConfig.ipAssignment != newConfig.ipAssignment) || linkAddressesDiffer || dnsesDiffer || routesDiffer) {
ipChanged = true;
}
break;
case DHCP:
if (currentConfig.ipAssignment != newConfig.ipAssignment) {
ipChanged = true;
}
break;
case UNASSIGNED:
/* Ignore */
break;
default:
loge("Ignore invalid ip assignment during write");
break;
}
switch(newConfig.proxySettings) {
case STATIC:
ProxyProperties newHttpProxy = newConfig.linkProperties.getHttpProxy();
ProxyProperties currentHttpProxy = currentConfig.linkProperties.getHttpProxy();
if (newHttpProxy != null) {
proxyChanged = !newHttpProxy.equals(currentHttpProxy);
} else {
proxyChanged = (currentHttpProxy != null);
}
break;
case NONE:
if (currentConfig.proxySettings != newConfig.proxySettings) {
proxyChanged = true;
}
break;
case UNASSIGNED:
/* Ignore */
break;
default:
loge("Ignore invalid proxy configuration during write");
break;
}
if (!ipChanged) {
linkProperties = copyIpSettingsFromConfig(currentConfig);
} else {
currentConfig.ipAssignment = newConfig.ipAssignment;
linkProperties = copyIpSettingsFromConfig(newConfig);
log("IP config changed SSID = " + currentConfig.SSID + " linkProperties: " + linkProperties.toString());
}
if (!proxyChanged) {
linkProperties.setHttpProxy(currentConfig.linkProperties.getHttpProxy());
} else {
currentConfig.proxySettings = newConfig.proxySettings;
linkProperties.setHttpProxy(newConfig.linkProperties.getHttpProxy());
log("proxy changed SSID = " + currentConfig.SSID);
if (linkProperties.getHttpProxy() != null) {
log(" proxyProperties: " + linkProperties.getHttpProxy().toString());
}
}
if (ipChanged || proxyChanged) {
currentConfig.linkProperties = linkProperties;
writeIpAndProxyConfigurations();
sendConfiguredNetworksChangedBroadcast(currentConfig, WifiManager.CHANGE_REASON_CONFIG_CHANGE);
}
return new NetworkUpdateResult(ipChanged, proxyChanged);
}
use of android.net.ProxyProperties in project android_frameworks_base by ParanoidAndroid.
the class WifiConfigStore method clearLinkProperties.
/**
* clear IP configuration for a given network id
* @param network id
*/
void clearLinkProperties(int netId) {
WifiConfiguration config = mConfiguredNetworks.get(netId);
if (config != null && config.linkProperties != null) {
// Clear everything except proxy
ProxyProperties proxy = config.linkProperties.getHttpProxy();
config.linkProperties.clear();
config.linkProperties.setHttpProxy(proxy);
}
}
use of android.net.ProxyProperties in project XobotOS by xamarin.
the class WebView method handleProxyBroadcast.
private static void handleProxyBroadcast(Intent intent) {
ProxyProperties proxyProperties = (ProxyProperties) intent.getExtra(Proxy.EXTRA_PROXY_INFO);
if (proxyProperties == null || proxyProperties.getHost() == null) {
WebViewCore.sendStaticMessage(EventHub.PROXY_CHANGED, null);
return;
}
WebViewCore.sendStaticMessage(EventHub.PROXY_CHANGED, proxyProperties);
}
use of android.net.ProxyProperties in project XobotOS by xamarin.
the class Proxy method getProxy.
/**
* Return the proxy object to be used for the URL given as parameter.
* @param ctx A Context used to get the settings for the proxy host.
* @param url A URL to be accessed. Used to evaluate exclusion list.
* @return Proxy (java.net) object containing the host name. If the
* user did not set a hostname it returns the default host.
* A null value means that no host is to be used.
* {@hide}
*/
public static final java.net.Proxy getProxy(Context ctx, String url) {
String host = "";
if (url != null) {
URI uri = URI.create(url);
host = uri.getHost();
}
if (!isLocalHost(host)) {
if (sConnectivityManager == null) {
sConnectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
}
if (sConnectivityManager == null)
return java.net.Proxy.NO_PROXY;
ProxyProperties proxyProperties = sConnectivityManager.getProxy();
if (proxyProperties != null) {
if (!proxyProperties.isExcluded(host)) {
return proxyProperties.makeProxy();
}
}
}
return java.net.Proxy.NO_PROXY;
}
use of android.net.ProxyProperties in project XobotOS by xamarin.
the class WifiConfigStore method clearIpConfiguration.
/**
* clear IP configuration for a given network id
*/
static void clearIpConfiguration(int netId) {
synchronized (sConfiguredNetworks) {
WifiConfiguration config = sConfiguredNetworks.get(netId);
if (config != null && config.linkProperties != null) {
// Clear everything except proxy
ProxyProperties proxy = config.linkProperties.getHttpProxy();
config.linkProperties.clear();
config.linkProperties.setHttpProxy(proxy);
}
}
}
Aggregations