Skip to content

Commit

Permalink
fix: Ignore modem state when getting position from MM (#5532)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Timeus <[email protected]>
  • Loading branch information
nicolatimeus authored Nov 8, 2024
1 parent c2ea2ff commit e6694b7
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.kura.net.wifi.WifiChannel;
import org.eclipse.kura.nm.configuration.NMSettingsConverter;
import org.eclipse.kura.nm.enums.MMModemLocationSource;
import org.eclipse.kura.nm.enums.MMModemState;
import org.eclipse.kura.nm.enums.NMDeviceState;
import org.eclipse.kura.nm.enums.NMDeviceType;
import org.eclipse.kura.nm.signal.handlers.DeviceCreationLock;
Expand Down Expand Up @@ -650,7 +649,7 @@ private void configurationEnforcementDisable() throws DBusException {
public List<Location> getAvailableMMLocations() {
List<Location> availableLocations = new ArrayList<>();

this.getEnabledModemsPaths().forEach(modemPath -> {
this.getModemsPaths().forEach(modemPath -> {
try {
Properties locationProperties = this.modemManager
.getLocationProperties(this.modemManager.getModemManagerLocation(modemPath));
Expand All @@ -671,30 +670,22 @@ public List<Location> getAvailableMMLocations() {

}

private List<String> getEnabledModemsPaths() {
List<String> enabledModemsPath = new ArrayList<>();
private List<String> getModemsPaths() {
List<String> modemsPath = new ArrayList<>();

try {

for (Device device : this.networkManager.getAllDevices()) {
if (networkManager.getDeviceType(device.getObjectPath()).equals(NMDeviceType.NM_DEVICE_TYPE_MODEM)) {
Optional<String> modemPath = this.networkManager.getModemManagerDbusPath(device.getObjectPath());
if (modemPath.isPresent()) {
Optional<Properties> modemProps = this.modemManager.getModemProperties(modemPath.get());
modemProps.ifPresent(props -> {
MMModemState modemState = this.modemManager.getMMModemState(props);
if (modemState.equals(MMModemState.MM_MODEM_STATE_CONNECTED)
|| modemState.equals(MMModemState.MM_MODEM_STATE_REGISTERED)) {
enabledModemsPath.add(modemPath.get());
}
});
}

modemPath.ifPresent(modemsPath::add);
}
}
} catch (DBusException ex) {
logger.debug("Impossible to retrieve information regarding available modems");
}

return enabledModemsPath;
return modemsPath;
}
}

0 comments on commit e6694b7

Please sign in to comment.