Skip to content

Commit

Permalink
feat(nm): Modem APN as an optional parameter (#5350)
Browse files Browse the repository at this point in the history
* Made apn an optional parameter

Signed-off-by: pierantoniomerlino <[email protected]>

* Fixed nm apn test

Signed-off-by: pierantoniomerlino <[email protected]>

---------

Signed-off-by: pierantoniomerlino <[email protected]>
  • Loading branch information
pierantoniomerlino authored Sep 12, 2024
1 parent 634a04c commit 402e5e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ private static void configureIp6MethodManual(NetworkProperties props, String dev
settings.put("address-data", new Variant<>(addressData, "aa{sv}"));
}

private static void configureIp6MethodAuto(NetworkProperties props, String deviceId, Map<String, Variant<?>> settings) {
private static void configureIp6MethodAuto(NetworkProperties props, String deviceId,
Map<String, Variant<?>> settings) {
settings.put(NM_SETTINGS_IPV6_METHOD, new Variant<>("auto"));

Optional<String> addressGenerationMode = props.getOpt(String.class,
Expand Down Expand Up @@ -568,8 +569,8 @@ private static Map<String, Variant<?>> createWPA2WPA3EnterpriseSettings() {
public static Map<String, Variant<?>> buildGsmSettings(NetworkProperties props, String deviceId) {
Map<String, Variant<?>> settings = new HashMap<>();

String apn = props.get(String.class, "net.interface.%s.config.apn", deviceId);
settings.put("apn", new Variant<>(apn));
Optional<String> apn = props.getOpt(String.class, "net.interface.%s.config.apn", deviceId);
apn.ifPresent(apnString -> settings.put("apn", new Variant<>(apnString)));

Optional<String> username = props.getOpt(String.class, "net.interface.%s.config.username", deviceId);
username.ifPresent(usernameString -> settings.put("username", new Variant<>(usernameString)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,6 @@ public boolean isValid() {
if (this.dial.getText() == null || "".equals(this.dial.getText().trim())) {
this.groupDial.setValidationState(ValidationState.ERROR);
}
if (this.apn.getText() == null || "".equals(this.apn.getText().trim())) {
if (this.apn.isEnabled()) {
this.groupApn.setValidationState(ValidationState.ERROR);
}
}
if (this.maxfail.getText() == null || "".equals(this.maxfail.getText().trim())) {
this.groupMaxfail.setValidationState(ValidationState.ERROR);
}
Expand Down Expand Up @@ -547,26 +542,15 @@ private void initForm() {
});

// APN
this.labelApn.setText(MSGS.netModemAPN() + "*");
this.labelApn.setText(MSGS.netModemAPN());
this.apn.addMouseOverHandler(event -> {
if (TabModemUi.this.apn.isEnabled()) {
TabModemUi.this.helpText.clear();
TabModemUi.this.helpText.add(new Span(MSGS.netModemToolTipApn()));
}
});
this.apn.addMouseOutHandler(event -> resetHelp());
this.apn.addValueChangeHandler(event -> {
setDirty(true);
if (TabModemUi.this.apn.getText() == null || "".equals(TabModemUi.this.apn.getText().trim())) {
if (TabModemUi.this.apn.isEnabled()) {
TabModemUi.this.groupApn.setValidationState(ValidationState.ERROR);
} else {
TabModemUi.this.groupApn.setValidationState(ValidationState.NONE);
}
} else {
TabModemUi.this.groupApn.setValidationState(ValidationState.NONE);
}
});
this.apn.addValueChangeHandler(event -> setDirty(true));

// AUTH TYPE
this.labelAuth.setText(MSGS.netModemAuthType());
Expand Down Expand Up @@ -672,7 +656,7 @@ private void initForm() {
TabModemUi.this.groupMaxfail.setValidationState(ValidationState.NONE);
}
});

this.labelHoldoff.setText(MSGS.netModemHoldoff() + "*");
this.holdoff.addMouseOverHandler(event -> {
if (TabModemUi.this.holdoff.isEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,12 @@ public void build80211WirelessSecuritySettingsShouldThrowWhenGivenMalformedSecur
}

@Test
public void buildGsmSettingsShouldThrowWithMissingRequiredArgument() {
public void buildGsmSettingsShouldNotThrowWithNoArgument() {
givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap);

whenBuildGsmSettingsIsRunWith(this.networkProperties, "ttyACM0");

thenExceptionOccurred(NoSuchElementException.class);
thenNoExceptionOccurred();
}

@Test
Expand Down

0 comments on commit 402e5e6

Please sign in to comment.