Loading services/core/java/com/android/server/ConnectivityService.java +22 −5 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private static final boolean VDBG = false; private static final boolean LOGD_RULES = false; private static final boolean LOGD_BLOCKED_NETWORKINFO = true; // TODO: create better separation between radio types and network types Loading Loading @@ -955,6 +956,21 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void maybeLogBlockedNetworkInfo(NetworkInfo ni, int uid) { if (ni == null || !LOGD_BLOCKED_NETWORKINFO) return; boolean removed = false; boolean added = false; synchronized (mBlockedAppUids) { if (ni.getDetailedState() == DetailedState.BLOCKED && mBlockedAppUids.add(uid)) { added = true; } else if (ni.isConnected() && mBlockedAppUids.remove(uid)) { removed = true; } } if (added) log("Returning blocked NetworkInfo to uid=" + uid); else if (removed) log("Returning unblocked NetworkInfo to uid=" + uid); } /** * Return a filtered {@link NetworkInfo}, potentially marked * {@link DetailedState#BLOCKED} based on Loading @@ -965,10 +981,6 @@ 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 for ifname=" + lp.getInterfaceName() + ", uid=" + uid); } } if (info != null && mLockdownTracker != null) { info = mLockdownTracker.augmentNetworkInfo(info); Loading @@ -989,7 +1001,9 @@ public class ConnectivityService extends IConnectivityManager.Stub enforceAccessPermission(); final int uid = Binder.getCallingUid(); NetworkState state = getUnfilteredActiveNetworkState(uid); return getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid); NetworkInfo ni = getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid); maybeLogBlockedNetworkInfo(ni, uid); return ni; } @Override Loading Loading @@ -3882,6 +3896,9 @@ public class ConnectivityService extends IConnectivityManager.Stub private final HashMap<Messenger, NetworkAgentInfo> mNetworkAgentInfos = new HashMap<Messenger, NetworkAgentInfo>(); @GuardedBy("mBlockedAppUids") private final HashSet<Integer> mBlockedAppUids = new HashSet(); // Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated. private final NetworkRequest mDefaultRequest; Loading Loading
services/core/java/com/android/server/ConnectivityService.java +22 −5 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private static final boolean VDBG = false; private static final boolean LOGD_RULES = false; private static final boolean LOGD_BLOCKED_NETWORKINFO = true; // TODO: create better separation between radio types and network types Loading Loading @@ -955,6 +956,21 @@ public class ConnectivityService extends IConnectivityManager.Stub } } private void maybeLogBlockedNetworkInfo(NetworkInfo ni, int uid) { if (ni == null || !LOGD_BLOCKED_NETWORKINFO) return; boolean removed = false; boolean added = false; synchronized (mBlockedAppUids) { if (ni.getDetailedState() == DetailedState.BLOCKED && mBlockedAppUids.add(uid)) { added = true; } else if (ni.isConnected() && mBlockedAppUids.remove(uid)) { removed = true; } } if (added) log("Returning blocked NetworkInfo to uid=" + uid); else if (removed) log("Returning unblocked NetworkInfo to uid=" + uid); } /** * Return a filtered {@link NetworkInfo}, potentially marked * {@link DetailedState#BLOCKED} based on Loading @@ -965,10 +981,6 @@ 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 for ifname=" + lp.getInterfaceName() + ", uid=" + uid); } } if (info != null && mLockdownTracker != null) { info = mLockdownTracker.augmentNetworkInfo(info); Loading @@ -989,7 +1001,9 @@ public class ConnectivityService extends IConnectivityManager.Stub enforceAccessPermission(); final int uid = Binder.getCallingUid(); NetworkState state = getUnfilteredActiveNetworkState(uid); return getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid); NetworkInfo ni = getFilteredNetworkInfo(state.networkInfo, state.linkProperties, uid); maybeLogBlockedNetworkInfo(ni, uid); return ni; } @Override Loading Loading @@ -3882,6 +3896,9 @@ public class ConnectivityService extends IConnectivityManager.Stub private final HashMap<Messenger, NetworkAgentInfo> mNetworkAgentInfos = new HashMap<Messenger, NetworkAgentInfo>(); @GuardedBy("mBlockedAppUids") private final HashSet<Integer> mBlockedAppUids = new HashSet(); // Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated. private final NetworkRequest mDefaultRequest; Loading