diff options
author | Sreeram Ramachandran <sreeram@google.com> | 2014-07-19 23:21:46 -0700 |
---|---|---|
committer | Sreeram Ramachandran <sreeram@google.com> | 2014-07-22 15:46:34 -0700 |
commit | 03666c705ddabe0e7c5869ab69c2ca8b964164e9 (patch) | |
tree | c24ae1fb4a94ea49af37c122a3e194a35b37d873 | |
parent | 921ec8056a3010d0a21400f97312cf3f7d97ffaa (diff) | |
download | frameworks_base-03666c705ddabe0e7c5869ab69c2ca8b964164e9.zip frameworks_base-03666c705ddabe0e7c5869ab69c2ca8b964164e9.tar.gz frameworks_base-03666c705ddabe0e7c5869ab69c2ca8b964164e9.tar.bz2 |
Cleanup: Delete dead code.
Bug: 15413389
Change-Id: I315468832ef18ffc84174e54774ab63b86d284dc
12 files changed, 34 insertions, 404 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 4d6bd4b..175b6a5 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -413,8 +413,7 @@ class ContextImpl extends Context { registerService(CONNECTIVITY_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { IBinder b = ServiceManager.getService(CONNECTIVITY_SERVICE); - return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b), - ctx.getPackageName()); + return new ConnectivityManager(IConnectivityManager.Stub.asInterface(b)); }}); registerService(COUNTRY_DETECTOR, new StaticServiceFetcher() { diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 8de545e..13364cd 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -543,8 +543,6 @@ public class ConnectivityManager { private final IConnectivityManager mService; - private final String mPackageName; - private INetworkManagementService mNMService; /** @@ -646,23 +644,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 * 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. */ public boolean requestRouteToHost(int networkType, int hostAddress) { - InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); - - if (inetAddress == null) { - return false; - } - - return requestRouteToHostAddress(networkType, inetAddress); + return requestRouteToHostAddress(networkType, NetworkUtils.intToInetAddress(hostAddress)); } /** @@ -1260,9 +1235,8 @@ public class ConnectivityManager { * {@link #setProcessDefaultNetwork} api. */ public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { - byte[] address = hostAddress.getAddress(); try { - return mService.requestRouteToHostAddress(networkType, address, mPackageName); + return mService.requestRouteToHostAddress(networkType, hostAddress.getAddress()); } catch (RemoteException e) { return false; } @@ -1433,9 +1407,8 @@ public class ConnectivityManager { /** * {@hide} */ - public ConnectivityManager(IConnectivityManager service, String packageName) { + public ConnectivityManager(IConnectivityManager service) { mService = checkNotNull(service, "missing IConnectivityManager"); - mPackageName = checkNotNull(packageName, "missing package name"); } /** {@hide} */ diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index f61984a..8b12fb8 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -69,9 +69,7 @@ interface IConnectivityManager int stopUsingNetworkFeature(int networkType, in String feature); - boolean requestRouteToHost(int networkType, int hostAddress, String packageName); - - boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName); + boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress); /** Policy control over specific {@link NetworkStateTracker}. */ void setPolicyDataEnable(int networkType, boolean enabled); diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index 9b95305..663aa15 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -36,12 +36,6 @@ public class 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 */ public static final int RESET_IPV4_ADDRESSES = 0x01; diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 403f2c9..c1e6664 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -19,7 +19,6 @@ package android.os; import android.net.InterfaceConfiguration; import android.net.INetworkManagementEventObserver; -import android.net.LinkAddress; import android.net.NetworkStats; import android.net.RouteInfo; import android.net.UidRange; @@ -313,11 +312,6 @@ interface INetworkManagementService */ void setDnsServersForNetwork(int netId, in String[] servers, String domains); - /** - * Flush the DNS cache associated with the specified network. - */ - void flushNetworkDnsCache(int netId); - void setFirewallEnabled(boolean enabled); boolean isFirewallEnabled(); void setFirewallInterfaceRule(String iface, boolean allow); @@ -336,17 +330,6 @@ interface INetworkManagementService void removeVpnUidRanges(int netId, in UidRange[] ranges); /** - * Exempts {@code host} from the routing set up by {@link setMarkedForwardingRoute} - * All connects to {@code host} will use the global routing table - */ - void setHostExemption(in LinkAddress host); - - /** - * Clears an exemption set by {@link setHostExemption} - */ - void clearHostExemption(in LinkAddress host); - - /** * Start the clatd (464xlat) service */ void startClatd(String interfaceName); @@ -402,7 +385,6 @@ interface INetworkManagementService void removeInterfaceFromNetwork(String iface, int netId); void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid); - void removeLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid); void setDefaultNetId(int netId); void clearDefaultNetId(); diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index 760ed45..32cf286 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -79,26 +79,6 @@ static struct fieldIds { jmethodID setVendorInfo; } 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, jstring ifname, jint mask) { @@ -280,9 +260,6 @@ static jboolean android_net_utils_protectFromVpn(JNIEnv *env, jobject thiz, jint */ static JNINativeMethod gNetworkUtilMethods[] = { /* 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 }, { "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 }, diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index ca9f6eb..abee0c6 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -41,7 +41,6 @@ import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; import android.app.AlarmManager; -import android.app.AppOpsManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -52,9 +51,7 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; @@ -224,10 +221,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { 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 KeyStore mKeyStore; @@ -261,11 +254,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { 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 * 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 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 * default network @@ -450,19 +429,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { 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 private static final int INET_CONDITION_LOG_MAX_SIZE = 15; private ArrayList mInetLog; @@ -479,8 +445,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { private SettingsObserver mSettingsObserver; - private AppOpsManager mAppOpsManager; - private UserManager mUserManager; NetworkConfig[] mNetConfigs; @@ -514,8 +478,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { // sequence number of NetworkRequests private int mNextNetworkRequestId = 1; - private static final int UID_UNUSED = -1; - /** * Implements support for the legacy "one network per network type" model. * @@ -701,7 +663,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetTrackers = new NetworkStateTracker[ ConnectivityManager.MAX_NETWORK_TYPE+1]; - mCurrentLinkProperties = new LinkProperties[ConnectivityManager.MAX_NETWORK_TYPE+1]; mRadioAttributes = new RadioAttributes[ConnectivityManager.MAX_RADIO_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); mContext.registerReceiver(mProvisioningReceiver, filter); - mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); - mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); } @@ -1710,61 +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 - * 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 requestRouteToHost(int networkType, int hostAddress, String packageName) { - 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 @@ -1773,13 +1677,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { * desired * @return {@code true} on success, {@code false} on failure */ - public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress, - String packageName) { + public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) { enforceChangePermission(); if (mProtectedNetworks.contains(networkType)) { enforceConnectivityInternalPermission(); } - boolean exempt; + InetAddress addr; try { addr = InetAddress.getByAddress(hostAddress); @@ -1787,26 +1690,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (DBG) log("requestRouteToHostAddress got " + e.toString()); 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 (DBG) log("requestRouteToHostAddress on invalid network: " + networkType); @@ -1822,13 +1705,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { } return false; } + DetailedState netState; synchronized (nai) { netState = nai.networkInfo.getDetailedState(); } - if ((netState != DetailedState.CONNECTED && - netState != DetailedState.CAPTIVE_PORTAL_CHECK)) { + if (netState != DetailedState.CONNECTED && netState != DetailedState.CAPTIVE_PORTAL_CHECK) { if (VDBG) { log("requestRouteToHostAddress on down network " + "(" + networkType + ") - dropped" @@ -1836,6 +1719,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } return false; } + final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { @@ -1845,7 +1729,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { lp = nai.linkProperties; 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); return ok; } finally { @@ -1853,17 +1737,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - private boolean addRoute(LinkProperties p, RouteInfo r, boolean toDefaultTable, - 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) { + private boolean addLegacyRouteToHost(LinkProperties lp, InetAddress addr, int netId, int uid) { RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), addr); if (bestRoute == null) { bestRoute = RouteInfo.makeHostRoute(addr, lp.getInterfaceName()); @@ -1878,125 +1752,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { bestRoute = RouteInfo.makeHostRoute(addr, bestRoute.getGateway(), iface); } } - return modifyRoute(lp, bestRoute, 0, doAdd, toDefaultTable, exempt, netId, true, uid); - } - - /* - * TODO: Clean all this stuff up. Once we have UID-based routing, stuff will break due to - * incorrect tracking of mAddedRoutes, so a cleanup becomes necessary and urgent. But at - * 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; - } - - 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"); + if (VDBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface()); + try { + mNetd.addLegacyRouteForNetId(netId, bestRoute, uid); + } catch (Exception e) { + // never crash - catch them all + if (DBG) loge("Exception trying to add a route: " + e); 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; } @@ -2607,6 +2370,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { * * TODO - delete when we're sure all this functionallity is captured. */ + /* private void handleConnectivityChange(int netType, LinkProperties curLp, boolean doReset) { int resetMask = doReset ? NetworkUtils.RESET_ALL_ADDRESSES : 0; boolean exempt = ConnectivityManager.isNetworkTypeExempt(netType); @@ -2615,10 +2379,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { + " resetMask=" + resetMask); } - /* - * If a non-default network is enabled, add the host routes that - * will allow it's DNS servers to be accessed. - */ + // If a non-default network is enabled, add the host routes that + // will allow it's DNS servers to be accessed. handleDnsConfigurationChange(netType); LinkProperties newLp = null; @@ -2719,7 +2481,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO: Temporary notifying upstread change to Tethering. // @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(), PhoneConstants.REASON_LINK_PROPERTIES_CHANGED)) { 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), @@ -2736,6 +2499,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { * host routes should be set to the dns servers * returns a boolean indicating the routes changed */ + /* private boolean updateRoutes(LinkProperties newLp, LinkProperties curLp, boolean isLinkDefault, boolean exempt, int netId) { Collection<RouteInfo> routesToAdd = null; @@ -2789,6 +2553,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { return routesChanged; } + */ /** * 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 // connection will fail until the provisioning network // is enabled. + /* for (RouteInfo r : lp.getRoutes()) { removeRoute(lp, r, TO_DEFAULT_TABLE, mNetTrackers[info.getType()].getNetwork().netId); } + */ } else if (state == NetworkInfo.State.DISCONNECTED) { } else if (state == NetworkInfo.State.SUSPENDED) { } else if (state == NetworkInfo.State.CONNECTED) { @@ -3283,8 +3050,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { // TODO: Temporary allowing network configuration // change not resetting sockets. // @see bug/4455071 + /* handleConnectivityChange(info.getType(), mCurrentLinkProperties[info.getType()], false); + */ break; } 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. if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI, - hostAddr.getAddress(), null)) { + hostAddr.getAddress())) { // Wait a short time to be sure the route is established ?? log("isMobileOk:" + " wait to establish route to hostAddr=" + hostAddr); diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index f65a154..db423b0 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -117,7 +117,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final String LIMIT_GLOBAL_ALERT = "globalAlert"; class NetdResponseCode { - /* Keep in sync with system/netd/ResponseCode.h */ + /* Keep in sync with system/netd/server/ResponseCode.h */ public static final int InterfaceListResult = 110; public static final int TetherInterfaceListResult = 111; public static final int TetherDnsFwdTgtListResult = 112; @@ -1745,36 +1745,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public void setHostExemption(LinkAddress host) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - mConnector.execute("interface", "fwmark", "exempt", "add", host); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override - public void clearHostExemption(LinkAddress host) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - mConnector.execute("interface", "fwmark", "exempt", "remove", host); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override - public void flushNetworkDnsCache(int netId) { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - try { - mConnector.execute("resolver", "flushnet", netId); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - } - - @Override public void setFirewallEnabled(boolean enabled) { enforceSystemUid(); try { @@ -2019,18 +1989,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addLegacyRouteForNetId(int netId, RouteInfo routeInfo, int uid) { - modifyLegacyRouteForNetId("add", netId, routeInfo, uid); - } - - @Override - public void removeLegacyRouteForNetId(int netId, RouteInfo routeInfo, int uid) { - modifyLegacyRouteForNetId("remove", netId, routeInfo, uid); - } - - private void modifyLegacyRouteForNetId(String action, int netId, RouteInfo routeInfo, int uid) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - final Command cmd = new Command("network", "route", "legacy", uid, action, netId); + final Command cmd = new Command("network", "route", "legacy", uid, "add", netId); // create triplet: interface dest-ip-addr/prefixlength gateway-ip-addr final LinkAddress la = routeInfo.getDestinationLinkAddress(); diff --git a/services/core/java/com/android/server/NsdService.java b/services/core/java/com/android/server/NsdService.java index fe97c71..cf7e65c 100644 --- a/services/core/java/com/android/server/NsdService.java +++ b/services/core/java/com/android/server/NsdService.java @@ -603,7 +603,7 @@ public class NsdService extends INsdManager.Stub { return mUniqueId; } - /* These should be in sync with system/netd/mDnsResponseCode.h */ + /* These should be in sync with system/netd/server/ResponseCode.h */ class NativeResponseCode { public static final int SERVICE_DISCOVERY_FAILED = 602; public static final int SERVICE_FOUND = 603; diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index 01a2fc2..d948942 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -724,14 +724,6 @@ public class Tethering extends BaseNetworkObserver { return retVal; } - //TODO: Temporary handling upstream change triggered without - // CONNECTIVITY_ACTION. Only to accomodate interface - // switch during HO. - // @see bug/4455071 - public void handleTetherIfaceChange() { - mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED); - } - class TetherInterfaceSM extends StateMachine { // notification from the master SM that it's not in tether mode static final int CMD_TETHER_MODE_DEAD = 1; diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index d15254b..7b68d55 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -488,18 +488,6 @@ public class Vpn { return tun; } - /** - * Check if a given address is covered by the VPN's routing rules. - */ - public boolean isAddressCovered(InetAddress address) { - synchronized (Vpn.this) { - if (!isRunningLocked()) { - return false; - } - return RouteInfo.selectBestRoute(mConfig.routes, address) != null; - } - } - private boolean isRunningLocked() { return mVpnUsers != null; } diff --git a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java index 88aaafc..9e3dec8 100644 --- a/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/ConnectivityServiceTest.java @@ -162,12 +162,10 @@ public class ConnectivityServiceTest extends AndroidTestCase { mTrackerHandler.obtainMessage(EVENT_STATE_CHANGED, mMobile.info).sendToTarget(); nextConnBroadcast.get(); - // verify that both routes were added and DNS was flushed + // verify that both routes were added int mobileNetId = mMobile.tracker.getNetwork().netId; verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V4)); verify(mNetManager).addRoute(eq(mobileNetId), eq(MOBILE_ROUTE_V6)); - verify(mNetManager).flushNetworkDnsCache(mobileNetId); - } public void testMobileWifiHandoff() throws Exception { @@ -204,7 +202,6 @@ public class ConnectivityServiceTest extends AndroidTestCase { int wifiNetId = mWifi.tracker.getNetwork().netId; verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V4)); verify(mNetManager).addRoute(eq(wifiNetId), eq(WIFI_ROUTE_V6)); - verify(mNetManager).flushNetworkDnsCache(wifiNetId); verify(mMobile.tracker).teardown(); int mobileNetId = mMobile.tracker.getNetwork().netId; |