diff options
-rw-r--r-- | core/java/android/bluetooth/BluetoothTetheringDataTracker.java | 19 | ||||
-rw-r--r-- | core/java/android/net/DhcpInfoInternal.java | 87 | ||||
-rw-r--r-- | core/java/android/net/NetworkUtils.java | 25 | ||||
-rw-r--r-- | core/jni/android_net_NetUtils.cpp | 71 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 34 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 47 |
6 files changed, 190 insertions, 93 deletions
diff --git a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java index 7b083f1..aa1adcb 100644 --- a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java +++ b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java @@ -18,7 +18,7 @@ package android.bluetooth; import android.content.Context; import android.net.ConnectivityManager; -import android.net.DhcpInfo; +import android.net.DhcpInfoInternal; import android.net.LinkAddress; import android.net.LinkCapabilities; import android.net.LinkProperties; @@ -251,23 +251,12 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker { public void run() { //TODO(): Add callbacks for failure and success case. //Currently this thread runs independently. - DhcpInfo dhcpInfo = new DhcpInfo(); - if (!NetworkUtils.runDhcp(mIface, dhcpInfo)) { + DhcpInfoInternal dhcpInfoInternal = new DhcpInfoInternal(); + if (!NetworkUtils.runDhcp(mIface, dhcpInfoInternal)) { Log.e(TAG, "DHCP request error:" + NetworkUtils.getDhcpError()); return; } - mLinkProperties.addLinkAddress(new LinkAddress( - NetworkUtils.intToInetAddress(dhcpInfo.ipAddress), - NetworkUtils.intToInetAddress(dhcpInfo.netmask))); - mLinkProperties.setGateway(NetworkUtils.intToInetAddress(dhcpInfo.gateway)); - InetAddress dns1Addr = NetworkUtils.intToInetAddress(dhcpInfo.dns1); - if (dns1Addr == null || dns1Addr.equals("0.0.0.0")) { - mLinkProperties.addDns(dns1Addr); - } - InetAddress dns2Addr = NetworkUtils.intToInetAddress(dhcpInfo.dns2); - if (dns2Addr == null || dns2Addr.equals("0.0.0.0")) { - mLinkProperties.addDns(dns2Addr); - } + mLinkProperties = dhcpInfoInternal.makeLinkProperties(); mLinkProperties.setInterfaceName(mIface); mNetworkInfo.setIsAvailable(true); diff --git a/core/java/android/net/DhcpInfoInternal.java b/core/java/android/net/DhcpInfoInternal.java new file mode 100644 index 0000000..7d9bd52 --- /dev/null +++ b/core/java/android/net/DhcpInfoInternal.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +import java.net.InetAddress; +import java.net.Inet4Address; +import java.net.UnknownHostException; + +/** + * A simple object for retrieving the results of a DHCP request. + * Replaces (internally) the IPv4-only DhcpInfo class. + * @hide + */ +public class DhcpInfoInternal { + public String ipAddress; + public String gateway; + public int prefixLength; + + public String dns1; + public String dns2; + + public String serverAddress; + public int leaseDuration; + + public DhcpInfoInternal() { + } + + private int convertToInt(String addr) { + try { + InetAddress inetAddress = NetworkUtils.numericToInetAddress(addr); + if (inetAddress instanceof Inet4Address) { + return NetworkUtils.inetAddressToInt(inetAddress); + } + } catch (IllegalArgumentException e) {} + return 0; + } + + public DhcpInfo makeDhcpInfo() { + DhcpInfo info = new DhcpInfo(); + info.ipAddress = convertToInt(ipAddress); + info.gateway = convertToInt(gateway); + try { + InetAddress inetAddress = NetworkUtils.numericToInetAddress(ipAddress); + info.netmask = NetworkUtils.prefixLengthToNetmaskInt(prefixLength); + } catch (IllegalArgumentException e) {} + info.dns1 = convertToInt(dns1); + info.dns2 = convertToInt(dns2); + info.serverAddress = convertToInt(serverAddress); + info.leaseDuration = leaseDuration; + return info; + } + + public LinkAddress makeLinkAddress() { + return new LinkAddress(NetworkUtils.numericToInetAddress(ipAddress), prefixLength); + } + + public LinkProperties makeLinkProperties() { + LinkProperties p = new LinkProperties(); + p.addLinkAddress(makeLinkAddress()); + p.setGateway(NetworkUtils.numericToInetAddress(gateway)); + p.addDns(NetworkUtils.numericToInetAddress(dns1)); + p.addDns(NetworkUtils.numericToInetAddress(dns2)); + return p; + } + + public String toString() { + return "addr: " + ipAddress + "/" + prefixLength + + " gateway: " + gateway + + " dns: " + dns1 + "," + dns2 + + " dhcpServer: " + serverAddress + + " leaseDuration: " + leaseDuration; + } +} diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index b0c974c..1c48e7d 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -77,7 +77,7 @@ public class NetworkUtils { * the IP address information. * @return {@code true} for success, {@code false} for failure */ - public native static boolean runDhcp(String interfaceName, DhcpInfo ipInfo); + public native static boolean runDhcp(String interfaceName, DhcpInfoInternal ipInfo); /** * Shut down the DHCP client daemon. @@ -150,6 +150,29 @@ public class NetworkUtils { } /** + * Create an InetAddress from a string where the string must be a standard + * representation of a V4 or V6 address. Avoids doing a DNS lookup on failure + * but it will throw an IllegalArgumentException in that case. + * @param addrString + * @return the InetAddress + * @hide + */ + public static InetAddress numericToInetAddress(String addrString) + throws IllegalArgumentException { + // TODO - do this for real, using a hidden method on InetAddress that aborts + // instead of doing dns step + if (!InetAddress.isNumeric(addrString)) { + throw new IllegalArgumentException("numericToInetAddress with non numeric: " + + addrString); + } + try { + return InetAddress.getByName(addrString); + } catch (UnknownHostException e) { + throw new IllegalArgumentException(e); + } + } + + /** * Add a default route through the specified gateway. * @param interfaceName interface on which the route should be added * @param gw the IP address of the gateway to which the route is desired, diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index f658479..3adf770 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -21,6 +21,7 @@ #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> #include <arpa/inet.h> +#include <cutils/properties.h> extern "C" { int ifc_enable(const char *ifname); @@ -32,12 +33,12 @@ int ifc_remove_default_route(const char *ifname); int ifc_reset_connections(const char *ifname); int dhcp_do_request(const char *ifname, - in_addr_t *ipaddr, - in_addr_t *gateway, - in_addr_t *mask, - in_addr_t *dns1, - in_addr_t *dns2, - in_addr_t *server, + const char *ipaddr, + const char *gateway, + uint32_t *prefixLength, + const char *dns1, + const char *dns2, + const char *server, uint32_t *lease); int dhcp_stop(const char *ifname); int dhcp_release_lease(const char *ifname); @@ -54,16 +55,16 @@ namespace android { * to look them up every time. */ static struct fieldIds { - jclass dhcpInfoClass; + jclass dhcpInfoInternalClass; jmethodID constructorId; jfieldID ipaddress; jfieldID gateway; - jfieldID netmask; + jfieldID prefixLength; jfieldID dns1; jfieldID dns2; jfieldID serverAddress; jfieldID leaseDuration; -} dhcpInfoFieldIds; +} dhcpInfoInternalFieldIds; static jint android_net_utils_enableInterface(JNIEnv* env, jobject clazz, jstring ifname) { @@ -148,21 +149,29 @@ static jint android_net_utils_resetConnections(JNIEnv* env, jobject clazz, jstri static jboolean android_net_utils_runDhcp(JNIEnv* env, jobject clazz, jstring ifname, jobject info) { int result; - in_addr_t ipaddr, gateway, mask, dns1, dns2, server; + char ipaddr[PROPERTY_VALUE_MAX]; + uint32_t prefixLength; + char gateway[PROPERTY_VALUE_MAX]; + char dns1[PROPERTY_VALUE_MAX]; + char dns2[PROPERTY_VALUE_MAX]; + char server[PROPERTY_VALUE_MAX]; uint32_t lease; const char *nameStr = env->GetStringUTFChars(ifname, NULL); - result = ::dhcp_do_request(nameStr, &ipaddr, &gateway, &mask, - &dns1, &dns2, &server, &lease); + if (nameStr == NULL) return (jboolean)false; + + result = ::dhcp_do_request(nameStr, ipaddr, gateway, &prefixLength, + dns1, dns2, server, &lease); env->ReleaseStringUTFChars(ifname, nameStr); - if (result == 0 && dhcpInfoFieldIds.dhcpInfoClass != NULL) { - env->SetIntField(info, dhcpInfoFieldIds.ipaddress, ipaddr); - env->SetIntField(info, dhcpInfoFieldIds.gateway, gateway); - env->SetIntField(info, dhcpInfoFieldIds.netmask, mask); - env->SetIntField(info, dhcpInfoFieldIds.dns1, dns1); - env->SetIntField(info, dhcpInfoFieldIds.dns2, dns2); - env->SetIntField(info, dhcpInfoFieldIds.serverAddress, server); - env->SetIntField(info, dhcpInfoFieldIds.leaseDuration, lease); + if (result == 0 && dhcpInfoInternalFieldIds.dhcpInfoInternalClass != NULL) { + env->SetObjectField(info, dhcpInfoInternalFieldIds.ipaddress, env->NewStringUTF(ipaddr)); + env->SetObjectField(info, dhcpInfoInternalFieldIds.gateway, env->NewStringUTF(gateway)); + env->SetIntField(info, dhcpInfoInternalFieldIds.prefixLength, prefixLength); + env->SetObjectField(info, dhcpInfoInternalFieldIds.dns1, env->NewStringUTF(dns1)); + env->SetObjectField(info, dhcpInfoInternalFieldIds.dns2, env->NewStringUTF(dns2)); + env->SetObjectField(info, dhcpInfoInternalFieldIds.serverAddress, + env->NewStringUTF(server)); + env->SetIntField(info, dhcpInfoInternalFieldIds.leaseDuration, lease); } return (jboolean)(result == 0); } @@ -209,7 +218,7 @@ static JNINativeMethod gNetworkUtilMethods[] = { (void *)android_net_utils_getDefaultRoute }, { "removeDefaultRoute", "(Ljava/lang/String;)I", (void *)android_net_utils_removeDefaultRoute }, { "resetConnections", "(Ljava/lang/String;)I", (void *)android_net_utils_resetConnections }, - { "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpInfo;)Z", (void *)android_net_utils_runDhcp }, + { "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcp }, { "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp }, { "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease }, { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError }, @@ -220,16 +229,16 @@ int register_android_net_NetworkUtils(JNIEnv* env) jclass netutils = env->FindClass(NETUTILS_PKG_NAME); LOG_FATAL_IF(netutils == NULL, "Unable to find class " NETUTILS_PKG_NAME); - dhcpInfoFieldIds.dhcpInfoClass = env->FindClass("android/net/DhcpInfo"); - if (dhcpInfoFieldIds.dhcpInfoClass != NULL) { - dhcpInfoFieldIds.constructorId = env->GetMethodID(dhcpInfoFieldIds.dhcpInfoClass, "<init>", "()V"); - dhcpInfoFieldIds.ipaddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "ipAddress", "I"); - dhcpInfoFieldIds.gateway = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "gateway", "I"); - dhcpInfoFieldIds.netmask = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "netmask", "I"); - dhcpInfoFieldIds.dns1 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns1", "I"); - dhcpInfoFieldIds.dns2 = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "dns2", "I"); - dhcpInfoFieldIds.serverAddress = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "serverAddress", "I"); - dhcpInfoFieldIds.leaseDuration = env->GetFieldID(dhcpInfoFieldIds.dhcpInfoClass, "leaseDuration", "I"); + dhcpInfoInternalFieldIds.dhcpInfoInternalClass = env->FindClass("android/net/DhcpInfoInternal"); + if (dhcpInfoInternalFieldIds.dhcpInfoInternalClass != NULL) { + dhcpInfoInternalFieldIds.constructorId = env->GetMethodID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "<init>", "()V"); + dhcpInfoInternalFieldIds.ipaddress = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "ipAddress", "Ljava/lang/String;"); + dhcpInfoInternalFieldIds.gateway = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "gateway", "Ljava/lang/String;"); + dhcpInfoInternalFieldIds.prefixLength = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "prefixLength", "I"); + dhcpInfoInternalFieldIds.dns1 = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "dns1", "Ljava/lang/String;"); + dhcpInfoInternalFieldIds.dns2 = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "dns2", "Ljava/lang/String;"); + dhcpInfoInternalFieldIds.serverAddress = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "serverAddress", "Ljava/lang/String;"); + dhcpInfoInternalFieldIds.leaseDuration = env->GetFieldID(dhcpInfoInternalFieldIds.dhcpInfoInternalClass, "leaseDuration", "I"); } return AndroidRuntime::registerNativeMethods(env, diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index 73c24cf..55d1844 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -18,7 +18,7 @@ package android.net.wifi; import android.content.Context; import android.content.Intent; -import android.net.DhcpInfo; +import android.net.DhcpInfoInternal; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NetworkUtils; @@ -436,35 +436,25 @@ class WifiConfigStore { * that, we should remove handling DhcpInfo and move * to using LinkProperties */ - static DhcpInfo getIpConfiguration(int netId) { - DhcpInfo dhcpInfo = new DhcpInfo(); + static DhcpInfoInternal getIpConfiguration(int netId) { + DhcpInfoInternal dhcpInfoInternal = new DhcpInfoInternal(); LinkProperties linkProperties = getLinkProperties(netId); if (linkProperties != null) { Iterator<LinkAddress> iter = linkProperties.getLinkAddresses().iterator(); if (iter.hasNext()) { - try { - LinkAddress linkAddress = iter.next(); - dhcpInfo.ipAddress = NetworkUtils.inetAddressToInt( - linkAddress.getAddress()); - dhcpInfo.gateway = NetworkUtils.inetAddressToInt( - linkProperties.getGateway()); - dhcpInfo.netmask = NetworkUtils.prefixLengthToNetmaskInt( - linkAddress.getNetworkPrefixLength()); - Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator(); - dhcpInfo.dns1 = NetworkUtils.inetAddressToInt(dnsIterator.next()); - if (dnsIterator.hasNext()) { - dhcpInfo.dns2 = NetworkUtils.inetAddressToInt(dnsIterator.next()); - } - } catch (IllegalArgumentException e1) { - Log.e(TAG, "IPv6 address cannot be handled " + e1); - } catch (NullPointerException e2) { - /* Should not happen since a stored static config should be valid */ - Log.e(TAG, "Invalid partial IP configuration " + e2); + LinkAddress linkAddress = iter.next(); + dhcpInfoInternal.ipAddress = linkAddress.getAddress().getHostAddress(); + dhcpInfoInternal.gateway = linkProperties.getGateway().getHostAddress(); + dhcpInfoInternal.prefixLength = linkAddress.getNetworkPrefixLength(); + Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator(); + dhcpInfoInternal.dns1 = dnsIterator.next().getHostAddress(); + if (dnsIterator.hasNext()) { + dhcpInfoInternal.dns2 = dnsIterator.next().getHostAddress(); } } } - return dhcpInfo; + return dhcpInfoInternal; } /** diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 42a27d1..f0d26d1 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -42,6 +42,7 @@ import android.app.PendingIntent; import android.net.LinkAddress; import android.net.NetworkInfo; import android.net.DhcpInfo; +import android.net.DhcpInfoInternal; import android.net.NetworkUtils; import android.net.ConnectivityManager; import android.net.InterfaceConfiguration; @@ -146,7 +147,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { private Context mContext; - private DhcpInfo mDhcpInfo; + private DhcpInfoInternal mDhcpInfoInternal; private WifiInfo mWifiInfo; private NetworkInfo mNetworkInfo; private SupplicantStateTracker mSupplicantStateTracker; @@ -450,7 +451,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { nwService = INetworkManagementService.Stub.asInterface(b); mWifiMonitor = new WifiMonitor(this); - mDhcpInfo = new DhcpInfo(); + mDhcpInfoInternal = new DhcpInfoInternal(); mWifiInfo = new WifiInfo(); mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0"); mSupplicantStateTracker = new SupplicantStateTracker(context, this, getHandler()); @@ -654,8 +655,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { } public DhcpInfo syncGetDhcpInfo() { - synchronized (mDhcpInfo) { - return new DhcpInfo(mDhcpInfo); + synchronized (mDhcpInfoInternal) { + return mDhcpInfoInternal.makeDhcpInfo(); } } @@ -971,7 +972,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { sb.append("current HSM state: ").append(getCurrentState().getName()).append(LS); sb.append("mLinkProperties ").append(mLinkProperties).append(LS); sb.append("mWifiInfo ").append(mWifiInfo).append(LS); - sb.append("mDhcpInfo ").append(mDhcpInfo).append(LS); + sb.append("mDhcpInfoInternal ").append(mDhcpInfoInternal).append(LS); sb.append("mNetworkInfo ").append(mNetworkInfo).append(LS); sb.append("mLastSignalLevel ").append(mLastSignalLevel).append(LS); sb.append("mLastBssid ").append(mLastBssid).append(LS); @@ -1307,14 +1308,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { if (WifiConfigStore.isUsingStaticIp(mLastNetworkId)) { mLinkProperties = WifiConfigStore.getLinkProperties(mLastNetworkId); } else { - // TODO - fix this for v6 - synchronized (mDhcpInfo) { - mLinkProperties.addLinkAddress(new LinkAddress( - NetworkUtils.intToInetAddress(mDhcpInfo.ipAddress), - NetworkUtils.intToInetAddress(mDhcpInfo.netmask))); - mLinkProperties.setGateway(NetworkUtils.intToInetAddress(mDhcpInfo.gateway)); - mLinkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns1)); - mLinkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns2)); + synchronized (mDhcpInfoInternal) { + mLinkProperties = mDhcpInfoInternal.makeLinkProperties(); } mLinkProperties.setHttpProxy(WifiConfigStore.getProxyProperties(mLastNetworkId)); } @@ -2513,11 +2508,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { Log.d(TAG, "DHCP request started"); mDhcpThread = new Thread(new Runnable() { public void run() { - DhcpInfo dhcpInfo = new DhcpInfo(); - if (NetworkUtils.runDhcp(mInterfaceName, dhcpInfo)) { + DhcpInfoInternal dhcpInfoInternal = new DhcpInfoInternal(); + if (NetworkUtils.runDhcp(mInterfaceName, dhcpInfoInternal)) { Log.d(TAG, "DHCP request succeeded"); - synchronized (mDhcpInfo) { - mDhcpInfo = dhcpInfo; + synchronized (mDhcpInfoInternal) { + mDhcpInfoInternal = dhcpInfoInternal; } sendMessage(CMD_IP_CONFIG_SUCCESS); } else { @@ -2529,18 +2524,20 @@ public class WifiStateMachine extends HierarchicalStateMachine { }); mDhcpThread.start(); } else { - DhcpInfo dhcpInfo = WifiConfigStore.getIpConfiguration(mLastNetworkId); + DhcpInfoInternal dhcpInfoInternal = WifiConfigStore.getIpConfiguration( + mLastNetworkId); IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); INetworkManagementService netd = INetworkManagementService.Stub.asInterface(b); InterfaceConfiguration ifcg = new InterfaceConfiguration(); + ifcg.addr = NetworkUtils.numericToInetAddress(dhcpInfoInternal.ipAddress); + ifcg.mask = NetworkUtils.intToInetAddress( + NetworkUtils.prefixLengthToNetmaskInt(dhcpInfoInternal.prefixLength)); ifcg.interfaceFlags = "[up]"; - ifcg.addr = NetworkUtils.intToInetAddress(dhcpInfo.ipAddress); - ifcg.mask = NetworkUtils.intToInetAddress(dhcpInfo.netmask); try { netd.setInterfaceConfig(mInterfaceName, ifcg); Log.v(TAG, "Static IP configuration succeeded"); - synchronized (mDhcpInfo) { - mDhcpInfo = dhcpInfo; + synchronized (mDhcpInfoInternal) { + mDhcpInfoInternal = dhcpInfoInternal; } sendMessage(CMD_IP_CONFIG_SUCCESS); } catch (RemoteException re) { @@ -2559,9 +2556,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { switch(message.what) { case CMD_IP_CONFIG_SUCCESS: mLastSignalLevel = -1; // force update of signal strength - synchronized (mDhcpInfo) { - mWifiInfo.setIpAddress(mDhcpInfo.ipAddress); + InetAddress addr; + synchronized (mDhcpInfoInternal) { + addr = NetworkUtils.numericToInetAddress(mDhcpInfoInternal.ipAddress); } + mWifiInfo.setIpAddress(NetworkUtils.inetAddressToInt(addr)); configureLinkProperties(); if (getNetworkDetailedState() == DetailedState.CONNECTED) { sendLinkConfigurationChangedBroadcast(); |