summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net/wifi/WifiInfo.java
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-02-16 17:31:11 -0800
committerRobert Greenwalt <rgreenwalt@google.com>2011-02-16 17:31:11 -0800
commit124b44d89bc00b150c9478ccddfa83cac0f1df24 (patch)
treeee534768ae116840350a9cd80c2b2fb2be051595 /wifi/java/android/net/wifi/WifiInfo.java
parent83361072e7d5e66bf1438e413d1b1645a6e13a47 (diff)
downloadframeworks_base-124b44d89bc00b150c9478ccddfa83cac0f1df24.zip
frameworks_base-124b44d89bc00b150c9478ccddfa83cac0f1df24.tar.gz
frameworks_base-124b44d89bc00b150c9478ccddfa83cac0f1df24.tar.bz2
Make WifiInfo not use int for ip address.
Change-Id: Ib27824cd0722099e157024ee2a9797236157bc8e
Diffstat (limited to 'wifi/java/android/net/wifi/WifiInfo.java')
-rw-r--r--wifi/java/android/net/wifi/WifiInfo.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java
index 4312bfd..f60ae48 100644
--- a/wifi/java/android/net/wifi/WifiInfo.java
+++ b/wifi/java/android/net/wifi/WifiInfo.java
@@ -19,7 +19,11 @@ package android.net.wifi;
import android.os.Parcelable;
import android.os.Parcel;
import android.net.NetworkInfo.DetailedState;
+import android.net.NetworkUtils;
+import java.net.InetAddress;
+import java.net.Inet6Address;
+import java.net.UnknownHostException;
import java.util.EnumMap;
/**
@@ -61,7 +65,7 @@ public class WifiInfo implements Parcelable {
public static final String LINK_SPEED_UNITS = "Mbps";
private int mLinkSpeed;
- private int mIpAddress;
+ private InetAddress mIpAddress;
private String mMacAddress;
@@ -72,7 +76,6 @@ public class WifiInfo implements Parcelable {
mSupplicantState = SupplicantState.UNINITIALIZED;
mRssi = -9999;
mLinkSpeed = -1;
- mIpAddress = 0;
mHiddenSSID = false;
}
@@ -172,12 +175,13 @@ public class WifiInfo implements Parcelable {
mSupplicantState = state;
}
- void setIpAddress(int address) {
+ void setInetAddress(InetAddress address) {
mIpAddress = address;
}
public int getIpAddress() {
- return mIpAddress;
+ if (mIpAddress == null || mIpAddress instanceof Inet6Address) return 0;
+ return NetworkUtils.inetAddressToInt(mIpAddress);
}
/**
@@ -251,7 +255,12 @@ public class WifiInfo implements Parcelable {
dest.writeInt(mNetworkId);
dest.writeInt(mRssi);
dest.writeInt(mLinkSpeed);
- dest.writeInt(mIpAddress);
+ if (mIpAddress != null) {
+ dest.writeByte((byte)1);
+ dest.writeByteArray(mIpAddress.getAddress());
+ } else {
+ dest.writeByte((byte)0);
+ }
dest.writeString(getSSID());
dest.writeString(mBSSID);
dest.writeString(mMacAddress);
@@ -266,7 +275,11 @@ public class WifiInfo implements Parcelable {
info.setNetworkId(in.readInt());
info.setRssi(in.readInt());
info.setLinkSpeed(in.readInt());
- info.setIpAddress(in.readInt());
+ if (in.readByte() == 1) {
+ try {
+ info.setInetAddress(InetAddress.getByAddress(in.createByteArray()));
+ } catch (UnknownHostException e) {}
+ }
info.setSSID(in.readString());
info.mBSSID = in.readString();
info.mMacAddress = in.readString();