Cleanup: Delete dead code.
Bug: 15413389 Change-Id: I315468832ef18ffc84174e54774ab63b86d284dc
This commit is contained in:
@@ -543,8 +543,6 @@ public class ConnectivityManager {
|
|||||||
|
|
||||||
private final IConnectivityManager mService;
|
private final IConnectivityManager mService;
|
||||||
|
|
||||||
private final String mPackageName;
|
|
||||||
|
|
||||||
private INetworkManagementService mNMService;
|
private INetworkManagementService mNMService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -645,23 +643,6 @@ public class ConnectivityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the given network type should be exempt from VPN routing rules
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static boolean isNetworkTypeExempt(int networkType) {
|
|
||||||
switch (networkType) {
|
|
||||||
case TYPE_MOBILE_MMS:
|
|
||||||
case TYPE_MOBILE_SUPL:
|
|
||||||
case TYPE_MOBILE_HIPRI:
|
|
||||||
case TYPE_MOBILE_IA:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the preferred network type. When the device has more
|
* Specifies the preferred network type. When the device has more
|
||||||
* than one type available the preferred network type will be used.
|
* than one type available the preferred network type will be used.
|
||||||
@@ -1236,13 +1217,7 @@ public class ConnectivityManager {
|
|||||||
* {@link #setProcessDefaultNetwork} and {@link Network#getSocketFactory} api.
|
* {@link #setProcessDefaultNetwork} and {@link Network#getSocketFactory} api.
|
||||||
*/
|
*/
|
||||||
public boolean requestRouteToHost(int networkType, int hostAddress) {
|
public boolean requestRouteToHost(int networkType, int hostAddress) {
|
||||||
InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
|
return requestRouteToHostAddress(networkType, NetworkUtils.intToInetAddress(hostAddress));
|
||||||
|
|
||||||
if (inetAddress == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestRouteToHostAddress(networkType, inetAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1260,9 +1235,8 @@ public class ConnectivityManager {
|
|||||||
* {@link #setProcessDefaultNetwork} api.
|
* {@link #setProcessDefaultNetwork} api.
|
||||||
*/
|
*/
|
||||||
public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
|
public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
|
||||||
byte[] address = hostAddress.getAddress();
|
|
||||||
try {
|
try {
|
||||||
return mService.requestRouteToHostAddress(networkType, address, mPackageName);
|
return mService.requestRouteToHostAddress(networkType, hostAddress.getAddress());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1433,9 +1407,8 @@ public class ConnectivityManager {
|
|||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public ConnectivityManager(IConnectivityManager service, String packageName) {
|
public ConnectivityManager(IConnectivityManager service) {
|
||||||
mService = checkNotNull(service, "missing IConnectivityManager");
|
mService = checkNotNull(service, "missing IConnectivityManager");
|
||||||
mPackageName = checkNotNull(packageName, "missing package name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
|
|||||||
@@ -69,9 +69,7 @@ interface IConnectivityManager
|
|||||||
|
|
||||||
int stopUsingNetworkFeature(int networkType, in String feature);
|
int stopUsingNetworkFeature(int networkType, in String feature);
|
||||||
|
|
||||||
boolean requestRouteToHost(int networkType, int hostAddress, String packageName);
|
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);
|
||||||
|
|
||||||
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);
|
|
||||||
|
|
||||||
/** Policy control over specific {@link NetworkStateTracker}. */
|
/** Policy control over specific {@link NetworkStateTracker}. */
|
||||||
void setPolicyDataEnable(int networkType, boolean enabled);
|
void setPolicyDataEnable(int networkType, boolean enabled);
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ public class NetworkUtils {
|
|||||||
|
|
||||||
private static final String TAG = "NetworkUtils";
|
private static final String TAG = "NetworkUtils";
|
||||||
|
|
||||||
/** Bring the named network interface up. */
|
|
||||||
public native static int enableInterface(String interfaceName);
|
|
||||||
|
|
||||||
/** Bring the named network interface down. */
|
|
||||||
public native static int disableInterface(String interfaceName);
|
|
||||||
|
|
||||||
/** Setting bit 0 indicates reseting of IPv4 addresses required */
|
/** Setting bit 0 indicates reseting of IPv4 addresses required */
|
||||||
public static final int RESET_IPV4_ADDRESSES = 0x01;
|
public static final int RESET_IPV4_ADDRESSES = 0x01;
|
||||||
|
|
||||||
|
|||||||
@@ -79,26 +79,6 @@ static struct fieldIds {
|
|||||||
jmethodID setVendorInfo;
|
jmethodID setVendorInfo;
|
||||||
} dhcpResultsFieldIds;
|
} dhcpResultsFieldIds;
|
||||||
|
|
||||||
static jint android_net_utils_enableInterface(JNIEnv* env, jobject clazz, jstring ifname)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
const char *nameStr = env->GetStringUTFChars(ifname, NULL);
|
|
||||||
result = ::ifc_enable(nameStr);
|
|
||||||
env->ReleaseStringUTFChars(ifname, nameStr);
|
|
||||||
return (jint)result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static jint android_net_utils_disableInterface(JNIEnv* env, jobject clazz, jstring ifname)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
const char *nameStr = env->GetStringUTFChars(ifname, NULL);
|
|
||||||
result = ::ifc_disable(nameStr);
|
|
||||||
env->ReleaseStringUTFChars(ifname, nameStr);
|
|
||||||
return (jint)result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static jint android_net_utils_resetConnections(JNIEnv* env, jobject clazz,
|
static jint android_net_utils_resetConnections(JNIEnv* env, jobject clazz,
|
||||||
jstring ifname, jint mask)
|
jstring ifname, jint mask)
|
||||||
{
|
{
|
||||||
@@ -280,9 +260,6 @@ static jboolean android_net_utils_protectFromVpn(JNIEnv *env, jobject thiz, jint
|
|||||||
*/
|
*/
|
||||||
static JNINativeMethod gNetworkUtilMethods[] = {
|
static JNINativeMethod gNetworkUtilMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
|
|
||||||
{ "enableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_enableInterface },
|
|
||||||
{ "disableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_disableInterface },
|
|
||||||
{ "resetConnections", "(Ljava/lang/String;I)I", (void *)android_net_utils_resetConnections },
|
{ "resetConnections", "(Ljava/lang/String;I)I", (void *)android_net_utils_resetConnections },
|
||||||
{ "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpResults;)Z", (void *)android_net_utils_runDhcp },
|
{ "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpResults;)Z", (void *)android_net_utils_runDhcp },
|
||||||
{ "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpResults;)Z", (void *)android_net_utils_runDhcpRenew },
|
{ "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpResults;)Z", (void *)android_net_utils_runDhcpRenew },
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL;
|
|||||||
import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
|
import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.AppOpsManager;
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -52,9 +51,7 @@ import android.content.Context;
|
|||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -224,10 +221,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
AlarmManager mAlarmManager;
|
AlarmManager mAlarmManager;
|
||||||
|
|
||||||
// used in recursive route setting to add gateways for the host for which
|
|
||||||
// a host route was requested.
|
|
||||||
private static final int MAX_HOSTROUTE_CYCLE_COUNT = 10;
|
|
||||||
|
|
||||||
private Tethering mTethering;
|
private Tethering mTethering;
|
||||||
|
|
||||||
private KeyStore mKeyStore;
|
private KeyStore mKeyStore;
|
||||||
@@ -260,11 +253,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
*/
|
*/
|
||||||
private CaptivePortalTracker mCaptivePortalTracker;
|
private CaptivePortalTracker mCaptivePortalTracker;
|
||||||
|
|
||||||
/**
|
|
||||||
* The link properties that define the current links
|
|
||||||
*/
|
|
||||||
private LinkProperties mCurrentLinkProperties[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A per Net list of the PID's that requested access to the net
|
* A per Net list of the PID's that requested access to the net
|
||||||
* used both as a refcount and for per-PID DNS selection
|
* used both as a refcount and for per-PID DNS selection
|
||||||
@@ -297,15 +285,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
private static final int ENABLED = 1;
|
private static final int ENABLED = 1;
|
||||||
private static final int DISABLED = 0;
|
private static final int DISABLED = 0;
|
||||||
|
|
||||||
private static final boolean ADD = true;
|
|
||||||
private static final boolean REMOVE = false;
|
|
||||||
|
|
||||||
private static final boolean TO_DEFAULT_TABLE = true;
|
|
||||||
private static final boolean TO_SECONDARY_TABLE = false;
|
|
||||||
|
|
||||||
private static final boolean EXEMPT = true;
|
|
||||||
private static final boolean UNEXEMPT = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used internally as a delayed event to make us switch back to the
|
* used internally as a delayed event to make us switch back to the
|
||||||
* default network
|
* default network
|
||||||
@@ -450,19 +429,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private InetAddress mDefaultDns;
|
private InetAddress mDefaultDns;
|
||||||
|
|
||||||
// Lock for protecting access to mAddedRoutes and mExemptAddresses
|
|
||||||
private final Object mRoutesLock = new Object();
|
|
||||||
|
|
||||||
// this collection is used to refcount the added routes - if there are none left
|
|
||||||
// it's time to remove the route from the route table
|
|
||||||
@GuardedBy("mRoutesLock")
|
|
||||||
private Collection<RouteInfo> mAddedRoutes = new ArrayList<RouteInfo>();
|
|
||||||
|
|
||||||
// this collection corresponds to the entries of mAddedRoutes that have routing exemptions
|
|
||||||
// used to handle cleanup of exempt rules
|
|
||||||
@GuardedBy("mRoutesLock")
|
|
||||||
private Collection<LinkAddress> mExemptAddresses = new ArrayList<LinkAddress>();
|
|
||||||
|
|
||||||
// used in DBG mode to track inet condition reports
|
// used in DBG mode to track inet condition reports
|
||||||
private static final int INET_CONDITION_LOG_MAX_SIZE = 15;
|
private static final int INET_CONDITION_LOG_MAX_SIZE = 15;
|
||||||
private ArrayList mInetLog;
|
private ArrayList mInetLog;
|
||||||
@@ -479,8 +445,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
private SettingsObserver mSettingsObserver;
|
private SettingsObserver mSettingsObserver;
|
||||||
|
|
||||||
private AppOpsManager mAppOpsManager;
|
|
||||||
|
|
||||||
private UserManager mUserManager;
|
private UserManager mUserManager;
|
||||||
|
|
||||||
NetworkConfig[] mNetConfigs;
|
NetworkConfig[] mNetConfigs;
|
||||||
@@ -514,8 +478,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// sequence number of NetworkRequests
|
// sequence number of NetworkRequests
|
||||||
private int mNextNetworkRequestId = 1;
|
private int mNextNetworkRequestId = 1;
|
||||||
|
|
||||||
private static final int UID_UNUSED = -1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements support for the legacy "one network per network type" model.
|
* Implements support for the legacy "one network per network type" model.
|
||||||
*
|
*
|
||||||
@@ -701,7 +663,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
mNetTrackers = new NetworkStateTracker[
|
mNetTrackers = new NetworkStateTracker[
|
||||||
ConnectivityManager.MAX_NETWORK_TYPE+1];
|
ConnectivityManager.MAX_NETWORK_TYPE+1];
|
||||||
mCurrentLinkProperties = new LinkProperties[ConnectivityManager.MAX_NETWORK_TYPE+1];
|
|
||||||
|
|
||||||
mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1];
|
mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_TYPE+1];
|
||||||
mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1];
|
mNetConfigs = new NetworkConfig[ConnectivityManager.MAX_NETWORK_TYPE+1];
|
||||||
@@ -884,8 +845,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
filter.addAction(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
|
filter.addAction(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
|
||||||
mContext.registerReceiver(mProvisioningReceiver, filter);
|
mContext.registerReceiver(mProvisioningReceiver, filter);
|
||||||
|
|
||||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
|
||||||
|
|
||||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1710,42 +1669,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the address falls into any of currently running VPN's route's.
|
|
||||||
*/
|
|
||||||
private boolean isAddressUnderVpn(InetAddress address) {
|
|
||||||
synchronized (mVpns) {
|
|
||||||
synchronized (mRoutesLock) {
|
|
||||||
int uid = UserHandle.getCallingUserId();
|
|
||||||
Vpn vpn = mVpns.get(uid);
|
|
||||||
if (vpn == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if an exemption exists for this address.
|
|
||||||
for (LinkAddress destination : mExemptAddresses) {
|
|
||||||
if (!NetworkUtils.addressTypeMatches(address, destination.getAddress())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int prefix = destination.getPrefixLength();
|
|
||||||
InetAddress addrMasked = NetworkUtils.getNetworkPart(address, prefix);
|
|
||||||
InetAddress destMasked = NetworkUtils.getNetworkPart(destination.getAddress(),
|
|
||||||
prefix);
|
|
||||||
|
|
||||||
if (addrMasked.equals(destMasked)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally check if the address is covered by the VPN.
|
|
||||||
return vpn.isAddressCovered(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use requestRouteToHostAddress instead
|
|
||||||
*
|
|
||||||
* Ensure that a network route exists to deliver traffic to the specified
|
* Ensure that a network route exists to deliver traffic to the specified
|
||||||
* host via the specified network interface.
|
* host via the specified network interface.
|
||||||
* @param networkType the type of the network over which traffic to the
|
* @param networkType the type of the network over which traffic to the
|
||||||
@@ -1754,32 +1677,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* desired
|
* desired
|
||||||
* @return {@code true} on success, {@code false} on failure
|
* @return {@code true} on success, {@code false} on failure
|
||||||
*/
|
*/
|
||||||
public boolean requestRouteToHost(int networkType, int hostAddress, String packageName) {
|
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) {
|
||||||
InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
|
|
||||||
|
|
||||||
if (inetAddress == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestRouteToHostAddress(networkType, inetAddress.getAddress(), packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure that a network route exists to deliver traffic to the specified
|
|
||||||
* host via the specified network interface.
|
|
||||||
* @param networkType the type of the network over which traffic to the
|
|
||||||
* specified host is to be routed
|
|
||||||
* @param hostAddress the IP address of the host to which the route is
|
|
||||||
* desired
|
|
||||||
* @return {@code true} on success, {@code false} on failure
|
|
||||||
*/
|
|
||||||
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress,
|
|
||||||
String packageName) {
|
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
if (mProtectedNetworks.contains(networkType)) {
|
if (mProtectedNetworks.contains(networkType)) {
|
||||||
enforceConnectivityInternalPermission();
|
enforceConnectivityInternalPermission();
|
||||||
}
|
}
|
||||||
boolean exempt;
|
|
||||||
InetAddress addr;
|
InetAddress addr;
|
||||||
try {
|
try {
|
||||||
addr = InetAddress.getByAddress(hostAddress);
|
addr = InetAddress.getByAddress(hostAddress);
|
||||||
@@ -1787,26 +1690,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (DBG) log("requestRouteToHostAddress got " + e.toString());
|
if (DBG) log("requestRouteToHostAddress got " + e.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// System apps may request routes bypassing the VPN to keep other networks working.
|
|
||||||
if (Binder.getCallingUid() == Process.SYSTEM_UID) {
|
|
||||||
exempt = true;
|
|
||||||
} else {
|
|
||||||
mAppOpsManager.checkPackage(Binder.getCallingUid(), packageName);
|
|
||||||
try {
|
|
||||||
ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(packageName,
|
|
||||||
0);
|
|
||||||
exempt = (info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
throw new IllegalArgumentException("Failed to find calling package details", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Non-exempt routeToHost's can only be added if the host is not covered by the VPN.
|
|
||||||
// This can be either because the VPN's routes do not cover the destination or a
|
|
||||||
// system application added an exemption that covers this destination.
|
|
||||||
if (!exempt && isAddressUnderVpn(addr)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
|
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
|
||||||
if (DBG) log("requestRouteToHostAddress on invalid network: " + networkType);
|
if (DBG) log("requestRouteToHostAddress on invalid network: " + networkType);
|
||||||
@@ -1822,13 +1705,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailedState netState;
|
DetailedState netState;
|
||||||
synchronized (nai) {
|
synchronized (nai) {
|
||||||
netState = nai.networkInfo.getDetailedState();
|
netState = nai.networkInfo.getDetailedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((netState != DetailedState.CONNECTED &&
|
if (netState != DetailedState.CONNECTED && netState != DetailedState.CAPTIVE_PORTAL_CHECK) {
|
||||||
netState != DetailedState.CAPTIVE_PORTAL_CHECK)) {
|
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
log("requestRouteToHostAddress on down network "
|
log("requestRouteToHostAddress on down network "
|
||||||
+ "(" + networkType + ") - dropped"
|
+ "(" + networkType + ") - dropped"
|
||||||
@@ -1836,6 +1719,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int uid = Binder.getCallingUid();
|
final int uid = Binder.getCallingUid();
|
||||||
final long token = Binder.clearCallingIdentity();
|
final long token = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -1845,7 +1729,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
lp = nai.linkProperties;
|
lp = nai.linkProperties;
|
||||||
netId = nai.network.netId;
|
netId = nai.network.netId;
|
||||||
}
|
}
|
||||||
boolean ok = modifyRouteToAddress(lp, addr, ADD, TO_DEFAULT_TABLE, exempt, netId, uid);
|
boolean ok = addLegacyRouteToHost(lp, addr, netId, uid);
|
||||||
if (DBG) log("requestRouteToHostAddress ok=" + ok);
|
if (DBG) log("requestRouteToHostAddress ok=" + ok);
|
||||||
return ok;
|
return ok;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1853,17 +1737,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addRoute(LinkProperties p, RouteInfo r, boolean toDefaultTable,
|
private boolean addLegacyRouteToHost(LinkProperties lp, InetAddress addr, int netId, int uid) {
|
||||||
boolean exempt, int netId) {
|
|
||||||
return modifyRoute(p, r, 0, ADD, toDefaultTable, exempt, netId, false, UID_UNUSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean removeRoute(LinkProperties p, RouteInfo r, boolean toDefaultTable, int netId) {
|
|
||||||
return modifyRoute(p, r, 0, REMOVE, toDefaultTable, UNEXEMPT, netId, false, UID_UNUSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean modifyRouteToAddress(LinkProperties lp, InetAddress addr, boolean doAdd,
|
|
||||||
boolean toDefaultTable, boolean exempt, int netId, int uid) {
|
|
||||||
RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), addr);
|
RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), addr);
|
||||||
if (bestRoute == null) {
|
if (bestRoute == null) {
|
||||||
bestRoute = RouteInfo.makeHostRoute(addr, lp.getInterfaceName());
|
bestRoute = RouteInfo.makeHostRoute(addr, lp.getInterfaceName());
|
||||||
@@ -1878,125 +1752,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
bestRoute = RouteInfo.makeHostRoute(addr, bestRoute.getGateway(), iface);
|
bestRoute = RouteInfo.makeHostRoute(addr, bestRoute.getGateway(), iface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modifyRoute(lp, bestRoute, 0, doAdd, toDefaultTable, exempt, netId, true, uid);
|
if (VDBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface());
|
||||||
}
|
try {
|
||||||
|
mNetd.addLegacyRouteForNetId(netId, bestRoute, uid);
|
||||||
/*
|
} catch (Exception e) {
|
||||||
* TODO: Clean all this stuff up. Once we have UID-based routing, stuff will break due to
|
// never crash - catch them all
|
||||||
* incorrect tracking of mAddedRoutes, so a cleanup becomes necessary and urgent. But at
|
if (DBG) loge("Exception trying to add a route: " + e);
|
||||||
* the same time, there'll be no more need to track mAddedRoutes or mExemptAddresses,
|
|
||||||
* or even have the concept of an exempt address, or do things like "selectBestRoute", or
|
|
||||||
* determine "default" vs "secondary" table, etc., so the cleanup becomes possible.
|
|
||||||
*/
|
|
||||||
private boolean modifyRoute(LinkProperties lp, RouteInfo r, int cycleCount, boolean doAdd,
|
|
||||||
boolean toDefaultTable, boolean exempt, int netId, boolean legacy, int uid) {
|
|
||||||
if ((lp == null) || (r == null)) {
|
|
||||||
if (DBG) log("modifyRoute got unexpected null: " + lp + ", " + r);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cycleCount > MAX_HOSTROUTE_CYCLE_COUNT) {
|
|
||||||
loge("Error modifying route - too much recursion");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String ifaceName = r.getInterface();
|
|
||||||
if(ifaceName == null) {
|
|
||||||
loge("Error modifying route - no interface name");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.hasGateway()) {
|
|
||||||
RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), r.getGateway());
|
|
||||||
if (bestRoute != null) {
|
|
||||||
if (bestRoute.getGateway().equals(r.getGateway())) {
|
|
||||||
// if there is no better route, add the implied hostroute for our gateway
|
|
||||||
bestRoute = RouteInfo.makeHostRoute(r.getGateway(), ifaceName);
|
|
||||||
} else {
|
|
||||||
// if we will connect to our gateway through another route, add a direct
|
|
||||||
// route to it's gateway
|
|
||||||
bestRoute = RouteInfo.makeHostRoute(r.getGateway(),
|
|
||||||
bestRoute.getGateway(),
|
|
||||||
ifaceName);
|
|
||||||
}
|
|
||||||
modifyRoute(lp, bestRoute, cycleCount+1, doAdd, toDefaultTable, exempt, netId,
|
|
||||||
legacy, uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (doAdd) {
|
|
||||||
if (VDBG) log("Adding " + r + " for interface " + ifaceName);
|
|
||||||
try {
|
|
||||||
if (toDefaultTable) {
|
|
||||||
synchronized (mRoutesLock) {
|
|
||||||
// only track default table - only one apps can effect
|
|
||||||
mAddedRoutes.add(r);
|
|
||||||
if (legacy) {
|
|
||||||
mNetd.addLegacyRouteForNetId(netId, r, uid);
|
|
||||||
} else {
|
|
||||||
mNetd.addRoute(netId, r);
|
|
||||||
}
|
|
||||||
if (exempt) {
|
|
||||||
LinkAddress dest = r.getDestinationLinkAddress();
|
|
||||||
if (!mExemptAddresses.contains(dest)) {
|
|
||||||
mNetd.setHostExemption(dest);
|
|
||||||
mExemptAddresses.add(dest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (legacy) {
|
|
||||||
mNetd.addLegacyRouteForNetId(netId, r, uid);
|
|
||||||
} else {
|
|
||||||
mNetd.addRoute(netId, r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// never crash - catch them all
|
|
||||||
if (DBG) loge("Exception trying to add a route: " + e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// if we remove this one and there are no more like it, then refcount==0 and
|
|
||||||
// we can remove it from the table
|
|
||||||
if (toDefaultTable) {
|
|
||||||
synchronized (mRoutesLock) {
|
|
||||||
mAddedRoutes.remove(r);
|
|
||||||
if (mAddedRoutes.contains(r) == false) {
|
|
||||||
if (VDBG) log("Removing " + r + " for interface " + ifaceName);
|
|
||||||
try {
|
|
||||||
if (legacy) {
|
|
||||||
mNetd.removeLegacyRouteForNetId(netId, r, uid);
|
|
||||||
} else {
|
|
||||||
mNetd.removeRoute(netId, r);
|
|
||||||
}
|
|
||||||
LinkAddress dest = r.getDestinationLinkAddress();
|
|
||||||
if (mExemptAddresses.contains(dest)) {
|
|
||||||
mNetd.clearHostExemption(dest);
|
|
||||||
mExemptAddresses.remove(dest);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// never crash - catch them all
|
|
||||||
if (VDBG) loge("Exception trying to remove a route: " + e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (VDBG) log("not removing " + r + " as it's still in use");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (VDBG) log("Removing " + r + " for interface " + ifaceName);
|
|
||||||
try {
|
|
||||||
if (legacy) {
|
|
||||||
mNetd.removeLegacyRouteForNetId(netId, r, uid);
|
|
||||||
} else {
|
|
||||||
mNetd.removeRoute(netId, r);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// never crash - catch them all
|
|
||||||
if (VDBG) loge("Exception trying to remove a route: " + e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2607,6 +2370,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
*
|
*
|
||||||
* TODO - delete when we're sure all this functionallity is captured.
|
* TODO - delete when we're sure all this functionallity is captured.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
private void handleConnectivityChange(int netType, LinkProperties curLp, boolean doReset) {
|
private void handleConnectivityChange(int netType, LinkProperties curLp, boolean doReset) {
|
||||||
int resetMask = doReset ? NetworkUtils.RESET_ALL_ADDRESSES : 0;
|
int resetMask = doReset ? NetworkUtils.RESET_ALL_ADDRESSES : 0;
|
||||||
boolean exempt = ConnectivityManager.isNetworkTypeExempt(netType);
|
boolean exempt = ConnectivityManager.isNetworkTypeExempt(netType);
|
||||||
@@ -2615,10 +2379,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
+ " resetMask=" + resetMask);
|
+ " resetMask=" + resetMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If a non-default network is enabled, add the host routes that
|
||||||
* If a non-default network is enabled, add the host routes that
|
// will allow it's DNS servers to be accessed.
|
||||||
* will allow it's DNS servers to be accessed.
|
|
||||||
*/
|
|
||||||
handleDnsConfigurationChange(netType);
|
handleDnsConfigurationChange(netType);
|
||||||
|
|
||||||
LinkProperties newLp = null;
|
LinkProperties newLp = null;
|
||||||
@@ -2719,7 +2481,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
// TODO: Temporary notifying upstread change to Tethering.
|
// TODO: Temporary notifying upstread change to Tethering.
|
||||||
// @see bug/4455071
|
// @see bug/4455071
|
||||||
/** Notify TetheringService if interface name has been changed. */
|
// Notify TetheringService if interface name has been changed.
|
||||||
if (TextUtils.equals(mNetTrackers[netType].getNetworkInfo().getReason(),
|
if (TextUtils.equals(mNetTrackers[netType].getNetworkInfo().getReason(),
|
||||||
PhoneConstants.REASON_LINK_PROPERTIES_CHANGED)) {
|
PhoneConstants.REASON_LINK_PROPERTIES_CHANGED)) {
|
||||||
if (isTetheringSupported()) {
|
if (isTetheringSupported()) {
|
||||||
@@ -2727,6 +2489,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add and remove routes using the old properties (null if not previously connected),
|
* Add and remove routes using the old properties (null if not previously connected),
|
||||||
@@ -2736,6 +2499,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
* host routes should be set to the dns servers
|
* host routes should be set to the dns servers
|
||||||
* returns a boolean indicating the routes changed
|
* returns a boolean indicating the routes changed
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
private boolean updateRoutes(LinkProperties newLp, LinkProperties curLp,
|
private boolean updateRoutes(LinkProperties newLp, LinkProperties curLp,
|
||||||
boolean isLinkDefault, boolean exempt, int netId) {
|
boolean isLinkDefault, boolean exempt, int netId) {
|
||||||
Collection<RouteInfo> routesToAdd = null;
|
Collection<RouteInfo> routesToAdd = null;
|
||||||
@@ -2789,6 +2553,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
return routesChanged;
|
return routesChanged;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the network specific MTU size from reources.
|
* Reads the network specific MTU size from reources.
|
||||||
@@ -3264,10 +3029,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// any activity by applications trying to use this
|
// any activity by applications trying to use this
|
||||||
// connection will fail until the provisioning network
|
// connection will fail until the provisioning network
|
||||||
// is enabled.
|
// is enabled.
|
||||||
|
/*
|
||||||
for (RouteInfo r : lp.getRoutes()) {
|
for (RouteInfo r : lp.getRoutes()) {
|
||||||
removeRoute(lp, r, TO_DEFAULT_TABLE,
|
removeRoute(lp, r, TO_DEFAULT_TABLE,
|
||||||
mNetTrackers[info.getType()].getNetwork().netId);
|
mNetTrackers[info.getType()].getNetwork().netId);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} else if (state == NetworkInfo.State.DISCONNECTED) {
|
} else if (state == NetworkInfo.State.DISCONNECTED) {
|
||||||
} else if (state == NetworkInfo.State.SUSPENDED) {
|
} else if (state == NetworkInfo.State.SUSPENDED) {
|
||||||
} else if (state == NetworkInfo.State.CONNECTED) {
|
} else if (state == NetworkInfo.State.CONNECTED) {
|
||||||
@@ -3283,8 +3050,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// TODO: Temporary allowing network configuration
|
// TODO: Temporary allowing network configuration
|
||||||
// change not resetting sockets.
|
// change not resetting sockets.
|
||||||
// @see bug/4455071
|
// @see bug/4455071
|
||||||
|
/*
|
||||||
handleConnectivityChange(info.getType(), mCurrentLinkProperties[info.getType()],
|
handleConnectivityChange(info.getType(), mCurrentLinkProperties[info.getType()],
|
||||||
false);
|
false);
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NetworkStateTracker.EVENT_NETWORK_SUBTYPE_CHANGED: {
|
case NetworkStateTracker.EVENT_NETWORK_SUBTYPE_CHANGED: {
|
||||||
@@ -4683,7 +4452,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
// Make a route to host so we check the specific interface.
|
// Make a route to host so we check the specific interface.
|
||||||
if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
|
if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
|
||||||
hostAddr.getAddress(), null)) {
|
hostAddr.getAddress())) {
|
||||||
// Wait a short time to be sure the route is established ??
|
// Wait a short time to be sure the route is established ??
|
||||||
log("isMobileOk:"
|
log("isMobileOk:"
|
||||||
+ " wait to establish route to hostAddr=" + hostAddr);
|
+ " wait to establish route to hostAddr=" + hostAddr);
|
||||||
|
|||||||
@@ -162,12 +162,10 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
|||||||
mTrackerHandler.obtainMessage(EVENT_STATE_CHANGED, mMobile.info).sendToTarget();
|
mTrackerHandler.obtainMessage(EVENT_STATE_CHANGED, mMobile.info).sendToTarget();
|
||||||
nextConnBroadcast.get();
|
nextConnBroadcast.get();
|
||||||
|
|
||||||
// verify that both routes were added and DNS was flushed
|
// verify that both routes were added
|
||||||
int mobileNetId = mMobile.tracker.getNetwork().netId;
|
int mobileNetId = mMobile.tracker.getNetwork().netId;
|
||||||
verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V4));
|
verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V4));
|
||||||
verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V6));
|
verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V6));
|
||||||
verify(mNetManager).flushNetworkDnsCache(mobileNetId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMobileWifiHandoff() throws Exception {
|
public void testMobileWifiHandoff() throws Exception {
|
||||||
@@ -204,7 +202,6 @@ public class ConnectivityServiceTest extends AndroidTestCase {
|
|||||||
int wifiNetId = mWifi.tracker.getNetwork().netId;
|
int wifiNetId = mWifi.tracker.getNetwork().netId;
|
||||||
verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V4));
|
verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V4));
|
||||||
verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V6));
|
verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V6));
|
||||||
verify(mNetManager).flushNetworkDnsCache(wifiNetId);
|
|
||||||
verify(mMobile.tracker).teardown();
|
verify(mMobile.tracker).teardown();
|
||||||
|
|
||||||
int mobileNetId = mMobile.tracker.getNetwork().netId;
|
int mobileNetId = mMobile.tracker.getNetwork().netId;
|
||||||
|
|||||||
Reference in New Issue
Block a user