Merge "Set EthernetNetworkSpecifier on ethernet networks" am: 1fbc905f00
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1795391 Change-Id: Id7bc9333ea8549dcf91f9bf764409b443d4e9041
This commit is contained in:
@@ -177,12 +177,16 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final NetworkCapabilities nc = new NetworkCapabilities.Builder(capabilities)
|
||||||
|
.setNetworkSpecifier(new EthernetNetworkSpecifier(ifaceName))
|
||||||
|
.build();
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "addInterface, iface: " + ifaceName + ", capabilities: " + capabilities);
|
Log.d(TAG, "addInterface, iface: " + ifaceName + ", capabilities: " + nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
final NetworkInterfaceState iface = new NetworkInterfaceState(
|
final NetworkInterfaceState iface = new NetworkInterfaceState(
|
||||||
ifaceName, hwAddress, mHandler, mContext, ipConfig, capabilities, this, mDeps);
|
ifaceName, hwAddress, mHandler, mContext, ipConfig, nc, this, mDeps);
|
||||||
mTrackingInterfaces.put(ifaceName, iface);
|
mTrackingInterfaces.put(ifaceName, iface);
|
||||||
updateCapabilityFilter();
|
updateCapabilityFilter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
@@ -265,8 +266,12 @@ public class EthernetNetworkFactoryTest {
|
|||||||
triggerOnProvisioningSuccess();
|
triggerOnProvisioningSuccess();
|
||||||
// provisioning succeeded, verify that the network agent is created, registered, marked
|
// provisioning succeeded, verify that the network agent is created, registered, marked
|
||||||
// as connected and legacy type are correctly set.
|
// as connected and legacy type are correctly set.
|
||||||
verify(mDeps).makeEthernetNetworkAgent(any(), any(), any(), any(),
|
final ArgumentCaptor<NetworkCapabilities> ncCaptor = ArgumentCaptor.forClass(
|
||||||
|
NetworkCapabilities.class);
|
||||||
|
verify(mDeps).makeEthernetNetworkAgent(any(), any(), ncCaptor.capture(), any(),
|
||||||
argThat(x -> x.getLegacyType() == expectedLegacyType), any(), any());
|
argThat(x -> x.getLegacyType() == expectedLegacyType), any(), any());
|
||||||
|
assertEquals(
|
||||||
|
new EthernetNetworkSpecifier(iface), ncCaptor.getValue().getNetworkSpecifier());
|
||||||
verifyNetworkAgentRegistersAndConnects();
|
verifyNetworkAgentRegistersAndConnects();
|
||||||
clearInvocations(mDeps);
|
clearInvocations(mDeps);
|
||||||
clearInvocations(mNetworkAgent);
|
clearInvocations(mNetworkAgent);
|
||||||
|
|||||||
Reference in New Issue
Block a user