Merge "Fix a bug where listen callbacks would not be called" am: d36130f759
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1620900 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I14a640aa21b464e7d6ced3086986e0dd79eaa019
This commit is contained in:
@@ -3661,6 +3661,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If this NRI has a satisfier already, it is replacing an older request that
|
||||||
|
// has been removed. Track it.
|
||||||
|
final NetworkRequest activeRequest = nri.getActiveRequest();
|
||||||
|
if (null != activeRequest) {
|
||||||
|
// If there is an active request, then for sure there is a satisfier.
|
||||||
|
nri.getSatisfier().addRequest(activeRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rematchAllNetworksAndRequests();
|
rematchAllNetworksAndRequests();
|
||||||
@@ -5281,14 +5288,26 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
ensureAllNetworkRequestsHaveType(r);
|
ensureAllNetworkRequestsHaveType(r);
|
||||||
mRequests = initializeRequests(r);
|
mRequests = initializeRequests(r);
|
||||||
mNetworkRequestForCallback = nri.getNetworkRequestForCallback();
|
mNetworkRequestForCallback = nri.getNetworkRequestForCallback();
|
||||||
// Note here that the satisfier may have corresponded to an old request, that
|
final NetworkAgentInfo satisfier = nri.getSatisfier();
|
||||||
// this code doesn't try to take over. While it is a small discrepancy in the
|
if (null != satisfier) {
|
||||||
// structure of these requests, it will be fixed by the next rematch and it's
|
// If the old NRI was satisfied by an NAI, then it may have had an active request.
|
||||||
// not as bad as having an NRI not storing its real satisfier.
|
// The active request is necessary to figure out what callbacks to send, in
|
||||||
// Fixing this discrepancy would require figuring out in the copying code what
|
// particular then a network updates its capabilities.
|
||||||
// is the new request satisfied by this, which is a bit complex and not very
|
// As this code creates a new NRI with a new set of requests, figure out which of
|
||||||
// useful as no code is using it until rematch fixes it.
|
// the list of requests should be the active request. It is always the first
|
||||||
mSatisfier = nri.mSatisfier;
|
// request of the list that can be satisfied by the satisfier since the order of
|
||||||
|
// requests is a priority order.
|
||||||
|
// Note even in the presence of a satisfier there may not be an active request,
|
||||||
|
// when the satisfier is the no-service network.
|
||||||
|
NetworkRequest activeRequest = null;
|
||||||
|
for (final NetworkRequest candidate : r) {
|
||||||
|
if (candidate.canBeSatisfiedBy(satisfier.networkCapabilities)) {
|
||||||
|
activeRequest = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSatisfier(satisfier, activeRequest);
|
||||||
|
}
|
||||||
mMessenger = nri.mMessenger;
|
mMessenger = nri.mMessenger;
|
||||||
mBinder = nri.mBinder;
|
mBinder = nri.mBinder;
|
||||||
mPid = nri.mPid;
|
mPid = nri.mPid;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE;
|
|||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_RCS;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_RCS;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_SUPL;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_SUPL;
|
||||||
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
||||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_WIFI_P2P;
|
import static android.net.NetworkCapabilities.NET_CAPABILITY_WIFI_P2P;
|
||||||
@@ -5574,7 +5575,7 @@ public class ConnectivityServiceTest {
|
|||||||
reset(mStatsManager);
|
reset(mStatsManager);
|
||||||
|
|
||||||
// Temp metered change shouldn't update ifaces
|
// Temp metered change shouldn't update ifaces
|
||||||
mCellNetworkAgent.addCapability(NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED);
|
mCellNetworkAgent.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED);
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
verify(mStatsManager, never()).notifyNetworkStatus(eq(Arrays.asList(onlyCell)),
|
verify(mStatsManager, never()).notifyNetworkStatus(eq(Arrays.asList(onlyCell)),
|
||||||
any(List.class), eq(MOBILE_IFNAME), any(List.class));
|
any(List.class), eq(MOBILE_IFNAME), any(List.class));
|
||||||
@@ -10652,7 +10653,7 @@ public class ConnectivityServiceTest {
|
|||||||
null,
|
null,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
// default NCs will be unregistered in tearDown
|
// default callbacks will be unregistered in tearDown
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10709,7 +10710,7 @@ public class ConnectivityServiceTest {
|
|||||||
null,
|
null,
|
||||||
mService.mNoServiceNetwork.network());
|
mService.mNoServiceNetwork.network());
|
||||||
|
|
||||||
// default NCs will be unregistered in tearDown
|
// default callbacks will be unregistered in tearDown
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10768,7 +10769,7 @@ public class ConnectivityServiceTest {
|
|||||||
null,
|
null,
|
||||||
mService.mNoServiceNetwork.network());
|
mService.mNoServiceNetwork.network());
|
||||||
|
|
||||||
// default NCs will be unregistered in tearDown
|
// default callbacks will be unregistered in tearDown
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10827,7 +10828,28 @@ public class ConnectivityServiceTest {
|
|||||||
null,
|
null,
|
||||||
mService.mNoServiceNetwork.network());
|
mService.mNoServiceNetwork.network());
|
||||||
|
|
||||||
// default NCs will be unregistered in tearDown
|
// default callbacks will be unregistered in tearDown
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCapabilityWithOemNetworkPreference() throws Exception {
|
||||||
|
@OemNetworkPreferences.OemNetworkPreference final int networkPref =
|
||||||
|
OemNetworkPreferences.OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY;
|
||||||
|
setupMultipleDefaultNetworksForOemNetworkPreferenceNotCurrentUidTest(networkPref);
|
||||||
|
registerDefaultNetworkCallbacks();
|
||||||
|
|
||||||
|
setOemNetworkPreferenceAgentConnected(TRANSPORT_CELLULAR, true);
|
||||||
|
|
||||||
|
mSystemDefaultNetworkCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent);
|
||||||
|
mDefaultNetworkCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent);
|
||||||
|
|
||||||
|
mCellNetworkAgent.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED);
|
||||||
|
mSystemDefaultNetworkCallback.expectCapabilitiesThat(mCellNetworkAgent, nc ->
|
||||||
|
nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
|
||||||
|
mDefaultNetworkCallback.expectCapabilitiesThat(mCellNetworkAgent, nc ->
|
||||||
|
nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
|
||||||
|
|
||||||
|
// default callbacks will be unregistered in tearDown
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user