diff options
| author | Robert Greenwalt <robdroid@android.com> | 2010-08-30 10:56:47 -0700 |
|---|---|---|
| committer | Robert Greenwalt <rgreenwalt@google.com> | 2010-08-30 15:54:37 -0700 |
| commit | 37e65ebb7eb932e1a144b1cab262e11ca5fd109b (patch) | |
| tree | 8778822097d0ab67bc0a4c222cd7e01d2ade9082 | |
| parent | e82235ae7049badf6758ffef3c13080b135986f4 (diff) | |
| download | frameworks_base-37e65ebb7eb932e1a144b1cab262e11ca5fd109b.zip frameworks_base-37e65ebb7eb932e1a144b1cab262e11ca5fd109b.tar.gz frameworks_base-37e65ebb7eb932e1a144b1cab262e11ca5fd109b.tar.bz2 | |
Rename NetworkProperties to LinkProperties
Also add copy constructors and use them when giving out data.
Change-Id: Id320eb8fb91d0bd250305ce7bb4f628570215615
21 files changed, 158 insertions, 143 deletions
diff --git a/core/java/android/net/NetworkProperties.aidl b/core/java/android/net/LinkProperties.aidl index 07aac6e..73c7988 100644 --- a/core/java/android/net/NetworkProperties.aidl +++ b/core/java/android/net/LinkProperties.aidl @@ -18,5 +18,5 @@ package android.net; -parcelable NetworkProperties; +parcelable LinkProperties; diff --git a/core/java/android/net/NetworkProperties.java b/core/java/android/net/LinkProperties.java index 03c0a2e..9cb38e3 100644 --- a/core/java/android/net/NetworkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -16,6 +16,7 @@ package android.net; +import android.net.ProxyProperties; import android.os.Parcelable; import android.os.Parcel; import android.util.Log; @@ -26,14 +27,14 @@ import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; /** - * Describes the properties of a network interface or single address - * of an interface. + * Describes the properties of a network link. * TODO - consider adding optional fields like Apn and ApnType * @hide */ -public class NetworkProperties implements Parcelable { +public class LinkProperties implements Parcelable { private NetworkInterface mIface; private Collection<InetAddress> mAddresses; @@ -41,49 +42,58 @@ public class NetworkProperties implements Parcelable { private InetAddress mGateway; private ProxyProperties mHttpProxy; - public NetworkProperties() { + public LinkProperties() { clear(); } - public synchronized void setInterface(NetworkInterface iface) { + // copy constructor instead of clone + public LinkProperties(LinkProperties source) { + mIface = source.getInterface(); + mAddresses = source.getAddresses(); + mDnses = source.getDnses(); + mGateway = source.getGateway(); + mHttpProxy = new ProxyProperties(source.getHttpProxy()); + } + + public void setInterface(NetworkInterface iface) { mIface = iface; } - public synchronized NetworkInterface getInterface() { + public NetworkInterface getInterface() { return mIface; } - public synchronized String getInterfaceName() { + public String getInterfaceName() { return (mIface == null ? null : mIface.getName()); } - public synchronized void addAddress(InetAddress address) { + public void addAddress(InetAddress address) { mAddresses.add(address); } - public synchronized Collection<InetAddress> getAddresses() { - return mAddresses; + public Collection<InetAddress> getAddresses() { + return Collections.unmodifiableCollection(mAddresses); } - public synchronized void addDns(InetAddress dns) { + public void addDns(InetAddress dns) { mDnses.add(dns); } - public synchronized Collection<InetAddress> getDnses() { - return mDnses; + public Collection<InetAddress> getDnses() { + return Collections.unmodifiableCollection(mDnses); } - public synchronized void setGateway(InetAddress gateway) { + public void setGateway(InetAddress gateway) { mGateway = gateway; } - public synchronized InetAddress getGateway() { + public InetAddress getGateway() { return mGateway; } - public synchronized void setHttpProxy(ProxyProperties proxy) { + public void setHttpProxy(ProxyProperties proxy) { mHttpProxy = proxy; } - public synchronized ProxyProperties getHttpProxy() { + public ProxyProperties getHttpProxy() { return mHttpProxy; } - public synchronized void clear() { + public void clear() { mIface = null; mAddresses = new ArrayList<InetAddress>(); mDnses = new ArrayList<InetAddress>(); @@ -100,7 +110,7 @@ public class NetworkProperties implements Parcelable { } @Override - public synchronized String toString() { + public String toString() { String ifaceName = (mIface == null ? "" : "InterfaceName: " + mIface.getName() + " "); String ip = "IpAddresses: ["; @@ -121,7 +131,7 @@ public class NetworkProperties implements Parcelable { * Implement the Parcelable interface. * @hide */ - public synchronized void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(Parcel dest, int flags) { dest.writeString(getInterfaceName()); dest.writeInt(mAddresses.size()); //TODO: explore an easy alternative to preserve hostname @@ -151,10 +161,10 @@ public class NetworkProperties implements Parcelable { * Implement the Parcelable interface. * @hide */ - public static final Creator<NetworkProperties> CREATOR = - new Creator<NetworkProperties>() { - public NetworkProperties createFromParcel(Parcel in) { - NetworkProperties netProp = new NetworkProperties(); + public static final Creator<LinkProperties> CREATOR = + new Creator<LinkProperties>() { + public LinkProperties createFromParcel(Parcel in) { + LinkProperties netProp = new LinkProperties(); String iface = in.readString(); if (iface != null) { try { @@ -186,8 +196,8 @@ public class NetworkProperties implements Parcelable { return netProp; } - public NetworkProperties[] newArray(int size) { - return new NetworkProperties[size]; + public LinkProperties[] newArray(int size) { + return new LinkProperties[size]; } }; } diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 6dfd3bc..0498fff 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -16,8 +16,6 @@ package android.net; -import java.net.InetAddress; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -32,7 +30,7 @@ import com.android.internal.telephony.Phone; import com.android.internal.telephony.TelephonyIntents; import android.net.NetworkInfo.DetailedState; import android.net.NetworkInfo; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.telephony.TelephonyManager; import android.util.Log; import android.text.TextUtils; @@ -58,7 +56,7 @@ public class MobileDataStateTracker implements NetworkStateTracker { private boolean mTeardownRequested = false; private Handler mTarget; private Context mContext; - private NetworkProperties mNetworkProperties; + private LinkProperties mLinkProperties; private boolean mPrivateDnsRouteSet = false; private int mDefaultGatewayAddr = 0; private boolean mDefaultRouteSet = false; @@ -213,8 +211,8 @@ public class MobileDataStateTracker implements NetworkStateTracker { + e); } } - if (doReset && mNetworkProperties != null) { - String iface = mNetworkProperties.getInterfaceName(); + if (doReset && mLinkProperties != null) { + String iface = mLinkProperties.getInterfaceName(); if (iface != null) NetworkUtils.resetConnections(iface); } // TODO - check this @@ -233,11 +231,11 @@ public class MobileDataStateTracker implements NetworkStateTracker { setDetailedState(DetailedState.SUSPENDED, reason, apnName); break; case CONNECTED: - mNetworkProperties = intent.getParcelableExtra( - Phone.DATA_NETWORK_PROPERTIES_KEY); - if (mNetworkProperties == null) { + mLinkProperties = intent.getParcelableExtra( + Phone.DATA_LINK_PROPERTIES_KEY); + if (mLinkProperties == null) { Log.d(TAG, - "CONNECTED event did not supply network properties."); + "CONNECTED event did not supply link properties."); } setDetailedState(DetailedState.CONNECTED, reason, apnName); break; @@ -563,7 +561,7 @@ public class MobileDataStateTracker implements NetworkStateTracker { } } - public NetworkProperties getNetworkProperties() { - return mNetworkProperties; + public LinkProperties getLinkProperties() { + return new LinkProperties(mLinkProperties); } } diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index 0048a2e..420992b 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -91,9 +91,9 @@ public interface NetworkStateTracker { public NetworkInfo getNetworkInfo(); /** - * Fetch NetworkProperties for the network + * Fetch LinkProperties for the network */ - public NetworkProperties getNetworkProperties(); + public LinkProperties getLinkProperties(); /** * Return the system properties name associated with the tcp buffer sizes diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java index 207fb51..24f6766 100644 --- a/core/java/android/net/ProxyProperties.java +++ b/core/java/android/net/ProxyProperties.java @@ -36,24 +36,31 @@ public class ProxyProperties implements Parcelable { public ProxyProperties() { } - public synchronized InetAddress getAddress() { + // copy constructor instead of clone + public ProxyProperties(ProxyProperties source) { + mProxy = source.getAddress(); + mPort = source.getPort(); + mExclusionList = new String(source.getExclusionList()); + } + + public InetAddress getAddress() { return mProxy; } - public synchronized void setAddress(InetAddress proxy) { + public void setAddress(InetAddress proxy) { mProxy = proxy; } - public synchronized int getPort() { + public int getPort() { return mPort; } - public synchronized void setPort(int port) { + public void setPort(int port) { mPort = port; } - public synchronized String getExclusionList() { + public String getExclusionList() { return mExclusionList; } - public synchronized void setExclusionList(String exclusionList) { + public void setExclusionList(String exclusionList) { mExclusionList = exclusionList; } @@ -77,7 +84,7 @@ public class ProxyProperties implements Parcelable { * Implement the Parcelable interface. * @hide */ - public synchronized void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(Parcel dest, int flags) { if (mProxy != null) { dest.writeByte((byte)1); dest.writeString(mProxy.getHostName()); diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 57e8e02..6f23805 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -26,7 +26,7 @@ import android.net.ConnectivityManager; import android.net.IConnectivityManager; import android.net.MobileDataStateTracker; import android.net.NetworkInfo; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.net.NetworkStateTracker; import android.net.NetworkUtils; import android.net.wifi.WifiStateTracker; @@ -756,7 +756,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { * specified host is to be routed * @param hostAddress the IP address of the host to which the route is * desired - * todo - deprecate (only v4!) * @return {@code true} on success, {@code false} on failure */ public boolean requestRouteToHost(int networkType, int hostAddress) { @@ -813,7 +812,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { return false; } - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return false; String interfaceName = p.getInterfaceName(); @@ -1258,7 +1257,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void addPrivateDnsRoutes(NetworkStateTracker nt) { boolean privateDnsRouteSet = nt.isPrivateDnsRouteSet(); - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return; String interfaceName = p.getInterfaceName(); @@ -1279,7 +1278,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void removePrivateDnsRoutes(NetworkStateTracker nt) { // TODO - we should do this explicitly but the NetUtils api doesnt // support this yet - must remove all. No worse than before - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return; String interfaceName = p.getInterfaceName(); boolean privateDnsRouteSet = nt.isPrivateDnsRouteSet(); @@ -1295,7 +1294,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void addDefaultRoute(NetworkStateTracker nt) { - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return; String interfaceName = p.getInterfaceName(); InetAddress defaultGatewayAddr = p.getGateway(); @@ -1311,7 +1310,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { public void removeDefaultRoute(NetworkStateTracker nt) { - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return; String interfaceName = p.getInterfaceName(); @@ -1410,7 +1409,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { NetworkStateTracker nt = mNetTrackers[i]; if (nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) continue; List pids = mNetRequestersPids[i]; for (int j=0; j<pids.size(); j++) { @@ -1465,7 +1464,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { // add default net's dns entries NetworkStateTracker nt = mNetTrackers[netType]; if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { - NetworkProperties p = nt.getNetworkProperties(); + LinkProperties p = nt.getLinkProperties(); if (p == null) return; Collection<InetAddress> dnses = p.getDnses(); if (mNetAttributes[netType].isDefault()) { diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index 73234df..0a90a4c 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -19,7 +19,7 @@ package com.android.server; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; @@ -92,7 +92,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private ArrayList<String> mConnectedApns; - private NetworkProperties mDataConnectionProperties; + private LinkProperties mDataConnectionProperties; private Bundle mCellLocation = new Bundle(); @@ -355,7 +355,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } public void notifyDataConnection(int state, boolean isDataConnectivityPossible, - String reason, String apn, String apnType, NetworkProperties networkProperties, + String reason, String apn, String apnType, LinkProperties linkProperties, int networkType) { if (!checkNotifyPermission("notifyDataConnection()" )) { return; @@ -383,7 +383,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mDataConnectionPossible = isDataConnectivityPossible; mDataConnectionReason = reason; mDataConnectionApn = apn; - mDataConnectionProperties = networkProperties; + mDataConnectionProperties = linkProperties; if (mDataConnectionNetworkType != networkType) { mDataConnectionNetworkType = networkType; modified = true; @@ -403,7 +403,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, - apnType, networkProperties); + apnType, linkProperties); } public void notifyDataConnectionFailed(String reason, String apnType) { @@ -564,7 +564,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private void broadcastDataConnectionStateChanged(int state, boolean isDataConnectivityPossible, - String reason, String apn, String apnType, NetworkProperties networkProperties) { + String reason, String apn, String apnType, LinkProperties linkProperties) { // Note: not reporting to the battery stats service here, because the // status bar takes care of that after taking into account all of the // required info. @@ -577,9 +577,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (reason != null) { intent.putExtra(Phone.STATE_CHANGE_REASON_KEY, reason); } - if (networkProperties != null) { - intent.putExtra(Phone.DATA_NETWORK_PROPERTIES_KEY, networkProperties); - NetworkInterface iface = networkProperties.getInterface(); + if (linkProperties != null) { + intent.putExtra(Phone.DATA_LINK_PROPERTIES_KEY, linkProperties); + NetworkInterface iface = linkProperties.getInterface(); if (iface != null) { intent.putExtra(Phone.DATA_IFACE_NAME_KEY, iface.getName()); } diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java index 7e722cb..521d90c 100644 --- a/telephony/java/com/android/internal/telephony/DataConnection.java +++ b/telephony/java/com/android/internal/telephony/DataConnection.java @@ -21,7 +21,7 @@ import com.android.internal.telephony.gsm.ApnSetting; import com.android.internal.util.HierarchicalState; import com.android.internal.util.HierarchicalStateMachine; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.AsyncResult; import android.os.Message; import android.os.SystemProperties; @@ -261,7 +261,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { protected int mTag; protected PhoneBase phone; protected int cid; - protected NetworkProperties mNetworkProperties = new NetworkProperties(); + protected LinkProperties mLinkProperties = new LinkProperties(); protected long createTime; protected long lastFailTime; protected FailCause lastFailCause; @@ -378,7 +378,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { this.lastFailTime = -1; this.lastFailCause = FailCause.NONE; - mNetworkProperties.clear(); + mLinkProperties = new LinkProperties(); } /** @@ -416,7 +416,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { // Start with clean network properties and if we have // a failure we'll clear again at the bottom of this code. - mNetworkProperties.clear(); + LinkProperties linkProperties = new LinkProperties(); if (response.length >= 2) { cid = Integer.parseInt(response[0]); String interfaceName = response[1]; @@ -425,23 +425,23 @@ public abstract class DataConnection extends HierarchicalStateMachine { try { String prefix = "net." + interfaceName + "."; - mNetworkProperties.setInterface(NetworkInterface.getByName(interfaceName)); + linkProperties.setInterface(NetworkInterface.getByName(interfaceName)); // TODO: Get gateway and dns via RIL interface not property? String gatewayAddress = SystemProperties.get(prefix + "gw"); - mNetworkProperties.setGateway(InetAddress.getByName(gatewayAddress)); + linkProperties.setGateway(InetAddress.getByName(gatewayAddress)); if (response.length > 2) { String ipAddress = response[2]; - mNetworkProperties.addAddress(InetAddress.getByName(ipAddress)); + linkProperties.addAddress(InetAddress.getByName(ipAddress)); // TODO: Get gateway and dns via RIL interface not property? String dnsServers[] = new String[2]; dnsServers[0] = SystemProperties.get(prefix + "dns1"); dnsServers[1] = SystemProperties.get(prefix + "dns2"); if (isDnsOk(dnsServers)) { - mNetworkProperties.addDns(InetAddress.getByName(dnsServers[0])); - mNetworkProperties.addDns(InetAddress.getByName(dnsServers[1])); + linkProperties.addDns(InetAddress.getByName(dnsServers[0])); + linkProperties.addDns(InetAddress.getByName(dnsServers[1])); } else { result = SetupResult.ERR_BadDns; } @@ -463,15 +463,16 @@ public abstract class DataConnection extends HierarchicalStateMachine { // An error occurred so clear properties if (result != SetupResult.SUCCESS) { - log("onSetupCompleted with an error clearing NetworkProperties"); - mNetworkProperties.clear(); + log("onSetupCompleted with an error clearing LinkProperties"); + linkProperties.clear(); } + mLinkProperties = linkProperties; } if (DBG) { log("DataConnection setup result='" + result + "' on cid=" + cid); if (result == SetupResult.SUCCESS) { - log("NetworkProperties: " + mNetworkProperties.toString()); + log("LinkProperties: " + mLinkProperties.toString()); } } return result; @@ -636,7 +637,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { case ERR_BadDns: // Connection succeeded but DNS info is bad so disconnect StringBuilder dnsAddressesSb = new StringBuilder(); - for (InetAddress addr : mNetworkProperties.getDnses()) { + for (InetAddress addr : mLinkProperties.getDnses()) { if (dnsAddressesSb.length() != 0) dnsAddressesSb.append(" "); dnsAddressesSb.append(addr.toString()); } @@ -911,10 +912,10 @@ public abstract class DataConnection extends HierarchicalStateMachine { } /** - * @return the connections NetworkProperties + * @return the connections LinkProperties */ - public NetworkProperties getNetworkProperties() { - return mNetworkProperties; + public LinkProperties getLinkProperties() { + return new LinkProperties(mLinkProperties); } /** diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index 14cb584..765f64b 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -17,7 +17,7 @@ package com.android.internal.telephony; import android.app.PendingIntent; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; @@ -192,8 +192,8 @@ public abstract class DataConnectionTracker extends Handler { /** indication of our availability (preconditions to trysetupData are met) **/ protected boolean mAvailability = false; - /** all our network properties (dns, gateway, ip, etc) */ - protected NetworkProperties mNetworkProperties; + /** all our link properties (dns, gateway, ip, etc) */ + protected LinkProperties mLinkProperties; /** * Default constructor @@ -420,10 +420,10 @@ public abstract class DataConnectionTracker extends Handler { protected abstract void setState(State s); - protected NetworkProperties getNetworkProperties(String apnType) { + protected LinkProperties getLinkProperties(String apnType) { int id = apnTypeToId(apnType); if (isApnIdEnabled(id)) { - return mNetworkProperties; + return new LinkProperties(mLinkProperties); } else { return null; } @@ -673,7 +673,7 @@ public abstract class DataConnectionTracker extends Handler { } } - protected NetworkProperties getNetworkProperties(DataConnection connection) { - return connection.getNetworkProperties(); + protected LinkProperties getLinkProperties(DataConnection connection) { + return connection.getLinkProperties(); } } diff --git a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java index 382c19f..bf3c4d1 100644 --- a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java +++ b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java @@ -16,7 +16,7 @@ package com.android.internal.telephony; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -108,9 +108,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier { // use apnType as the key to which connection we're talking about. // pass apnType back up to fetch particular for this one. TelephonyManager telephony = TelephonyManager.getDefault(); - NetworkProperties networkProperties = null; + LinkProperties linkProperties = null; if (state == Phone.DataState.CONNECTED) { - networkProperties = sender.getNetworkProperties(apnType); + linkProperties = sender.getLinkProperties(apnType); } try { mRegistry.notifyDataConnection( @@ -118,7 +118,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier { sender.isDataConnectivityPossible(), reason, sender.getActiveApn(), apnType, - networkProperties, + linkProperties, ((telephony!=null) ? telephony.getNetworkType() : TelephonyManager.NETWORK_TYPE_UNKNOWN)); } catch (RemoteException ex) { diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index f7b70ee..eb7e566 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -17,7 +17,7 @@ package com.android.internal.telephony; import android.content.Intent; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Bundle; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -33,7 +33,7 @@ interface ITelephonyRegistry { void notifyCallForwardingChanged(boolean cfi); void notifyDataActivity(int state); void notifyDataConnection(int state, boolean isDataConnectivityPossible, - String reason, String apn, String apnType, in NetworkProperties networkProperties, + String reason, String apn, String apnType, in LinkProperties linkProperties, int networkType); void notifyDataConnectionFailed(String reason, String apnType); void notifyCellLocation(in Bundle cellLocation); diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java index e752dc6..fffe057 100644 --- a/telephony/java/com/android/internal/telephony/Phone.java +++ b/telephony/java/com/android/internal/telephony/Phone.java @@ -17,7 +17,7 @@ package com.android.internal.telephony; import android.content.Context; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Handler; import android.os.Message; import android.telephony.CellLocation; @@ -99,7 +99,7 @@ public interface Phone { static final String STATE_CHANGE_REASON_KEY = "reason"; static final String DATA_APN_TYPE_KEY = "apnType"; static final String DATA_APN_KEY = "apn"; - static final String DATA_NETWORK_PROPERTIES_KEY = "dataProperties"; + static final String DATA_LINK_PROPERTIES_KEY = "linkProperties"; static final String DATA_IFACE_NAME_KEY = "iface"; static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable"; @@ -319,9 +319,9 @@ public interface Phone { String getActiveApn(); /** - * Return the NetworkProperties for the named apn or null if not available + * Return the LinkProperties for the named apn or null if not available */ - NetworkProperties getNetworkProperties(String apnType); + LinkProperties getLinkProperties(String apnType); /** * Get current signal strength. No change notification available on this diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java index 0557942..36a2fcf 100644 --- a/telephony/java/com/android/internal/telephony/PhoneBase.java +++ b/telephony/java/com/android/internal/telephony/PhoneBase.java @@ -21,7 +21,7 @@ import android.app.IActivityManager; import android.content.Context; import android.content.res.Configuration; import android.content.SharedPreferences; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.net.wifi.WifiManager; import android.os.AsyncResult; import android.os.Handler; @@ -938,8 +938,8 @@ public abstract class PhoneBase extends Handler implements Phone { return mDataConnection.getActiveApnTypes(); } - public NetworkProperties getNetworkProperties(String apnType) { - return mDataConnection.getNetworkProperties(apnType); + public LinkProperties getLinkProperties(String apnType) { + return mDataConnection.getLinkProperties(apnType); } public String getActiveApn() { diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java index bcf3337..b6e4cda 100644 --- a/telephony/java/com/android/internal/telephony/PhoneProxy.java +++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java @@ -20,7 +20,7 @@ package com.android.internal.telephony; import android.app.ActivityManagerNative; import android.content.Context; import android.content.Intent; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Handler; import android.os.Message; import android.os.SystemProperties; @@ -208,8 +208,8 @@ public class PhoneProxy extends Handler implements Phone { return mActivePhone.getActiveApnTypes(); } - public NetworkProperties getNetworkProperties(String apnType) { - return mActivePhone.getNetworkProperties(apnType); + public LinkProperties getLinkProperties(String apnType) { + return mActivePhone.getLinkProperties(apnType); } public String getActiveApn() { diff --git a/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java b/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java index 1229d14..30d06d8 100644 --- a/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java +++ b/telephony/java/com/android/internal/telephony/SipPhoneNotifier.java @@ -16,7 +16,7 @@ package com.android.internal.telephony; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -110,9 +110,9 @@ public class SipPhoneNotifier implements PhoneNotifier { // use apnType as the key to which connection we're talking about. // pass apnType back up to fetch particular for this one. TelephonyManager telephony = TelephonyManager.getDefault(); - NetworkProperties networkProperties = null; + LinkProperties linkProperties = null; if (state == Phone.DataState.CONNECTED) { - networkProperties = sender.getNetworkProperties(apnType); + linkProperties = sender.getLinkProperties(apnType); } try { mRegistry.notifyDataConnection( @@ -120,7 +120,7 @@ public class SipPhoneNotifier implements PhoneNotifier { sender.isDataConnectivityPossible(), reason, sender.getActiveApn(), apnType, - networkProperties, + linkProperties, ((telephony!=null) ? telephony.getNetworkType() : TelephonyManager.NETWORK_TYPE_UNKNOWN)); } catch (RemoteException ex) { diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java index c94cfa4..5918245 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java @@ -732,7 +732,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } if (ar.exception == null) { - mNetworkProperties = getNetworkProperties(mActiveDataConnection); + mLinkProperties = getLinkProperties(mActiveDataConnection); // everything is setup notifyDefaultData(reason); diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index face581..4414460 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -1098,7 +1098,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } if (ar.exception == null) { - mNetworkProperties = getNetworkProperties(mActivePdp); + mLinkProperties = getLinkProperties(mActivePdp); ApnSetting apn = mActivePdp.getApn(); if (apn.proxy != null && apn.proxy.length() != 0) { @@ -1106,7 +1106,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { ProxyProperties proxy = new ProxyProperties(); proxy.setAddress(InetAddress.getByName(apn.proxy)); proxy.setPort(Integer.parseInt(apn.port)); - mNetworkProperties.setHttpProxy(proxy); + mLinkProperties.setHttpProxy(proxy); } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException making ProxyProperties: " + e); } catch (SecurityException e) { diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java index 1d33be9..e742887 100755 --- a/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java +++ b/telephony/java/com/android/internal/telephony/sip/SipPhoneBase.java @@ -19,7 +19,7 @@ package com.android.internal.telephony.sip; import android.content.ContentValues; import android.content.Context; import android.content.SharedPreferences; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.net.Uri; import android.os.AsyncResult; import android.os.Handler; @@ -540,7 +540,7 @@ abstract class SipPhoneBase extends PhoneBase { } //@Override - public NetworkProperties getNetworkProperties(String apnType) { + public LinkProperties getLinkProperties(String apnType) { // FIXME: what's this for SIP? return null; } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 21671f1..8c3ec5f 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -307,19 +307,19 @@ public class WifiManager { @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String CONFIG_CHANGED_ACTION = "android.net.wifi.CONFIG_CHANGED"; /** - * The lookup key for a {@link android.net.NetworkProperties} object associated with the + * The lookup key for a {@link android.net.LinkProperties} object associated with the * Wi-Fi network. Retrieve with * {@link android.content.Intent#getParcelableExtra(String)}. * @hide */ - public static final String EXTRA_NETWORK_PROPERTIES = "networkProperties"; + public static final String EXTRA_LINK_PROPERTIES = "linkProperties"; /** * The network IDs of the configured networks could have changed. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String NETWORK_IDS_CHANGED_ACTION = "android.net.wifi.NETWORK_IDS_CHANGED"; - + /** * Activity Action: Pick a Wi-Fi network to connect to. * <p>Input: Nothing. diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 69e8f2e..7554bd1 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -43,7 +43,7 @@ import android.net.DhcpInfo; import android.net.NetworkUtils; import android.net.ConnectivityManager; import android.net.NetworkInfo.DetailedState; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.net.wifi.WifiConfiguration.Status; import android.os.Binder; import android.os.Message; @@ -143,7 +143,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { * Observes the static IP address settings. */ private SettingsObserver mSettingsObserver; - private NetworkProperties mNetworkProperties; + private LinkProperties mLinkProperties; // Held during driver load and unload private static PowerManager.WakeLock sWakeLock; @@ -421,10 +421,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { mSupplicantStateTracker = new SupplicantStateTracker(context, getHandler()); mBluetoothHeadset = new BluetoothHeadset(mContext, null); - mNetworkProperties = new NetworkProperties(); + mLinkProperties = new LinkProperties(); mNetworkInfo.setIsAvailable(false); - mNetworkProperties.clear(); + mLinkProperties.clear(); mLastBssid = null; mLastNetworkId = -1; mLastSignalLevel = -1; @@ -899,7 +899,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { StringBuffer sb = new StringBuffer(); String LS = System.getProperty("line.separator"); sb.append("current HSM state: ").append(getCurrentState().getName()).append(LS); - sb.append("mNetworkProperties ").append(mNetworkProperties).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("mNetworkInfo ").append(mNetworkInfo).append(LS); @@ -1189,9 +1189,9 @@ public class WifiStateMachine extends HierarchicalStateMachine { return null; } - private void configureNetworkProperties() { + private void configureLinkProperties() { try { - mNetworkProperties.setInterface(NetworkInterface.getByName(mInterfaceName)); + mLinkProperties.setInterface(NetworkInterface.getByName(mInterfaceName)); } catch (SocketException e) { Log.e(TAG, "SocketException creating NetworkInterface from " + mInterfaceName + ". e=" + e); @@ -1201,10 +1201,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { return; } // TODO - fix this for v6 - mNetworkProperties.addAddress(NetworkUtils.intToInetAddress(mDhcpInfo.ipAddress)); - mNetworkProperties.setGateway(NetworkUtils.intToInetAddress(mDhcpInfo.gateway)); - mNetworkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns1)); - mNetworkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns2)); + mLinkProperties.addAddress(NetworkUtils.intToInetAddress(mDhcpInfo.ipAddress)); + mLinkProperties.setGateway(NetworkUtils.intToInetAddress(mDhcpInfo.gateway)); + mLinkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns1)); + mLinkProperties.addDns(NetworkUtils.intToInetAddress(mDhcpInfo.dns2)); // TODO - add proxy info } @@ -1381,7 +1381,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo); - intent.putExtra(WifiManager.EXTRA_NETWORK_PROPERTIES, mNetworkProperties); + intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties); if (bssid != null) intent.putExtra(WifiManager.EXTRA_BSSID, bssid); mContext.sendStickyBroadcast(intent); @@ -1390,7 +1390,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { private void sendConfigChangeBroadcast() { if (!ActivityManagerNative.isSystemReady()) return; Intent intent = new Intent(WifiManager.CONFIG_CHANGED_ACTION); - intent.putExtra(WifiManager.EXTRA_NETWORK_PROPERTIES, mNetworkProperties); + intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties); mContext.sendBroadcast(intent); } @@ -1945,7 +1945,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { mWifiInfo.setNetworkId(-1); /* Clear network properties */ - mNetworkProperties.clear(); + mLinkProperties.clear(); mLastBssid= null; mLastNetworkId = -1; @@ -3036,7 +3036,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { mLastSignalLevel = -1; // force update of signal strength mWifiInfo.setIpAddress(mDhcpInfo.ipAddress); Log.d(TAG, "IP configuration: " + mDhcpInfo); - configureNetworkProperties(); + configureLinkProperties(); setDetailedState(DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mLastBssid); //TODO: we could also detect an IP config change diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 147e2dc..5a20736 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -24,7 +24,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.net.NetworkProperties; +import android.net.LinkProperties; import android.net.NetworkStateTracker; import android.os.Handler; import android.os.Message; @@ -47,7 +47,7 @@ public class WifiStateTracker implements NetworkStateTracker { private AtomicInteger mDefaultGatewayAddr = new AtomicInteger(0); private AtomicBoolean mDefaultRouteSet = new AtomicBoolean(false); - private NetworkProperties mNetworkProperties; + private LinkProperties mLinkProperties; private NetworkInfo mNetworkInfo; /* For sending events to connectivity service handler */ @@ -58,10 +58,10 @@ public class WifiStateTracker implements NetworkStateTracker { public WifiStateTracker() { mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, NETWORKTYPE, ""); - mNetworkProperties = new NetworkProperties(); + mLinkProperties = new LinkProperties(); mNetworkInfo.setIsAvailable(false); - mNetworkProperties.clear(); + mLinkProperties.clear(); setTeardownRequested(false); } @@ -191,10 +191,10 @@ public class WifiStateTracker implements NetworkStateTracker { } /** - * Fetch NetworkProperties for the network + * Fetch LinkProperties for the network */ - public NetworkProperties getNetworkProperties() { - return mNetworkProperties; + public LinkProperties getLinkProperties() { + return new LinkProperties(mLinkProperties); } /** @@ -232,13 +232,13 @@ public class WifiStateTracker implements NetworkStateTracker { if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { mNetworkInfo = (NetworkInfo) intent.getParcelableExtra( WifiManager.EXTRA_NETWORK_INFO); - mNetworkProperties = (NetworkProperties) intent.getParcelableExtra( - WifiManager.EXTRA_NETWORK_PROPERTIES); + mLinkProperties = (LinkProperties) intent.getParcelableExtra( + WifiManager.EXTRA_LINK_PROPERTIES); Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); } else if (intent.getAction().equals(WifiManager.CONFIG_CHANGED_ACTION)) { - mNetworkProperties = (NetworkProperties) intent.getParcelableExtra( - WifiManager.EXTRA_NETWORK_PROPERTIES); + mLinkProperties = (LinkProperties) intent.getParcelableExtra( + WifiManager.EXTRA_LINK_PROPERTIES); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); } |
