Loading core/java/android/net/NetworkProperties.java +4 −3 Original line number Diff line number Diff line Loading @@ -99,19 +99,20 @@ public class NetworkProperties implements Parcelable { return 0; } @Override public synchronized String toString() { String ifaceName = (mIface == null ? "" : "InterfaceName: " + mIface.getName() + " "); String ip = "IpAddresses: ["; for (InetAddress addr : mAddresses) ip += addr.toString() + ","; for (InetAddress addr : mAddresses) ip += addr.getHostAddress() + ","; ip += "] "; String dns = "DnsAddresses: ["; for (InetAddress addr : mDnses) dns += addr.toString() + ","; for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ","; dns += "] "; String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " "); String gateway = (mGateway == null ? "" : "Gateway: " + mGateway.toString() + " "); String gateway = (mGateway == null ? "" : "Gateway: " + mGateway.getHostAddress() + " "); return ifaceName + ip + gateway + dns + proxy; } Loading core/java/android/net/ProxyProperties.java +8 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,14 @@ public class ProxyProperties implements Parcelable { mExclusionList = exclusionList; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(mProxy.getHostAddress()).append(":").append(mPort) .append(" xl=").append(mExclusionList); return sb.toString(); } /** * Implement the Parcelable interface * @hide Loading telephony/java/com/android/internal/telephony/DataConnection.java +68 −55 Original line number Diff line number Diff line Loading @@ -21,11 +21,17 @@ 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.os.AsyncResult; import android.os.Message; import android.os.SystemProperties; import android.util.EventLog; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; /** * {@hide} * Loading Loading @@ -255,10 +261,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { protected int mTag; protected PhoneBase phone; protected int cid; protected String interfaceName; protected String ipAddress; protected String gatewayAddress; protected String[] dnsServers; protected NetworkProperties mNetworkProperties = new NetworkProperties(); protected long createTime; protected long lastFailTime; protected FailCause lastFailCause; Loading @@ -283,8 +286,6 @@ public abstract class DataConnection extends HierarchicalStateMachine { if (DBG) log("DataConnection constructor E"); this.phone = phone; this.cid = -1; this.dnsServers = new String[2]; clearSettings(); setDbg(false); Loading Loading @@ -377,11 +378,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { this.lastFailTime = -1; this.lastFailCause = FailCause.NONE; interfaceName = null; ipAddress = null; gatewayAddress = null; dnsServers[0] = null; dnsServers[1] = null; mNetworkProperties.clear(); } /** Loading Loading @@ -416,37 +413,65 @@ public abstract class DataConnection extends HierarchicalStateMachine { // for (int i = 0; i < response.length; i++) { // log(" response[" + i + "]='" + response[i] + "'"); // } // Start with clean network properties and if we have // a failure we'll clear again at the bottom of this code. mNetworkProperties.clear(); if (response.length >= 2) { cid = Integer.parseInt(response[0]); interfaceName = response[1]; String interfaceName = response[1]; result = SetupResult.SUCCESS; try { String prefix = "net." + interfaceName + "."; gatewayAddress = SystemProperties.get(prefix + "gw"); dnsServers[0] = SystemProperties.get(prefix + "dns1"); dnsServers[1] = SystemProperties.get(prefix + "dns2"); mNetworkProperties.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)); if (response.length > 2) { ipAddress = response[2]; String ipAddress = response[2]; mNetworkProperties.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)) { result = SetupResult.SUCCESS; mNetworkProperties.addDns(InetAddress.getByName(dnsServers[0])); mNetworkProperties.addDns(InetAddress.getByName(dnsServers[1])); } else { result = SetupResult.ERR_BadDns; } } else { result = SetupResult.SUCCESS; } } catch (UnknownHostException e1) { log("onSetupCompleted: UnknowHostException " + e1); e1.printStackTrace(); result = SetupResult.ERR_Other; } catch (SocketException e2) { log("onSetupCompleted: SocketException " + e2); e2.printStackTrace(); result = SetupResult.ERR_Other; } } else { log("onSetupCompleted: error; expected number of responses >= 2 was " + response.length); result = SetupResult.ERR_Other; } // An error occurred so clear properties if (result != SetupResult.SUCCESS) { log("onSetupCompleted with an error clearing NetworkProperties"); mNetworkProperties.clear(); } } if (DBG) { log("DataConnection setup result='" + result + "' on cid=" + cid); if (result == SetupResult.SUCCESS) { log("interface=" + interfaceName + " ipAddress=" + ipAddress + " gateway=" + gatewayAddress + " DNS1=" + dnsServers[0] + " DNS2=" + dnsServers[1]); log("NetworkProperties: " + mNetworkProperties.toString()); } } return result; Loading Loading @@ -610,7 +635,16 @@ public abstract class DataConnection extends HierarchicalStateMachine { break; case ERR_BadDns: // Connection succeeded but DNS info is bad so disconnect EventLog.writeEvent(EventLogTags.PDP_BAD_DNS_ADDRESS, dnsServers[0]); StringBuilder dnsAddressesSb = new StringBuilder(); for (InetAddress addr : mNetworkProperties.getDnses()) { if (dnsAddressesSb.length() != 0) dnsAddressesSb.append(" "); dnsAddressesSb.append(addr.toString()); } if (dnsAddressesSb.length() == 0) { dnsAddressesSb.append("no-dns-addresses"); } EventLog.writeEvent(EventLogTags.PDP_BAD_DNS_ADDRESS, dnsAddressesSb.toString()); tearDownData(cp); transitionTo(mDisconnectingBadDnsState); break; Loading Loading @@ -877,31 +911,10 @@ public abstract class DataConnection extends HierarchicalStateMachine { } /** * @return the interface name as a string. */ public String getInterface() { return interfaceName; } /** * @return the ip address as a string. */ public String getIpAddress() { return ipAddress; } /** * @return the gateway address as a string. */ public String getGatewayAddress() { return gatewayAddress; } /** * @return an array of associated DNS addresses. * @return the connections NetworkProperties */ public String[] getDnsServers() { return dnsServers; public NetworkProperties getNetworkProperties() { return mNetworkProperties; } /** Loading telephony/java/com/android/internal/telephony/DataConnectionTracker.java +3 −51 Original line number Diff line number Diff line Loading @@ -21,18 +21,14 @@ import android.net.NetworkProperties; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; import android.util.Log; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; /** * {@hide} * Loading Loading @@ -422,14 +418,6 @@ public abstract class DataConnectionTracker extends Handler { public abstract ArrayList<DataConnection> getAllDataConnections(); protected abstract String getInterfaceName(String apnType); protected abstract String getIpAddress(String apnType); protected abstract String getGateway(String apnType); protected abstract String[] getDnsServers(String apnType); protected abstract void setState(State s); protected NetworkProperties getNetworkProperties(String apnType) { Loading Loading @@ -685,43 +673,7 @@ public abstract class DataConnectionTracker extends Handler { } } protected NetworkProperties makeNetworkProperties(DataConnection connection) { NetworkProperties properties = new NetworkProperties(); try { properties.setInterface(NetworkInterface.getByName(connection.getInterface())); } catch (SocketException e) { Log.e(LOG_TAG, "SocketException creating NetworkInterface: " + e); } catch (NullPointerException e) { Log.e(LOG_TAG, "NPE trying to makeNetworkProperties: " + e); } try { properties.addAddress(InetAddress.getByName(connection.getIpAddress())); } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting IpAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting IpAddress: " + e); } try { properties.setGateway(InetAddress.getByName(connection.getGatewayAddress())); } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting GatewayAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting GatewayAddress: " + e); } try { String[] dnsStrings = connection.getDnsServers(); for (int i = 0; i<dnsStrings.length; i++) { properties.addDns(InetAddress.getByName(dnsStrings[i])); } } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting DnsAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting DnsAddress: " + e); } // TODO - set Proxy info return properties; protected NetworkProperties getNetworkProperties(DataConnection connection) { return connection.getNetworkProperties(); } } telephony/java/com/android/internal/telephony/Phone.java +0 −26 Original line number Diff line number Diff line Loading @@ -17,11 +17,9 @@ package com.android.internal.telephony; import android.content.Context; import android.content.SharedPreferences; import android.net.NetworkProperties; import android.os.Handler; import android.os.Message; import android.preference.PreferenceManager; import android.telephony.CellLocation; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; Loading @@ -29,7 +27,6 @@ import android.telephony.SignalStrength; import com.android.internal.telephony.DataConnection; import com.android.internal.telephony.gsm.NetworkInfo; import com.android.internal.telephony.gsm.GsmDataConnection; import com.android.internal.telephony.test.SimulatedRadioControl; import java.util.List; Loading Loading @@ -1381,29 +1378,6 @@ public interface Phone { */ boolean isDataConnectivityPossible(); /** * Returns the name of the network interface used by the specified APN type. */ String getInterfaceName(String apnType); /** * Returns the IP address of the network interface used by the specified * APN type. */ String getIpAddress(String apnType); /** * Returns the gateway for the network interface used by the specified APN * type. */ String getGateway(String apnType); /** * Returns the DNS servers for the network interface used by the specified * APN type. */ public String[] getDnsServers(String apnType); /** * Retrieves the unique device ID, e.g., IMEI for GSM phones and MEID for CDMA phones. */ Loading Loading
core/java/android/net/NetworkProperties.java +4 −3 Original line number Diff line number Diff line Loading @@ -99,19 +99,20 @@ public class NetworkProperties implements Parcelable { return 0; } @Override public synchronized String toString() { String ifaceName = (mIface == null ? "" : "InterfaceName: " + mIface.getName() + " "); String ip = "IpAddresses: ["; for (InetAddress addr : mAddresses) ip += addr.toString() + ","; for (InetAddress addr : mAddresses) ip += addr.getHostAddress() + ","; ip += "] "; String dns = "DnsAddresses: ["; for (InetAddress addr : mDnses) dns += addr.toString() + ","; for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ","; dns += "] "; String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " "); String gateway = (mGateway == null ? "" : "Gateway: " + mGateway.toString() + " "); String gateway = (mGateway == null ? "" : "Gateway: " + mGateway.getHostAddress() + " "); return ifaceName + ip + gateway + dns + proxy; } Loading
core/java/android/net/ProxyProperties.java +8 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,14 @@ public class ProxyProperties implements Parcelable { mExclusionList = exclusionList; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(mProxy.getHostAddress()).append(":").append(mPort) .append(" xl=").append(mExclusionList); return sb.toString(); } /** * Implement the Parcelable interface * @hide Loading
telephony/java/com/android/internal/telephony/DataConnection.java +68 −55 Original line number Diff line number Diff line Loading @@ -21,11 +21,17 @@ 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.os.AsyncResult; import android.os.Message; import android.os.SystemProperties; import android.util.EventLog; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; /** * {@hide} * Loading Loading @@ -255,10 +261,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { protected int mTag; protected PhoneBase phone; protected int cid; protected String interfaceName; protected String ipAddress; protected String gatewayAddress; protected String[] dnsServers; protected NetworkProperties mNetworkProperties = new NetworkProperties(); protected long createTime; protected long lastFailTime; protected FailCause lastFailCause; Loading @@ -283,8 +286,6 @@ public abstract class DataConnection extends HierarchicalStateMachine { if (DBG) log("DataConnection constructor E"); this.phone = phone; this.cid = -1; this.dnsServers = new String[2]; clearSettings(); setDbg(false); Loading Loading @@ -377,11 +378,7 @@ public abstract class DataConnection extends HierarchicalStateMachine { this.lastFailTime = -1; this.lastFailCause = FailCause.NONE; interfaceName = null; ipAddress = null; gatewayAddress = null; dnsServers[0] = null; dnsServers[1] = null; mNetworkProperties.clear(); } /** Loading Loading @@ -416,37 +413,65 @@ public abstract class DataConnection extends HierarchicalStateMachine { // for (int i = 0; i < response.length; i++) { // log(" response[" + i + "]='" + response[i] + "'"); // } // Start with clean network properties and if we have // a failure we'll clear again at the bottom of this code. mNetworkProperties.clear(); if (response.length >= 2) { cid = Integer.parseInt(response[0]); interfaceName = response[1]; String interfaceName = response[1]; result = SetupResult.SUCCESS; try { String prefix = "net." + interfaceName + "."; gatewayAddress = SystemProperties.get(prefix + "gw"); dnsServers[0] = SystemProperties.get(prefix + "dns1"); dnsServers[1] = SystemProperties.get(prefix + "dns2"); mNetworkProperties.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)); if (response.length > 2) { ipAddress = response[2]; String ipAddress = response[2]; mNetworkProperties.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)) { result = SetupResult.SUCCESS; mNetworkProperties.addDns(InetAddress.getByName(dnsServers[0])); mNetworkProperties.addDns(InetAddress.getByName(dnsServers[1])); } else { result = SetupResult.ERR_BadDns; } } else { result = SetupResult.SUCCESS; } } catch (UnknownHostException e1) { log("onSetupCompleted: UnknowHostException " + e1); e1.printStackTrace(); result = SetupResult.ERR_Other; } catch (SocketException e2) { log("onSetupCompleted: SocketException " + e2); e2.printStackTrace(); result = SetupResult.ERR_Other; } } else { log("onSetupCompleted: error; expected number of responses >= 2 was " + response.length); result = SetupResult.ERR_Other; } // An error occurred so clear properties if (result != SetupResult.SUCCESS) { log("onSetupCompleted with an error clearing NetworkProperties"); mNetworkProperties.clear(); } } if (DBG) { log("DataConnection setup result='" + result + "' on cid=" + cid); if (result == SetupResult.SUCCESS) { log("interface=" + interfaceName + " ipAddress=" + ipAddress + " gateway=" + gatewayAddress + " DNS1=" + dnsServers[0] + " DNS2=" + dnsServers[1]); log("NetworkProperties: " + mNetworkProperties.toString()); } } return result; Loading Loading @@ -610,7 +635,16 @@ public abstract class DataConnection extends HierarchicalStateMachine { break; case ERR_BadDns: // Connection succeeded but DNS info is bad so disconnect EventLog.writeEvent(EventLogTags.PDP_BAD_DNS_ADDRESS, dnsServers[0]); StringBuilder dnsAddressesSb = new StringBuilder(); for (InetAddress addr : mNetworkProperties.getDnses()) { if (dnsAddressesSb.length() != 0) dnsAddressesSb.append(" "); dnsAddressesSb.append(addr.toString()); } if (dnsAddressesSb.length() == 0) { dnsAddressesSb.append("no-dns-addresses"); } EventLog.writeEvent(EventLogTags.PDP_BAD_DNS_ADDRESS, dnsAddressesSb.toString()); tearDownData(cp); transitionTo(mDisconnectingBadDnsState); break; Loading Loading @@ -877,31 +911,10 @@ public abstract class DataConnection extends HierarchicalStateMachine { } /** * @return the interface name as a string. */ public String getInterface() { return interfaceName; } /** * @return the ip address as a string. */ public String getIpAddress() { return ipAddress; } /** * @return the gateway address as a string. */ public String getGatewayAddress() { return gatewayAddress; } /** * @return an array of associated DNS addresses. * @return the connections NetworkProperties */ public String[] getDnsServers() { return dnsServers; public NetworkProperties getNetworkProperties() { return mNetworkProperties; } /** Loading
telephony/java/com/android/internal/telephony/DataConnectionTracker.java +3 −51 Original line number Diff line number Diff line Loading @@ -21,18 +21,14 @@ import android.net.NetworkProperties; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; import android.util.Log; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; /** * {@hide} * Loading Loading @@ -422,14 +418,6 @@ public abstract class DataConnectionTracker extends Handler { public abstract ArrayList<DataConnection> getAllDataConnections(); protected abstract String getInterfaceName(String apnType); protected abstract String getIpAddress(String apnType); protected abstract String getGateway(String apnType); protected abstract String[] getDnsServers(String apnType); protected abstract void setState(State s); protected NetworkProperties getNetworkProperties(String apnType) { Loading Loading @@ -685,43 +673,7 @@ public abstract class DataConnectionTracker extends Handler { } } protected NetworkProperties makeNetworkProperties(DataConnection connection) { NetworkProperties properties = new NetworkProperties(); try { properties.setInterface(NetworkInterface.getByName(connection.getInterface())); } catch (SocketException e) { Log.e(LOG_TAG, "SocketException creating NetworkInterface: " + e); } catch (NullPointerException e) { Log.e(LOG_TAG, "NPE trying to makeNetworkProperties: " + e); } try { properties.addAddress(InetAddress.getByName(connection.getIpAddress())); } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting IpAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting IpAddress: " + e); } try { properties.setGateway(InetAddress.getByName(connection.getGatewayAddress())); } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting GatewayAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting GatewayAddress: " + e); } try { String[] dnsStrings = connection.getDnsServers(); for (int i = 0; i<dnsStrings.length; i++) { properties.addDns(InetAddress.getByName(dnsStrings[i])); } } catch (UnknownHostException e) { Log.e(LOG_TAG, "UnknownHostException setting DnsAddress: " + e); } catch (SecurityException e) { Log.e(LOG_TAG, "SecurityException setting DnsAddress: " + e); } // TODO - set Proxy info return properties; protected NetworkProperties getNetworkProperties(DataConnection connection) { return connection.getNetworkProperties(); } }
telephony/java/com/android/internal/telephony/Phone.java +0 −26 Original line number Diff line number Diff line Loading @@ -17,11 +17,9 @@ package com.android.internal.telephony; import android.content.Context; import android.content.SharedPreferences; import android.net.NetworkProperties; import android.os.Handler; import android.os.Message; import android.preference.PreferenceManager; import android.telephony.CellLocation; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; Loading @@ -29,7 +27,6 @@ import android.telephony.SignalStrength; import com.android.internal.telephony.DataConnection; import com.android.internal.telephony.gsm.NetworkInfo; import com.android.internal.telephony.gsm.GsmDataConnection; import com.android.internal.telephony.test.SimulatedRadioControl; import java.util.List; Loading Loading @@ -1381,29 +1378,6 @@ public interface Phone { */ boolean isDataConnectivityPossible(); /** * Returns the name of the network interface used by the specified APN type. */ String getInterfaceName(String apnType); /** * Returns the IP address of the network interface used by the specified * APN type. */ String getIpAddress(String apnType); /** * Returns the gateway for the network interface used by the specified APN * type. */ String getGateway(String apnType); /** * Returns the DNS servers for the network interface used by the specified * APN type. */ public String[] getDnsServers(String apnType); /** * Retrieves the unique device ID, e.g., IMEI for GSM phones and MEID for CDMA phones. */ Loading