Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore modem state when getting position from MM [backport release-5.6.0] #5534

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading