Allowing for null net caps in updateConfiguration
Marking NetworkCapabilities as nullable in updateConfiguration and updating where needed to support this. This will allow callers of the ethernet network management updateConfiguration API to use it primarily for setting an ethernet network's IP configuration. Bug: 222565654 Bug: 220017952 Bug: 210485380 Test: atest EthernetServiceTests Change-Id: Ifd908639a00470e599fe1a15487cc6383a56b2f5
This commit is contained in:
@@ -485,7 +485,9 @@ public class EthernetNetworkFactory extends NetworkFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mIpConfig = ipConfig;
|
mIpConfig = ipConfig;
|
||||||
setCapabilities(capabilities);
|
if (null != capabilities) {
|
||||||
|
setCapabilities(capabilities);
|
||||||
|
}
|
||||||
// Send an abort callback if a request is filed before the previous one has completed.
|
// Send an abort callback if a request is filed before the previous one has completed.
|
||||||
maybeSendNetworkManagementCallbackForAbort();
|
maybeSendNetworkManagementCallbackForAbort();
|
||||||
// TODO: Update this logic to only do a restart if required. Although a restart may
|
// TODO: Update this logic to only do a restart if required. Although a restart may
|
||||||
|
|||||||
@@ -237,8 +237,8 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
|
|||||||
logIfEthernetNotStarted();
|
logIfEthernetNotStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateTestCapabilities(@NonNull final NetworkCapabilities nc) {
|
private void validateTestCapabilities(@Nullable final NetworkCapabilities nc) {
|
||||||
if (nc.hasTransport(TRANSPORT_TEST)) {
|
if (null != nc && nc.hasTransport(TRANSPORT_TEST)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class EthernetTracker {
|
|||||||
@VisibleForTesting(visibility = PACKAGE)
|
@VisibleForTesting(visibility = PACKAGE)
|
||||||
protected void updateConfiguration(@NonNull final String iface,
|
protected void updateConfiguration(@NonNull final String iface,
|
||||||
@NonNull final IpConfiguration ipConfig,
|
@NonNull final IpConfiguration ipConfig,
|
||||||
@NonNull final NetworkCapabilities capabilities,
|
@Nullable final NetworkCapabilities capabilities,
|
||||||
@Nullable final IEthernetNetworkManagementListener listener) {
|
@Nullable final IEthernetNetworkManagementListener listener) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.i(TAG, "updateConfiguration, iface: " + iface + ", capabilities: " + capabilities
|
Log.i(TAG, "updateConfiguration, iface: " + iface + ", capabilities: " + capabilities
|
||||||
@@ -241,7 +241,9 @@ public class EthernetTracker {
|
|||||||
}
|
}
|
||||||
final IpConfiguration localIpConfig = new IpConfiguration(ipConfig);
|
final IpConfiguration localIpConfig = new IpConfiguration(ipConfig);
|
||||||
writeIpConfiguration(iface, localIpConfig);
|
writeIpConfiguration(iface, localIpConfig);
|
||||||
mNetworkCapabilities.put(iface, capabilities);
|
if (null != capabilities) {
|
||||||
|
mNetworkCapabilities.put(iface, capabilities);
|
||||||
|
}
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
mFactory.updateInterface(iface, localIpConfig, capabilities, listener);
|
mFactory.updateInterface(iface, localIpConfig, capabilities, listener);
|
||||||
broadcastInterfaceStateChange(iface);
|
broadcastInterfaceStateChange(iface);
|
||||||
|
|||||||
@@ -247,6 +247,18 @@ public class EthernetServiceImplTest {
|
|||||||
verify(mEthernetTracker).disconnectNetwork(eq(TEST_IFACE), eq(NULL_LISTENER));
|
verify(mEthernetTracker).disconnectNetwork(eq(TEST_IFACE), eq(NULL_LISTENER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateConfigurationRejectsTestRequestWithNullCapabilities() {
|
||||||
|
enableTestInterface();
|
||||||
|
final EthernetNetworkUpdateRequest request =
|
||||||
|
new EthernetNetworkUpdateRequest
|
||||||
|
.Builder()
|
||||||
|
.setIpConfiguration(new IpConfiguration()).build();
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
mEthernetServiceImpl.updateConfiguration(TEST_IFACE, request, NULL_LISTENER);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateConfigurationRejectsInvalidTestRequest() {
|
public void testUpdateConfigurationRejectsInvalidTestRequest() {
|
||||||
enableTestInterface();
|
enableTestInterface();
|
||||||
|
|||||||
Reference in New Issue
Block a user