From 678979748585c5903125a404e448ad6c111dedad Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Mon, 7 Apr 2014 09:01:24 +0000 Subject: Revert "Refactor IpConfiguration from WifiConfiguration" This reverts commit 1284767ceb1affa6d5af77fd26ccf7322df48a6d. Change-Id: Ibccea84e5dc44c1b8954779660e0721b27f762d4 --- wifi/java/android/net/wifi/WifiConfiguration.java | 85 +++++++++++++++++++---- 1 file changed, 73 insertions(+), 12 deletions(-) (limited to 'wifi') diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 9b5a0a4..6562462 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -16,7 +16,8 @@ package android.net.wifi; -import android.net.IpConfiguration; +import android.net.LinkProperties; +import android.os.Parcelable; import android.os.Parcel; import android.text.TextUtils; @@ -26,7 +27,7 @@ import java.util.BitSet; * A class representing a configured Wi-Fi network, including the * security configuration. */ -public class WifiConfiguration extends IpConfiguration { +public class WifiConfiguration implements Parcelable { private static final String TAG = "WifiConfiguration"; /** {@hide} */ public static final String ssidVarName = "ssid"; @@ -281,6 +282,50 @@ public class WifiConfiguration extends IpConfiguration { */ public WifiEnterpriseConfig enterpriseConfig; + /** + * @hide + */ + public enum IpAssignment { + /* Use statically configured IP settings. Configuration can be accessed + * with linkProperties */ + STATIC, + /* Use dynamically configured IP settigns */ + DHCP, + /* no IP details are assigned, this is used to indicate + * that any existing IP settings should be retained */ + UNASSIGNED + } + /** + * @hide + */ + public IpAssignment ipAssignment; + + /** + * @hide + */ + public enum ProxySettings { + /* No proxy is to be used. Any existing proxy settings + * should be cleared. */ + NONE, + /* Use statically configured proxy. Configuration can be accessed + * with linkProperties */ + STATIC, + /* no proxy details are assigned, this is used to indicate + * that any existing proxy settings should be retained */ + UNASSIGNED, + /* Use a Pac based proxy. + */ + PAC + } + /** + * @hide + */ + public ProxySettings proxySettings; + /** + * @hide + */ + public LinkProperties linkProperties; + public WifiConfiguration() { networkId = INVALID_NETWORK_ID; SSID = null; @@ -298,6 +343,9 @@ public class WifiConfiguration extends IpConfiguration { wepKeys[i] = null; } enterpriseConfig = new WifiEnterpriseConfig(); + ipAssignment = IpAssignment.UNASSIGNED; + proxySettings = ProxySettings.UNASSIGNED; + linkProperties = new LinkProperties(); } /** @@ -326,7 +374,6 @@ public class WifiConfiguration extends IpConfiguration { @Override public String toString() { StringBuilder sbuf = new StringBuilder(); - if (this.status == WifiConfiguration.Status.CURRENT) { sbuf.append("* "); } else if (this.status == WifiConfiguration.Status.DISABLED) { @@ -401,8 +448,12 @@ public class WifiConfiguration extends IpConfiguration { sbuf.append(enterpriseConfig); sbuf.append('\n'); - // Append IpConfiguration info here to keep old behavior. - sbuf.append(super.toString()); + sbuf.append("IP assignment: " + ipAssignment.toString()); + sbuf.append("\n"); + sbuf.append("Proxy settings: " + proxySettings.toString()); + sbuf.append("\n"); + sbuf.append(linkProperties.toString()); + sbuf.append("\n"); return sbuf.toString(); } @@ -519,10 +570,13 @@ public class WifiConfiguration extends IpConfiguration { return KeyMgmt.NONE; } + /** Implement the Parcelable interface {@hide} */ + public int describeContents() { + return 0; + } + /** copy constructor {@hide} */ public WifiConfiguration(WifiConfiguration source) { - super(source); - if (source != null) { networkId = source.networkId; status = source.status; @@ -546,14 +600,15 @@ public class WifiConfiguration extends IpConfiguration { allowedGroupCiphers = (BitSet) source.allowedGroupCiphers.clone(); enterpriseConfig = new WifiEnterpriseConfig(source.enterpriseConfig); + + ipAssignment = source.ipAssignment; + proxySettings = source.proxySettings; + linkProperties = new LinkProperties(source.linkProperties); } } /** Implement the Parcelable interface {@hide} */ - @Override public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeInt(networkId); dest.writeInt(status); dest.writeInt(disableReason); @@ -574,6 +629,10 @@ public class WifiConfiguration extends IpConfiguration { writeBitSet(dest, allowedGroupCiphers); dest.writeParcelable(enterpriseConfig, flags); + + dest.writeString(ipAssignment.name()); + dest.writeString(proxySettings.name()); + dest.writeParcelable(linkProperties, flags); } /** Implement the Parcelable interface {@hide} */ @@ -581,8 +640,6 @@ public class WifiConfiguration extends IpConfiguration { new Creator() { public WifiConfiguration createFromParcel(Parcel in) { WifiConfiguration config = new WifiConfiguration(); - config.setFromParcel(in); - config.networkId = in.readInt(); config.status = in.readInt(); config.disableReason = in.readInt(); @@ -603,6 +660,10 @@ public class WifiConfiguration extends IpConfiguration { config.enterpriseConfig = in.readParcelable(null); + config.ipAssignment = IpAssignment.valueOf(in.readString()); + config.proxySettings = ProxySettings.valueOf(in.readString()); + config.linkProperties = in.readParcelable(null); + return config; } -- cgit v1.1