Search in sources :

Example 46 with StaticIpConfiguration

use of android.net.StaticIpConfiguration in project android_frameworks_base by ResurrectionRemix.

the class StaticIpConfigurationTest method testCopyAndClear.

@SmallTest
public void testCopyAndClear() {
    StaticIpConfiguration empty = new StaticIpConfiguration((StaticIpConfiguration) null);
    checkEmpty(empty);
    StaticIpConfiguration s1 = makeTestObject();
    StaticIpConfiguration s2 = new StaticIpConfiguration(s1);
    assertEquals(s1, s2);
    s2.clear();
    assertEquals(empty, s2);
}
Also used : StaticIpConfiguration(android.net.StaticIpConfiguration) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 47 with StaticIpConfiguration

use of android.net.StaticIpConfiguration in project android_frameworks_base by ResurrectionRemix.

the class StaticIpConfigurationTest method passThroughParcel.

private StaticIpConfiguration passThroughParcel(StaticIpConfiguration s) {
    Parcel p = Parcel.obtain();
    StaticIpConfiguration s2 = null;
    try {
        s.writeToParcel(p, 0);
        p.setDataPosition(0);
        s2 = StaticIpConfiguration.CREATOR.createFromParcel(p);
    } finally {
        p.recycle();
    }
    assertNotNull(s2);
    return s2;
}
Also used : Parcel(android.os.Parcel) StaticIpConfiguration(android.net.StaticIpConfiguration)

Example 48 with StaticIpConfiguration

use of android.net.StaticIpConfiguration in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiConfigController method ipAndProxyFieldsAreValid.

private boolean ipAndProxyFieldsAreValid() {
    mIpAssignment = (mIpSettingsSpinner != null && mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) ? IpAssignment.STATIC : IpAssignment.DHCP;
    if (mIpAssignment == IpAssignment.STATIC) {
        mStaticIpConfiguration = new StaticIpConfiguration();
        int result = validateIpConfigFields(mStaticIpConfiguration);
        if (result != 0) {
            return false;
        }
    }
    final int selectedPosition = mProxySettingsSpinner.getSelectedItemPosition();
    mProxySettings = ProxySettings.NONE;
    mHttpProxy = null;
    if (selectedPosition == PROXY_STATIC && mProxyHostView != null) {
        mProxySettings = ProxySettings.STATIC;
        String host = mProxyHostView.getText().toString();
        String portStr = mProxyPortView.getText().toString();
        String exclusionList = mProxyExclusionListView.getText().toString();
        int port = 0;
        int result = 0;
        try {
            port = Integer.parseInt(portStr);
            result = ProxySelector.validate(host, portStr, exclusionList);
        } catch (NumberFormatException e) {
            result = R.string.proxy_error_invalid_port;
        }
        if (result == 0) {
            mHttpProxy = new ProxyInfo(host, port, exclusionList);
        } else {
            return false;
        }
    } else if (selectedPosition == PROXY_PAC && mProxyPacView != null) {
        mProxySettings = ProxySettings.PAC;
        CharSequence uriSequence = mProxyPacView.getText();
        if (TextUtils.isEmpty(uriSequence)) {
            return false;
        }
        Uri uri = Uri.parse(uriSequence.toString());
        if (uri == null) {
            return false;
        }
        mHttpProxy = new ProxyInfo(uri);
    }
    return true;
}
Also used : ProxyInfo(android.net.ProxyInfo) StaticIpConfiguration(android.net.StaticIpConfiguration) Uri(android.net.Uri) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 49 with StaticIpConfiguration

use of android.net.StaticIpConfiguration in project android_frameworks_base by crdroidandroid.

the class StaticIpConfigurationTest method testToLinkProperties.

@SmallTest
public void testToLinkProperties() {
    LinkProperties expected = new LinkProperties();
    expected.setInterfaceName(IFACE);
    StaticIpConfiguration s = new StaticIpConfiguration();
    assertEquals(expected, s.toLinkProperties(IFACE));
    final RouteInfo connectedRoute = new RouteInfo(new IpPrefix(ADDRSTR), null, IFACE);
    s.ipAddress = ADDR;
    expected.addLinkAddress(ADDR);
    expected.addRoute(connectedRoute);
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.gateway = GATEWAY;
    RouteInfo defaultRoute = new RouteInfo(new IpPrefix("0.0.0.0/0"), GATEWAY, IFACE);
    expected.addRoute(defaultRoute);
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.gateway = OFFLINKGATEWAY;
    expected.removeRoute(defaultRoute);
    defaultRoute = new RouteInfo(new IpPrefix("0.0.0.0/0"), OFFLINKGATEWAY, IFACE);
    expected.addRoute(defaultRoute);
    RouteInfo gatewayRoute = new RouteInfo(new IpPrefix("192.0.2.129/32"), null, IFACE);
    expected.addRoute(gatewayRoute);
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.dnsServers.add(DNS1);
    expected.addDnsServer(DNS1);
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.dnsServers.add(DNS2);
    s.dnsServers.add(DNS3);
    expected.addDnsServer(DNS2);
    expected.addDnsServer(DNS3);
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.domains = "google.com";
    expected.setDomains("google.com");
    assertEquals(expected, s.toLinkProperties(IFACE));
    s.gateway = null;
    expected.removeRoute(defaultRoute);
    expected.removeRoute(gatewayRoute);
    assertEquals(expected, s.toLinkProperties(IFACE));
    // Without knowing the IP address, we don't have a directly-connected route, so we can't
    // tell if the gateway is off-link or not and we don't add a host route. This isn't a real
    // configuration, but we should at least not crash.
    s.gateway = OFFLINKGATEWAY;
    s.ipAddress = null;
    expected.removeLinkAddress(ADDR);
    expected.removeRoute(connectedRoute);
    expected.addRoute(defaultRoute);
    assertEquals(expected, s.toLinkProperties(IFACE));
}
Also used : IpPrefix(android.net.IpPrefix) StaticIpConfiguration(android.net.StaticIpConfiguration) RouteInfo(android.net.RouteInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 50 with StaticIpConfiguration

use of android.net.StaticIpConfiguration in project android_frameworks_base by crdroidandroid.

the class StaticIpConfigurationTest method testConstructor.

@SmallTest
public void testConstructor() {
    StaticIpConfiguration s = new StaticIpConfiguration();
    checkEmpty(s);
}
Also used : StaticIpConfiguration(android.net.StaticIpConfiguration) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

StaticIpConfiguration (android.net.StaticIpConfiguration)52 SmallTest (android.test.suitebuilder.annotation.SmallTest)25 LinkAddress (android.net.LinkAddress)20 InetAddress (java.net.InetAddress)16 ProxyInfo (android.net.ProxyInfo)11 RouteInfo (android.net.RouteInfo)10 WifiConfiguration (android.net.wifi.WifiConfiguration)6 IpConfiguration (android.net.IpConfiguration)5 IpAssignment (android.net.IpConfiguration.IpAssignment)5 ProxySettings (android.net.IpConfiguration.ProxySettings)5 IpPrefix (android.net.IpPrefix)5 Parcel (android.os.Parcel)5 SparseArray (android.util.SparseArray)5 DataInputStream (java.io.DataInputStream)5 EOFException (java.io.EOFException)5 IOException (java.io.IOException)5 Inet4Address (java.net.Inet4Address)5 HashSet (java.util.HashSet)5 BufferedInputStream (java.io.BufferedInputStream)4 FileInputStream (java.io.FileInputStream)4