Loading core/java/android/net/NetworkAgent.java +4 −4 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public abstract class NetworkAgent extends Handler { private volatile AsyncChannel mAsyncChannel; private final String LOG_TAG; private static final boolean DBG = true; private static final boolean VDBG = true; private static final boolean VDBG = false; private final Context mContext; private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>(); Loading Loading @@ -134,7 +134,7 @@ public abstract class NetworkAgent extends Handler { throw new IllegalArgumentException(); } if (DBG) log("Registering NetworkAgent"); if (VDBG) log("Registering NetworkAgent"); ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( Context.CONNECTIVITY_SERVICE); cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni), Loading @@ -148,7 +148,7 @@ public abstract class NetworkAgent extends Handler { if (mAsyncChannel != null) { log("Received new connection while already connected!"); } else { if (DBG) log("NetworkAgent fully connected"); if (VDBG) log("NetworkAgent fully connected"); AsyncChannel ac = new AsyncChannel(); ac.connected(null, this, msg.replyTo); ac.replyToMessage(msg, AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED, Loading @@ -164,7 +164,7 @@ public abstract class NetworkAgent extends Handler { break; } case AsyncChannel.CMD_CHANNEL_DISCONNECT: { if (DBG) log("CMD_CHANNEL_DISCONNECT"); if (VDBG) log("CMD_CHANNEL_DISCONNECT"); if (mAsyncChannel != null) mAsyncChannel.disconnect(); break; } Loading core/java/android/net/NetworkFactory.java +4 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.util.Protocol; **/ public class NetworkFactory extends Handler { private static final boolean DBG = true; private static final boolean VDBG = false; private static final int BASE = Protocol.BASE_NETWORK_FACTORY; /** Loading Loading @@ -164,13 +165,14 @@ public class NetworkFactory extends Handler { private void handleAddRequest(NetworkRequest request, int score) { NetworkRequestInfo n = mNetworkRequests.get(request.requestId); if (n == null) { if (DBG) log("got request " + request + " with score " + score); n = new NetworkRequestInfo(request, score); mNetworkRequests.put(n.request.requestId, n); } else { if (VDBG) log("new score " + score + " for exisiting request " + request); n.score = score; } if (DBG) log("got request " + request + " with score " + score); if (DBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter); if (VDBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter); evalRequest(n); } Loading services/core/java/com/android/server/ConnectivityService.java +67 −36 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private static final String TAG = "ConnectivityService"; private static final boolean DBG = true; private static final boolean VDBG = true; // STOPSHIP private static final boolean VDBG = false; // network sampling debugging private static final boolean SAMPLE_DBG = false; Loading Loading @@ -830,11 +830,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { // network is blocked; clone and override state info = new NetworkInfo(info); info.setDetailedState(DetailedState.BLOCKED, null, null); if (VDBG) log("returning Blocked NetworkInfo"); if (DBG) log("returning Blocked NetworkInfo"); } if (mLockdownTracker != null) { info = mLockdownTracker.augmentNetworkInfo(info); if (VDBG) log("returning Locked NetworkInfo"); if (DBG) log("returning Locked NetworkInfo"); } return info; } Loading Loading @@ -1202,7 +1202,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { bestRoute = RouteInfo.makeHostRoute(addr, bestRoute.getGateway(), iface); } } if (VDBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface()); if (DBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface()); try { mNetd.addLegacyRouteForNetId(netId, bestRoute, uid); } catch (Exception e) { Loading Loading @@ -1401,7 +1401,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mInitialBroadcast = new Intent(intent); } intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); if (VDBG) { if (DBG) { log("sendStickyBroadcast: action=" + intent.getAction()); } Loading Loading @@ -1558,7 +1558,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } try { if (VDBG) log("Setting MTU size: " + iface + ", " + mtu); if (DBG) log("Setting MTU size: " + iface + ", " + mtu); mNetd.setMtu(iface, mtu); } catch (Exception e) { Slog.e(TAG, "exception in setMtu()" + e); Loading @@ -1579,7 +1579,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } if (values == null || values.length != 6) { if (VDBG) log("Invalid tcpBufferSizes string: " + tcpBufferSizes +", using defaults"); if (DBG) log("Invalid tcpBufferSizes string: " + tcpBufferSizes +", using defaults"); tcpBufferSizes = DEFAULT_TCP_BUFFER_SIZES; values = tcpBufferSizes.split(","); } Loading @@ -1587,7 +1587,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return; try { if (VDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); if (DBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); final String prefix = "/sys/kernel/ipv4/tcp_"; FileUtils.stringToFile(prefix + "rmem_min", values[0]); Loading Loading @@ -1750,7 +1750,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } if (officialNai != null && officialNai.equals(nai)) return true; if (officialNai != null || VDBG) { loge(msg + " - validateNetworkAgent found mismatched netId: " + officialNai + loge(msg + " - isLiveNetworkAgent found mismatched netId: " + officialNai + " - " + nai); } return false; Loading Loading @@ -1794,7 +1794,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("NetworkAgent not found for EVENT_NETWORK_PROPERTIES_CHANGED"); } else { if (VDBG) { log("Update of Linkproperties for " + nai.name() + log("Update of LinkProperties for " + nai.name() + "; created=" + nai.created); } LinkProperties oldLp = nai.linkProperties; Loading Loading @@ -2073,11 +2073,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (int i = 0; i < nai.networkRequests.size(); i++) { NetworkRequest request = nai.networkRequests.valueAt(i); NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(request.requestId); if (VDBG) { log(" checking request " + request + ", currentNetwork = " + (currentNetwork != null ? currentNetwork.name() : "null")); } if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) { if (DBG) { log("Checking for replacement network to handle request " + request ); } mNetworkForRequestId.remove(request.requestId); sendUpdatedScoreToFactories(request, 0); NetworkAgentInfo alternative = null; Loading @@ -2091,11 +2090,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { alternative = existing; } } if (alternative != null && !toActivate.contains(alternative)) { if (alternative != null) { if (DBG) log(" found replacement in " + alternative.name()); if (!toActivate.contains(alternative)) { toActivate.add(alternative); } } } } if (nai.networkRequests.get(mDefaultRequest.requestId) != null) { removeDataActivityTracking(nai); mActiveDefaultNetwork = ConnectivityManager.TYPE_NONE; Loading @@ -2115,9 +2117,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { // Check for the best currently alive network that satisfies this request NetworkAgentInfo bestNetwork = null; for (NetworkAgentInfo network : mNetworkAgentInfos.values()) { if (VDBG) log("handleRegisterNetworkRequest checking " + network.name()); if (DBG) log("handleRegisterNetworkRequest checking " + network.name()); if (newCap.satisfiedByNetworkCapabilities(network.networkCapabilities)) { if (VDBG) log("apparently satisfied. currentScore=" + network.currentScore); if (DBG) log("apparently satisfied. currentScore=" + network.currentScore); if ((bestNetwork == null) || bestNetwork.currentScore < network.currentScore) { if (!nri.isRequest) { // Not setting bestNetwork here as a listening NetworkRequest may be Loading @@ -2132,7 +2134,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } if (bestNetwork != null) { if (VDBG) log("using " + bestNetwork.name()); if (DBG) log("using " + bestNetwork.name()); if (bestNetwork.networkInfo.isConnected()) { // Cancel any lingering so the linger timeout doesn't teardown this network // even though we have a request for it. Loading Loading @@ -2173,7 +2175,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { if (nai.networkRequests.get(nri.request.requestId) != null) { nai.networkRequests.remove(nri.request.requestId); if (VDBG) { if (DBG) { log(" Removing from current network " + nai.name() + ", leaving " + nai.networkRequests.size() + " requests."); Loading Loading @@ -3920,7 +3922,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void handleNetworkSamplingTimeout() { log("Sampling interval elapsed, updating statistics .."); if (SAMPLE_DBG) log("Sampling interval elapsed, updating statistics .."); // initialize list of interfaces .. Map<String, SamplingDataTracker.SamplingSnapshot> mapIfaceToSample = Loading Loading @@ -3951,13 +3953,15 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } log("Done."); if (SAMPLE_DBG) log("Done."); int samplingIntervalInSeconds = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS, DEFAULT_SAMPLING_INTERVAL_IN_SECONDS); if (DBG) log("Setting timer for " + String.valueOf(samplingIntervalInSeconds) + "seconds"); if (SAMPLE_DBG) { log("Setting timer for " + String.valueOf(samplingIntervalInSeconds) + "seconds"); } setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent); } Loading Loading @@ -4125,7 +4129,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } private void handleRegisterNetworkFactory(NetworkFactoryInfo nfi) { if (VDBG) log("Got NetworkFactory Messenger for " + nfi.name); if (DBG) log("Got NetworkFactory Messenger for " + nfi.name); mNetworkFactoryInfos.put(nfi.messenger, nfi); nfi.asyncChannel.connect(mContext, mTrackerHandler, nfi.messenger); } Loading @@ -4139,10 +4143,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void handleUnregisterNetworkFactory(Messenger messenger) { NetworkFactoryInfo nfi = mNetworkFactoryInfos.remove(messenger); if (nfi == null) { if (VDBG) log("Failed to find Messenger in unregisterNetworkFactory"); loge("Failed to find Messenger in unregisterNetworkFactory"); return; } if (VDBG) log("unregisterNetworkFactory for " + nfi.name); if (DBG) log("unregisterNetworkFactory for " + nfi.name); } /** Loading Loading @@ -4180,7 +4184,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { synchronized (this) { nai.networkMonitor.systemReady = mSystemReady; } if (VDBG) log("registerNetworkAgent " + nai); if (DBG) log("registerNetworkAgent " + nai); mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai)); } Loading Loading @@ -4241,6 +4245,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } for (String iface : interfaceDiff.added) { try { if (DBG) log("Adding iface " + iface + " to network " + netId); mNetd.addInterfaceToNetwork(iface, netId); } catch (Exception e) { loge("Exception adding interface: " + e); Loading @@ -4248,6 +4253,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } for (String iface : interfaceDiff.removed) { try { if (DBG) log("Removing iface " + iface + " from network " + netId); mNetd.removeInterfaceFromNetwork(iface, netId); } catch (Exception e) { loge("Exception removing interface: " + e); Loading @@ -4272,22 +4278,29 @@ public class ConnectivityService extends IConnectivityManager.Stub { // do this twice, adding non-nexthop routes first, then routes they are dependent on for (RouteInfo route : routeDiff.added) { if (route.hasGateway()) continue; if (DBG) log("Adding Route [" + route + "] to network " + netId); try { mNetd.addRoute(netId, route); } catch (Exception e) { if ((route.getDestination().getAddress() instanceof Inet4Address) || VDBG) { loge("Exception in addRoute for non-gateway: " + e); } } } for (RouteInfo route : routeDiff.added) { if (route.hasGateway() == false) continue; if (DBG) log("Adding Route [" + route + "] to network " + netId); try { mNetd.addRoute(netId, route); } catch (Exception e) { if ((route.getGateway() instanceof Inet4Address) || VDBG) { loge("Exception in addRoute for gateway: " + e); } } } for (RouteInfo route : routeDiff.removed) { if (DBG) log("Removing Route [" + route + "] from network " + netId); try { mNetd.removeRoute(netId, route); } catch (Exception e) { Loading @@ -4306,6 +4319,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("no dns provided for netId " + netId + ", so using defaults"); } } if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses); try { mNetd.setDnsServersForNetwork(netId, NetworkUtils.makeStrings(dnses), newLp.getDomains()); Loading Loading @@ -4395,7 +4409,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { msg.obj = o; msg.what = notificationType; try { if (VDBG) log("sending notification " + notificationType + " for " + nri.request); if (VDBG) { log("sending notification " + notifyTypeToName(notificationType) + " for " + nri.request); } nri.messenger.send(msg); } catch (RemoteException e) { // may occur naturally in the race of binder death. Loading @@ -4418,7 +4435,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } private void makeDefault(NetworkAgentInfo newNetwork) { if (VDBG) log("Switching to new default network: " + newNetwork); if (DBG) log("Switching to new default network: " + newNetwork); mActiveDefaultNetwork = newNetwork.networkInfo.getType(); setupDataActivityTracking(newNetwork); try { Loading @@ -4444,7 +4461,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (NetworkRequestInfo nri : mNetworkRequests.values()) { NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(nri.request.requestId); if (newNetwork == currentNetwork) { if (VDBG) log("Network " + newNetwork.name() + " was already satisfying" + if (DBG) log("Network " + newNetwork.name() + " was already satisfying" + " request " + nri.request.requestId + ". No change."); keep = true; continue; Loading @@ -4468,12 +4485,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (currentNetwork == null || currentNetwork.currentScore < newNetwork.currentScore) { if (currentNetwork != null) { if (VDBG) log(" accepting network in place of " + currentNetwork.name()); if (DBG) log(" accepting network in place of " + currentNetwork.name()); currentNetwork.networkRequests.remove(nri.request.requestId); currentNetwork.networkLingered.add(nri.request); affectedNetworks.add(currentNetwork); } else { if (VDBG) log(" accepting network in place of null"); if (DBG) log(" accepting network in place of null"); } mNetworkForRequestId.put(nri.request.requestId, newNetwork); newNetwork.addRequest(nri.request); Loading Loading @@ -4574,7 +4591,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge(" " + newNetwork.networkRequests.valueAt(i)); } } if (VDBG) log("Validated network turns out to be unwanted. Tear it down."); if (DBG) log("Validated network turns out to be unwanted. Tear it down."); newNetwork.asyncChannel.disconnect(); } } Loading Loading @@ -4745,7 +4762,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) { if (VDBG) log("notifyType " + notifyType + " for " + networkAgent.name()); if (DBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name()); for (int i = 0; i < networkAgent.networkRequests.size(); i++) { NetworkRequest nr = networkAgent.networkRequests.valueAt(i); NetworkRequestInfo nri = mNetworkRequests.get(nr); Loading @@ -4754,6 +4771,20 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } private String notifyTypeToName(int notifyType) { switch (notifyType) { case ConnectivityManager.CALLBACK_PRECHECK: return "PRECHECK"; case ConnectivityManager.CALLBACK_AVAILABLE: return "AVAILABLE"; case ConnectivityManager.CALLBACK_LOSING: return "LOSING"; case ConnectivityManager.CALLBACK_LOST: return "LOST"; case ConnectivityManager.CALLBACK_UNAVAIL: return "UNAVAILABLE"; case ConnectivityManager.CALLBACK_CAP_CHANGED: return "CAP_CHANGED"; case ConnectivityManager.CALLBACK_IP_CHANGED: return "IP_CHANGED"; case ConnectivityManager.CALLBACK_RELEASED: return "RELEASED"; } return "UNKNOWN"; } private LinkProperties getLinkPropertiesForTypeInternal(int networkType) { NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType); if (nai != null) { Loading Loading
core/java/android/net/NetworkAgent.java +4 −4 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public abstract class NetworkAgent extends Handler { private volatile AsyncChannel mAsyncChannel; private final String LOG_TAG; private static final boolean DBG = true; private static final boolean VDBG = true; private static final boolean VDBG = false; private final Context mContext; private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>(); Loading Loading @@ -134,7 +134,7 @@ public abstract class NetworkAgent extends Handler { throw new IllegalArgumentException(); } if (DBG) log("Registering NetworkAgent"); if (VDBG) log("Registering NetworkAgent"); ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( Context.CONNECTIVITY_SERVICE); cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni), Loading @@ -148,7 +148,7 @@ public abstract class NetworkAgent extends Handler { if (mAsyncChannel != null) { log("Received new connection while already connected!"); } else { if (DBG) log("NetworkAgent fully connected"); if (VDBG) log("NetworkAgent fully connected"); AsyncChannel ac = new AsyncChannel(); ac.connected(null, this, msg.replyTo); ac.replyToMessage(msg, AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED, Loading @@ -164,7 +164,7 @@ public abstract class NetworkAgent extends Handler { break; } case AsyncChannel.CMD_CHANNEL_DISCONNECT: { if (DBG) log("CMD_CHANNEL_DISCONNECT"); if (VDBG) log("CMD_CHANNEL_DISCONNECT"); if (mAsyncChannel != null) mAsyncChannel.disconnect(); break; } Loading
core/java/android/net/NetworkFactory.java +4 −2 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.internal.util.Protocol; **/ public class NetworkFactory extends Handler { private static final boolean DBG = true; private static final boolean VDBG = false; private static final int BASE = Protocol.BASE_NETWORK_FACTORY; /** Loading Loading @@ -164,13 +165,14 @@ public class NetworkFactory extends Handler { private void handleAddRequest(NetworkRequest request, int score) { NetworkRequestInfo n = mNetworkRequests.get(request.requestId); if (n == null) { if (DBG) log("got request " + request + " with score " + score); n = new NetworkRequestInfo(request, score); mNetworkRequests.put(n.request.requestId, n); } else { if (VDBG) log("new score " + score + " for exisiting request " + request); n.score = score; } if (DBG) log("got request " + request + " with score " + score); if (DBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter); if (VDBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter); evalRequest(n); } Loading
services/core/java/com/android/server/ConnectivityService.java +67 −36 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private static final String TAG = "ConnectivityService"; private static final boolean DBG = true; private static final boolean VDBG = true; // STOPSHIP private static final boolean VDBG = false; // network sampling debugging private static final boolean SAMPLE_DBG = false; Loading Loading @@ -830,11 +830,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { // network is blocked; clone and override state info = new NetworkInfo(info); info.setDetailedState(DetailedState.BLOCKED, null, null); if (VDBG) log("returning Blocked NetworkInfo"); if (DBG) log("returning Blocked NetworkInfo"); } if (mLockdownTracker != null) { info = mLockdownTracker.augmentNetworkInfo(info); if (VDBG) log("returning Locked NetworkInfo"); if (DBG) log("returning Locked NetworkInfo"); } return info; } Loading Loading @@ -1202,7 +1202,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { bestRoute = RouteInfo.makeHostRoute(addr, bestRoute.getGateway(), iface); } } if (VDBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface()); if (DBG) log("Adding " + bestRoute + " for interface " + bestRoute.getInterface()); try { mNetd.addLegacyRouteForNetId(netId, bestRoute, uid); } catch (Exception e) { Loading Loading @@ -1401,7 +1401,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mInitialBroadcast = new Intent(intent); } intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); if (VDBG) { if (DBG) { log("sendStickyBroadcast: action=" + intent.getAction()); } Loading Loading @@ -1558,7 +1558,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } try { if (VDBG) log("Setting MTU size: " + iface + ", " + mtu); if (DBG) log("Setting MTU size: " + iface + ", " + mtu); mNetd.setMtu(iface, mtu); } catch (Exception e) { Slog.e(TAG, "exception in setMtu()" + e); Loading @@ -1579,7 +1579,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } if (values == null || values.length != 6) { if (VDBG) log("Invalid tcpBufferSizes string: " + tcpBufferSizes +", using defaults"); if (DBG) log("Invalid tcpBufferSizes string: " + tcpBufferSizes +", using defaults"); tcpBufferSizes = DEFAULT_TCP_BUFFER_SIZES; values = tcpBufferSizes.split(","); } Loading @@ -1587,7 +1587,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (tcpBufferSizes.equals(mCurrentTcpBufferSizes)) return; try { if (VDBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); if (DBG) Slog.d(TAG, "Setting tx/rx TCP buffers to " + tcpBufferSizes); final String prefix = "/sys/kernel/ipv4/tcp_"; FileUtils.stringToFile(prefix + "rmem_min", values[0]); Loading Loading @@ -1750,7 +1750,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } if (officialNai != null && officialNai.equals(nai)) return true; if (officialNai != null || VDBG) { loge(msg + " - validateNetworkAgent found mismatched netId: " + officialNai + loge(msg + " - isLiveNetworkAgent found mismatched netId: " + officialNai + " - " + nai); } return false; Loading Loading @@ -1794,7 +1794,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("NetworkAgent not found for EVENT_NETWORK_PROPERTIES_CHANGED"); } else { if (VDBG) { log("Update of Linkproperties for " + nai.name() + log("Update of LinkProperties for " + nai.name() + "; created=" + nai.created); } LinkProperties oldLp = nai.linkProperties; Loading Loading @@ -2073,11 +2073,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (int i = 0; i < nai.networkRequests.size(); i++) { NetworkRequest request = nai.networkRequests.valueAt(i); NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(request.requestId); if (VDBG) { log(" checking request " + request + ", currentNetwork = " + (currentNetwork != null ? currentNetwork.name() : "null")); } if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) { if (DBG) { log("Checking for replacement network to handle request " + request ); } mNetworkForRequestId.remove(request.requestId); sendUpdatedScoreToFactories(request, 0); NetworkAgentInfo alternative = null; Loading @@ -2091,11 +2090,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { alternative = existing; } } if (alternative != null && !toActivate.contains(alternative)) { if (alternative != null) { if (DBG) log(" found replacement in " + alternative.name()); if (!toActivate.contains(alternative)) { toActivate.add(alternative); } } } } if (nai.networkRequests.get(mDefaultRequest.requestId) != null) { removeDataActivityTracking(nai); mActiveDefaultNetwork = ConnectivityManager.TYPE_NONE; Loading @@ -2115,9 +2117,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { // Check for the best currently alive network that satisfies this request NetworkAgentInfo bestNetwork = null; for (NetworkAgentInfo network : mNetworkAgentInfos.values()) { if (VDBG) log("handleRegisterNetworkRequest checking " + network.name()); if (DBG) log("handleRegisterNetworkRequest checking " + network.name()); if (newCap.satisfiedByNetworkCapabilities(network.networkCapabilities)) { if (VDBG) log("apparently satisfied. currentScore=" + network.currentScore); if (DBG) log("apparently satisfied. currentScore=" + network.currentScore); if ((bestNetwork == null) || bestNetwork.currentScore < network.currentScore) { if (!nri.isRequest) { // Not setting bestNetwork here as a listening NetworkRequest may be Loading @@ -2132,7 +2134,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } if (bestNetwork != null) { if (VDBG) log("using " + bestNetwork.name()); if (DBG) log("using " + bestNetwork.name()); if (bestNetwork.networkInfo.isConnected()) { // Cancel any lingering so the linger timeout doesn't teardown this network // even though we have a request for it. Loading Loading @@ -2173,7 +2175,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { if (nai.networkRequests.get(nri.request.requestId) != null) { nai.networkRequests.remove(nri.request.requestId); if (VDBG) { if (DBG) { log(" Removing from current network " + nai.name() + ", leaving " + nai.networkRequests.size() + " requests."); Loading Loading @@ -3920,7 +3922,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void handleNetworkSamplingTimeout() { log("Sampling interval elapsed, updating statistics .."); if (SAMPLE_DBG) log("Sampling interval elapsed, updating statistics .."); // initialize list of interfaces .. Map<String, SamplingDataTracker.SamplingSnapshot> mapIfaceToSample = Loading Loading @@ -3951,13 +3953,15 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } log("Done."); if (SAMPLE_DBG) log("Done."); int samplingIntervalInSeconds = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.CONNECTIVITY_SAMPLING_INTERVAL_IN_SECONDS, DEFAULT_SAMPLING_INTERVAL_IN_SECONDS); if (DBG) log("Setting timer for " + String.valueOf(samplingIntervalInSeconds) + "seconds"); if (SAMPLE_DBG) { log("Setting timer for " + String.valueOf(samplingIntervalInSeconds) + "seconds"); } setAlarm(samplingIntervalInSeconds * 1000, mSampleIntervalElapsedIntent); } Loading Loading @@ -4125,7 +4129,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } private void handleRegisterNetworkFactory(NetworkFactoryInfo nfi) { if (VDBG) log("Got NetworkFactory Messenger for " + nfi.name); if (DBG) log("Got NetworkFactory Messenger for " + nfi.name); mNetworkFactoryInfos.put(nfi.messenger, nfi); nfi.asyncChannel.connect(mContext, mTrackerHandler, nfi.messenger); } Loading @@ -4139,10 +4143,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void handleUnregisterNetworkFactory(Messenger messenger) { NetworkFactoryInfo nfi = mNetworkFactoryInfos.remove(messenger); if (nfi == null) { if (VDBG) log("Failed to find Messenger in unregisterNetworkFactory"); loge("Failed to find Messenger in unregisterNetworkFactory"); return; } if (VDBG) log("unregisterNetworkFactory for " + nfi.name); if (DBG) log("unregisterNetworkFactory for " + nfi.name); } /** Loading Loading @@ -4180,7 +4184,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { synchronized (this) { nai.networkMonitor.systemReady = mSystemReady; } if (VDBG) log("registerNetworkAgent " + nai); if (DBG) log("registerNetworkAgent " + nai); mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai)); } Loading Loading @@ -4241,6 +4245,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } for (String iface : interfaceDiff.added) { try { if (DBG) log("Adding iface " + iface + " to network " + netId); mNetd.addInterfaceToNetwork(iface, netId); } catch (Exception e) { loge("Exception adding interface: " + e); Loading @@ -4248,6 +4253,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } for (String iface : interfaceDiff.removed) { try { if (DBG) log("Removing iface " + iface + " from network " + netId); mNetd.removeInterfaceFromNetwork(iface, netId); } catch (Exception e) { loge("Exception removing interface: " + e); Loading @@ -4272,22 +4278,29 @@ public class ConnectivityService extends IConnectivityManager.Stub { // do this twice, adding non-nexthop routes first, then routes they are dependent on for (RouteInfo route : routeDiff.added) { if (route.hasGateway()) continue; if (DBG) log("Adding Route [" + route + "] to network " + netId); try { mNetd.addRoute(netId, route); } catch (Exception e) { if ((route.getDestination().getAddress() instanceof Inet4Address) || VDBG) { loge("Exception in addRoute for non-gateway: " + e); } } } for (RouteInfo route : routeDiff.added) { if (route.hasGateway() == false) continue; if (DBG) log("Adding Route [" + route + "] to network " + netId); try { mNetd.addRoute(netId, route); } catch (Exception e) { if ((route.getGateway() instanceof Inet4Address) || VDBG) { loge("Exception in addRoute for gateway: " + e); } } } for (RouteInfo route : routeDiff.removed) { if (DBG) log("Removing Route [" + route + "] from network " + netId); try { mNetd.removeRoute(netId, route); } catch (Exception e) { Loading @@ -4306,6 +4319,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("no dns provided for netId " + netId + ", so using defaults"); } } if (DBG) log("Setting Dns servers for network " + netId + " to " + dnses); try { mNetd.setDnsServersForNetwork(netId, NetworkUtils.makeStrings(dnses), newLp.getDomains()); Loading Loading @@ -4395,7 +4409,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { msg.obj = o; msg.what = notificationType; try { if (VDBG) log("sending notification " + notificationType + " for " + nri.request); if (VDBG) { log("sending notification " + notifyTypeToName(notificationType) + " for " + nri.request); } nri.messenger.send(msg); } catch (RemoteException e) { // may occur naturally in the race of binder death. Loading @@ -4418,7 +4435,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } private void makeDefault(NetworkAgentInfo newNetwork) { if (VDBG) log("Switching to new default network: " + newNetwork); if (DBG) log("Switching to new default network: " + newNetwork); mActiveDefaultNetwork = newNetwork.networkInfo.getType(); setupDataActivityTracking(newNetwork); try { Loading @@ -4444,7 +4461,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (NetworkRequestInfo nri : mNetworkRequests.values()) { NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(nri.request.requestId); if (newNetwork == currentNetwork) { if (VDBG) log("Network " + newNetwork.name() + " was already satisfying" + if (DBG) log("Network " + newNetwork.name() + " was already satisfying" + " request " + nri.request.requestId + ". No change."); keep = true; continue; Loading @@ -4468,12 +4485,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (currentNetwork == null || currentNetwork.currentScore < newNetwork.currentScore) { if (currentNetwork != null) { if (VDBG) log(" accepting network in place of " + currentNetwork.name()); if (DBG) log(" accepting network in place of " + currentNetwork.name()); currentNetwork.networkRequests.remove(nri.request.requestId); currentNetwork.networkLingered.add(nri.request); affectedNetworks.add(currentNetwork); } else { if (VDBG) log(" accepting network in place of null"); if (DBG) log(" accepting network in place of null"); } mNetworkForRequestId.put(nri.request.requestId, newNetwork); newNetwork.addRequest(nri.request); Loading Loading @@ -4574,7 +4591,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge(" " + newNetwork.networkRequests.valueAt(i)); } } if (VDBG) log("Validated network turns out to be unwanted. Tear it down."); if (DBG) log("Validated network turns out to be unwanted. Tear it down."); newNetwork.asyncChannel.disconnect(); } } Loading Loading @@ -4745,7 +4762,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) { if (VDBG) log("notifyType " + notifyType + " for " + networkAgent.name()); if (DBG) log("notifyType " + notifyTypeToName(notifyType) + " for " + networkAgent.name()); for (int i = 0; i < networkAgent.networkRequests.size(); i++) { NetworkRequest nr = networkAgent.networkRequests.valueAt(i); NetworkRequestInfo nri = mNetworkRequests.get(nr); Loading @@ -4754,6 +4771,20 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } private String notifyTypeToName(int notifyType) { switch (notifyType) { case ConnectivityManager.CALLBACK_PRECHECK: return "PRECHECK"; case ConnectivityManager.CALLBACK_AVAILABLE: return "AVAILABLE"; case ConnectivityManager.CALLBACK_LOSING: return "LOSING"; case ConnectivityManager.CALLBACK_LOST: return "LOST"; case ConnectivityManager.CALLBACK_UNAVAIL: return "UNAVAILABLE"; case ConnectivityManager.CALLBACK_CAP_CHANGED: return "CAP_CHANGED"; case ConnectivityManager.CALLBACK_IP_CHANGED: return "IP_CHANGED"; case ConnectivityManager.CALLBACK_RELEASED: return "RELEASED"; } return "UNKNOWN"; } private LinkProperties getLinkPropertiesForTypeInternal(int networkType) { NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType); if (nai != null) { Loading