Merge lp:~mandel/location-service/first-connection into lp:location-service/trunk

Proposed by Manuel de la Peña
Status: Merged
Approved by: Michael Frey
Approved revision: 192
Merged at revision: 191
Proposed branch: lp:~mandel/location-service/first-connection
Merge into: lp:location-service/trunk
Diff against target: 102 lines (+20/-11)
2 files modified
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+19/-10)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h (+1/-1)
To merge this branch: bzr merge lp:~mandel/location-service/first-connection
Reviewer Review Type Date Requested Status
Michael Frey (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+257540@code.launchpad.net

Commit message

Make sure that cached modems are considered as well when calculating connection characteristics.

Description of the change

Update fixes from tvoss by merging with trunk.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
192. By Manuel de la Peña

Link bug.

Revision history for this message
Michael Frey (mfrey) wrote :

Tested fixes issue.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-04-14 14:26:38 +0000
+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-04-27 19:37:56 +0000
@@ -75,8 +75,9 @@
75{75{
76 std::lock_guard<std::mutex> lg(d.cached.guard);76 std::lock_guard<std::mutex> lg(d.cached.guard);
7777
78 for (const auto& pair : d.cached.wireless_devices)78 for (const auto& pair : d.cached.nm_devices)
79 pair.second.request_scan();79 if (pair.second.type() == xdg::NetworkManager::Device::Type::wifi)
80 pair.second.request_scan();
80}81}
8182
82const core::Signal<>& connectivity::OfonoNmConnectivityManager::wireless_network_scan_finished() const83const core::Signal<>& connectivity::OfonoNmConnectivityManager::wireless_network_scan_finished() const
@@ -506,16 +507,23 @@
506 const core::dbus::types::ObjectPath& device_path,507 const core::dbus::types::ObjectPath& device_path,
507 std::unique_lock<std::mutex>& ul)508 std::unique_lock<std::mutex>& ul)
508{509{
509 if (cached.wireless_devices.count(device_path) > 0)510 if (cached.nm_devices.count(device_path) > 0)
510 return;511 return;
511512
512 auto device = network_manager->device_for_path(device_path);513 auto device = network_manager->device_for_path(device_path);
513514
515 if (device.type() == xdg::NetworkManager::Device::Type::modem)
516 {
517 // Make the device known to the cache.
518 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device>::iterator it;
519 std::tie(it, std::ignore) = cached.nm_devices.insert(std::make_pair(device_path, device));
520 }
521
514 if (device.type() == xdg::NetworkManager::Device::Type::wifi)522 if (device.type() == xdg::NetworkManager::Device::Type::wifi)
515 {523 {
516 // Make the device known to the cache.524 // Make the device known to the cache.
517 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device>::iterator it;525 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device>::iterator it;
518 std::tie(it, std::ignore) = cached.wireless_devices.insert(std::make_pair(device_path, device));526 std::tie(it, std::ignore) = cached.nm_devices.insert(std::make_pair(device_path, device));
519527
520 // Iterate over all currently known wifis528 // Iterate over all currently known wifis
521 it->second.for_each_access_point([this, device_path, &ul](const core::dbus::types::ObjectPath& path)529 it->second.for_each_access_point([this, device_path, &ul](const core::dbus::types::ObjectPath& path)
@@ -567,7 +575,7 @@
567 const core::dbus::types::ObjectPath& path,575 const core::dbus::types::ObjectPath& path,
568 std::unique_lock<std::mutex>&)576 std::unique_lock<std::mutex>&)
569{577{
570 cached.wireless_devices.erase(path);578 cached.nm_devices.erase(path);
571}579}
572580
573void connectivity::OfonoNmConnectivityManager::Private::on_access_point_added(581void connectivity::OfonoNmConnectivityManager::Private::on_access_point_added(
@@ -577,8 +585,8 @@
577{585{
578 // Let's see if we have a device known for the path. We return early586 // Let's see if we have a device known for the path. We return early
579 // if we do not know about the device.587 // if we do not know about the device.
580 auto itd = cached.wireless_devices.find(device_path);588 auto itd = cached.nm_devices.find(device_path);
581 if (itd == cached.wireless_devices.end())589 if (itd == cached.nm_devices.end() || itd->second.type() != xdg::NetworkManager::Device::Type::wifi)
582 return;590 return;
583591
584 xdg::NetworkManager::AccessPoint ap592 xdg::NetworkManager::AccessPoint ap
@@ -638,8 +646,8 @@
638 // We only consider cached devices and do not reach out to enumerate all of the devices646 // We only consider cached devices and do not reach out to enumerate all of the devices
639 // to prevent from excessive dbus roundtrips.647 // to prevent from excessive dbus roundtrips.
640 std::lock_guard<std::mutex> lg{cached.guard};648 std::lock_guard<std::mutex> lg{cached.guard};
641 if (cached.wireless_devices.count(path) > 0)649 if (cached.nm_devices.count(path) > 0 )
642 type = cached.wireless_devices.at(path).type(); 650 type = cached.nm_devices.at(path).type();
643 }651 }
644652
645 // We interpret a primary connection over a modem device as653 // We interpret a primary connection over a modem device as
@@ -672,7 +680,7 @@
672 }680 }
673 }681 }
674682
675 characteristics = characteristics | all_characteristics();683 characteristics = characteristics | all_characteristics();
676 } else if (type == xdg::NetworkManager::Device::Type::wifi)684 } else if (type == xdg::NetworkManager::Device::Type::wifi)
677 {685 {
678 characteristics = characteristics | connectivity::Characteristics::connection_goes_via_wifi;686 characteristics = characteristics | connectivity::Characteristics::connection_goes_via_wifi;
@@ -684,6 +692,7 @@
684 // Empty on purpose.692 // Empty on purpose.
685 }693 }
686694
695 LOG(INFO) << characteristics << std::endl;
687 return characteristics;696 return characteristics;
688}697}
689698
690699
=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h'
--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h 2015-04-14 14:26:38 +0000
+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h 2015-04-27 19:37:56 +0000
@@ -162,7 +162,7 @@
162 std::map<core::dbus::types::ObjectPath, detail::CachedRadioCell::Ptr> cells;162 std::map<core::dbus::types::ObjectPath, detail::CachedRadioCell::Ptr> cells;
163 std::map<core::dbus::types::ObjectPath, org::Ofono::Manager::Modem> modems;163 std::map<core::dbus::types::ObjectPath, org::Ofono::Manager::Modem> modems;
164 std::map<core::dbus::types::ObjectPath, detail::CachedWirelessNetwork::Ptr> wifis;164 std::map<core::dbus::types::ObjectPath, detail::CachedWirelessNetwork::Ptr> wifis;
165 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> wireless_devices;165 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> nm_devices;
166 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::ActiveConnection> primary_connection;166 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::ActiveConnection> primary_connection;
167 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> primary_connection_devices;167 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> primary_connection_devices;
168 } cached;168 } cached;

Subscribers

People subscribed via source and target branches