Skip to content

Commit

Permalink
fix: fixed null in wi-fi frontend and missing wi-fi update on IPv6
Browse files Browse the repository at this point in the history
Signed-off-by: MMaiero <[email protected]>
  • Loading branch information
MMaiero committed Jun 22, 2024
1 parent 0a2a820 commit bd50775
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1322,16 +1322,16 @@ private void setPasswordValidation() {
configUserOptions.allowAnyPassword();
}

if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA_MESSAGE)
if (this.security != null && (this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA_MESSAGE)
|| this.security.getSelectedItemText().equals(WIFI_SECURITY_WPA2_MESSAGE)
|| this.security.getSelectedItemText().contentEquals(WIFI_SECURITY_WPA_WPA2_MESSAGE)) {
|| this.security.getSelectedItemText().contentEquals(WIFI_SECURITY_WPA_WPA2_MESSAGE))) {

this.password.setValidatorsFrom(configUserOptions);
configUserOptions.setPasswordMinimumLength(Math.min(configUserOptions.getPasswordMinimumLength(), 63));

this.password.addValidator(GwtValidators.regex(REGEX_PASS_WPA, MSGS.netWifiWirelessInvalidWPAPassword()));

} else if (this.security.getSelectedItemText().equals(WIFI_SECURITY_WEP_MESSAGE)) {
} else if (this.security != null && this.security.getSelectedItemText().equals(WIFI_SECURITY_WEP_MESSAGE)) {

configUserOptions.setPasswordRequireSpecialChars(false);
configUserOptions.setPasswordMinimumLength(Math.min(configUserOptions.getPasswordMinimumLength(), 26));
Expand Down Expand Up @@ -1741,14 +1741,14 @@ private void setForm(boolean visible) {
private boolean checkPassword() {
boolean result = true;

if (!this.password.validate() && this.password.isEnabled()) {
if (this.password != null && !this.password.validate() && this.password.isEnabled()) {
this.groupPassword.setValidationState(ValidationState.ERROR);
result = false;
} else {
this.groupPassword.setValidationState(ValidationState.NONE);
}

if (this.verify.isEnabled() && TabWirelessUi.this.password != null
if (this.verify != null && this.verify.isEnabled() && TabWirelessUi.this.password != null
&& !TabWirelessUi.this.verify.getText().equals(TabWirelessUi.this.password.getText())) {
TabWirelessUi.this.helpVerify.setText(MSGS.netWifiWirelessPasswordDoesNotMatch());
TabWirelessUi.this.groupVerify.setValidationState(ValidationState.ERROR);
Expand Down Expand Up @@ -1820,7 +1820,8 @@ private void updateChannelListValues(List<GwtWifiChannelFrequency> freqChannels)
addAutomaticChannel(freqChannels);
freqChannels.stream().forEach(this::addItemChannelList);

if (this.activeConfig.getChannels() != null && !this.activeConfig.getChannels().isEmpty()) {
if (this.activeConfig != null && this.activeConfig.getChannels() != null
&& !this.activeConfig.getChannels().isEmpty()) {
this.netTabs.hardwareTab.channel
.setText(this.channelList.getItemText(this.activeConfig.getChannels().get(0)));

Expand Down Expand Up @@ -1880,7 +1881,7 @@ public void onSuccess(Boolean acSupported) {

if (selectedRadioMode != null) {
setRadioModeByValue(selectedRadioMode);
} else {
} else if (TabWirelessUi.this.activeConfig != null) {
setRadioModeByValue(TabWirelessUi.this.activeConfig.getRadioMode());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ public Map<String, Object> build() throws GwtKuraException {
setIpv4DhcpServerProperties();
set8021xConfig();

switch (this.gwtConfig.getStatusEnum()) {
case netIPv4StatusDisabled:
break;
case netIPv4StatusUnmanaged:
break;
default:
if (isIPv4StatusEnabledManaged(this.gwtConfig.getStatus())
|| isIPv6StatusEnabledManaged(this.gwtConfig.getIpv6Status())) {
setWifiProperties();
setModemProperties();
break;
}

// Manage GPS independently of device ip status
Expand All @@ -83,6 +78,15 @@ public Map<String, Object> build() throws GwtKuraException {
return this.properties.getProperties();
}

private boolean isIPv4StatusEnabledManaged(String ipv4Status) {
return !(ipv4Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name())
|| ipv4Status.equals(GwtNetIfStatus.netIPv4StatusUnmanaged.name()));
}

private boolean isIPv6StatusEnabledManaged(String ipv6Status) {
return !ipv6Status.equals(GwtNetIfStatus.netIPv6StatusDisabled.name());
}

private void setCommonProperties() {
this.properties.setType(this.ifname, this.gwtConfig.getHwType());

Expand Down Expand Up @@ -427,7 +431,7 @@ private void setAdvancedProperties() {
this.properties.setIp6Mtu(this.ifname,
Objects.nonNull(this.gwtConfig.getIpv6Mtu()) ? this.gwtConfig.getIpv6Mtu() : DEFAULT_MTU);
this.properties.setPromisc(this.ifname,
Objects.nonNull(this.gwtConfig.getPromisc()) ? this.gwtConfig.getPromisc() : DEFAULT_PROMISC);
Objects.nonNull(this.gwtConfig.getPromisc()) ? this.gwtConfig.getPromisc() : DEFAULT_PROMISC);
}

private static GwtNetInterfaceConfig getConfigsAndStatuses(String ifName) throws GwtKuraException, KuraException {
Expand Down

0 comments on commit bd50775

Please sign in to comment.