Changing automotive ethernet allowed UIDs check

Updating the automotive allowed UIDs check to only work if the
capabilities have a single transport equal to ethernet.

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079
This commit is contained in:
James Mattis 2022-05-18 22:14:16 -07:00
commit 4eff0efb57
2 changed files with 5 additions and 5 deletions

View file

@ -1256,7 +1256,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo>, NetworkRa
if (nc.hasTransport(TRANSPORT_TEST)) return true;
// Factories that make ethernet networks can allow UIDs for automotive devices.
if (nc.hasTransport(TRANSPORT_ETHERNET) && hasAutomotiveFeature) {
if (nc.hasSingleTransport(TRANSPORT_ETHERNET) && hasAutomotiveFeature) {
return true;
}

View file

@ -15536,7 +15536,7 @@ public class ConnectivityServiceTest {
mEthernetNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_ETHERNET,
new LinkProperties(), agentNetCaps.build());
validateAllowedUids(mEthernetNetworkAgent, TRANSPORT_ETHERNET, agentNetCaps);
validateAllowedUids(mEthernetNetworkAgent, TRANSPORT_ETHERNET, agentNetCaps, true);
}
@Test
@ -15560,12 +15560,12 @@ public class ConnectivityServiceTest {
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR,
new LinkProperties(), agentNetCaps.build());
validateAllowedUids(mCellNetworkAgent, TRANSPORT_CELLULAR, agentNetCaps);
validateAllowedUids(mCellNetworkAgent, TRANSPORT_CELLULAR, agentNetCaps, false);
}
private void validateAllowedUids(final TestNetworkAgentWrapper testAgent,
@NetworkCapabilities.Transport final int transportUnderTest,
final NetworkCapabilities.Builder ncb) throws Exception {
final NetworkCapabilities.Builder ncb, final boolean forAutomotive) throws Exception {
final ArraySet<Integer> serviceUidSet = new ArraySet<>();
serviceUidSet.add(TEST_PACKAGE_UID);
final ArraySet<Integer> nonServiceUidSet = new ArraySet<>();
@ -15595,7 +15595,7 @@ public class ConnectivityServiceTest {
}
/* Test setting UIDs is rejected when expected */
if (TRANSPORT_ETHERNET == transportUnderTest) {
if (forAutomotive) {
mockHasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, false);
}