Observe mOwnerUID in NetworkCapabilities#equals.

Currently, NetworkCapabilities's equals and hashCode methods
ignore mOwnerUID. This is confusing because it is inconsistent
with pretty much every other member of this class.

Bug: 175188445
Test: atest CtsNetTestCases:NetworkAgentTest \
            CtsNetTestCases:Ikev2VpnTest \
	    CtsNetTestCases:VpnServiceTest HostsideVpnTests \
	    CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest \
	    ConnectivityServiceTest com.android.server.connectivity.VpnTest
Change-Id: I2348b7a35f32a931687f2d3c2fa57620a12fe06f
This commit is contained in:
Lorenzo Colitti
2020-11-27 14:46:42 +09:00
parent 6b44e92fde
commit 46fd589d89
2 changed files with 20 additions and 16 deletions

View File

@@ -1980,18 +1980,16 @@ public class ConnectivityServiceTest {
mWiFiNetworkAgent.setNetworkCapabilities(agentCapabilities, true);
waitForIdle();
// Check that the owner UID is not updated.
// Check that the owner UID is updated.
// The owner UID is -1 because it is visible only to the UID that owns the network.
NetworkCapabilities nc = mCm.getNetworkCapabilities(mWiFiNetworkAgent.getNetwork());
assertEquals(originalOwnerUid, nc.getOwnerUid());
assertEquals(-1, nc.getOwnerUid());
// Make an unrelated change to the capabilities.
// Make an unrelated change to the capabilities and check it. The owner UID remains -1.
assertFalse(agentCapabilities.hasCapability(NET_CAPABILITY_NOT_CONGESTED));
agentCapabilities.addCapability(NET_CAPABILITY_NOT_CONGESTED);
mWiFiNetworkAgent.setNetworkCapabilities(agentCapabilities, true);
waitForIdle();
// Check that both the capability change and the owner UID have been modified.
// The owner UID is -1 because it is visible only to the UID that owns the network.
nc = mCm.getNetworkCapabilities(mWiFiNetworkAgent.getNetwork());
assertEquals(-1, nc.getOwnerUid());
assertTrue(nc.hasCapability(NET_CAPABILITY_NOT_CONGESTED));