Loading services/core/java/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java +12 −6 Original line number Diff line number Diff line Loading @@ -399,10 +399,13 @@ public class UpstreamNetworkMonitor { @Override public void onLinkPropertiesChanged(Network network, LinkProperties newLp) { handleLinkProp(network, newLp); // TODO(b/110335330): reduce the number of times this is called by // only recomputing on the LISTEN_ALL callback. // Any non-LISTEN_ALL callback will necessarily concern a network that will // also match the LISTEN_ALL callback by construction of the LISTEN_ALL callback. // So it's not useful to do this work for non-LISTEN_ALL callbacks. if (mCallbackType == CALLBACK_LISTEN_ALL) { recomputeLocalPrefixes(); } } @Override public void onNetworkSuspended(Network network) { Loading @@ -417,11 +420,14 @@ public class UpstreamNetworkMonitor { @Override public void onLost(Network network) { handleLost(mCallbackType, network); // TODO(b/110335330): reduce the number of times this is called by // only recomputing on the LISTEN_ALL callback. // Any non-LISTEN_ALL callback will necessarily concern a network that will // also match the LISTEN_ALL callback by construction of the LISTEN_ALL callback. // So it's not useful to do this work for non-LISTEN_ALL callbacks. if (mCallbackType == CALLBACK_LISTEN_ALL) { recomputeLocalPrefixes(); } } } private void releaseCallback(NetworkCallback cb) { if (cb != null) cm().unregisterNetworkCallback(cb); Loading tests/net/java/com/android/server/connectivity/tethering/UpstreamNetworkMonitorTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -475,6 +475,18 @@ public class UpstreamNetworkMonitorTest { assertPrefixSet(local, EXCLUDES, wifiLinkPrefixes); assertPrefixSet(local, INCLUDES, cellLinkPrefixes); assertPrefixSet(local, INCLUDES, dunLinkPrefixes); // [5] Pretend mobile disconnected. cellAgent.fakeDisconnect(); local = mUNM.getLocalPrefixes(); assertPrefixSet(local, EXCLUDES, wifiLinkPrefixes); assertPrefixSet(local, EXCLUDES, cellLinkPrefixes); assertPrefixSet(local, INCLUDES, dunLinkPrefixes); // [6] Pretend DUN disconnected. dunAgent.fakeDisconnect(); local = mUNM.getLocalPrefixes(); assertTrue(local.isEmpty()); } private void assertSatisfiesLegacyType(int legacyType, NetworkState ns) { Loading Loading
services/core/java/com/android/server/connectivity/tethering/UpstreamNetworkMonitor.java +12 −6 Original line number Diff line number Diff line Loading @@ -399,10 +399,13 @@ public class UpstreamNetworkMonitor { @Override public void onLinkPropertiesChanged(Network network, LinkProperties newLp) { handleLinkProp(network, newLp); // TODO(b/110335330): reduce the number of times this is called by // only recomputing on the LISTEN_ALL callback. // Any non-LISTEN_ALL callback will necessarily concern a network that will // also match the LISTEN_ALL callback by construction of the LISTEN_ALL callback. // So it's not useful to do this work for non-LISTEN_ALL callbacks. if (mCallbackType == CALLBACK_LISTEN_ALL) { recomputeLocalPrefixes(); } } @Override public void onNetworkSuspended(Network network) { Loading @@ -417,11 +420,14 @@ public class UpstreamNetworkMonitor { @Override public void onLost(Network network) { handleLost(mCallbackType, network); // TODO(b/110335330): reduce the number of times this is called by // only recomputing on the LISTEN_ALL callback. // Any non-LISTEN_ALL callback will necessarily concern a network that will // also match the LISTEN_ALL callback by construction of the LISTEN_ALL callback. // So it's not useful to do this work for non-LISTEN_ALL callbacks. if (mCallbackType == CALLBACK_LISTEN_ALL) { recomputeLocalPrefixes(); } } } private void releaseCallback(NetworkCallback cb) { if (cb != null) cm().unregisterNetworkCallback(cb); Loading
tests/net/java/com/android/server/connectivity/tethering/UpstreamNetworkMonitorTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -475,6 +475,18 @@ public class UpstreamNetworkMonitorTest { assertPrefixSet(local, EXCLUDES, wifiLinkPrefixes); assertPrefixSet(local, INCLUDES, cellLinkPrefixes); assertPrefixSet(local, INCLUDES, dunLinkPrefixes); // [5] Pretend mobile disconnected. cellAgent.fakeDisconnect(); local = mUNM.getLocalPrefixes(); assertPrefixSet(local, EXCLUDES, wifiLinkPrefixes); assertPrefixSet(local, EXCLUDES, cellLinkPrefixes); assertPrefixSet(local, INCLUDES, dunLinkPrefixes); // [6] Pretend DUN disconnected. dunAgent.fakeDisconnect(); local = mUNM.getLocalPrefixes(); assertTrue(local.isEmpty()); } private void assertSatisfiesLegacyType(int legacyType, NetworkState ns) { Loading