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
1=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp'
2--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-04-14 14:26:38 +0000
3+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp 2015-04-27 19:37:56 +0000
4@@ -75,8 +75,9 @@
5 {
6 std::lock_guard<std::mutex> lg(d.cached.guard);
7
8- for (const auto& pair : d.cached.wireless_devices)
9- pair.second.request_scan();
10+ for (const auto& pair : d.cached.nm_devices)
11+ if (pair.second.type() == xdg::NetworkManager::Device::Type::wifi)
12+ pair.second.request_scan();
13 }
14
15 const core::Signal<>& connectivity::OfonoNmConnectivityManager::wireless_network_scan_finished() const
16@@ -506,16 +507,23 @@
17 const core::dbus::types::ObjectPath& device_path,
18 std::unique_lock<std::mutex>& ul)
19 {
20- if (cached.wireless_devices.count(device_path) > 0)
21+ if (cached.nm_devices.count(device_path) > 0)
22 return;
23
24 auto device = network_manager->device_for_path(device_path);
25
26+ if (device.type() == xdg::NetworkManager::Device::Type::modem)
27+ {
28+ // Make the device known to the cache.
29+ std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device>::iterator it;
30+ std::tie(it, std::ignore) = cached.nm_devices.insert(std::make_pair(device_path, device));
31+ }
32+
33 if (device.type() == xdg::NetworkManager::Device::Type::wifi)
34 {
35 // Make the device known to the cache.
36 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device>::iterator it;
37- std::tie(it, std::ignore) = cached.wireless_devices.insert(std::make_pair(device_path, device));
38+ std::tie(it, std::ignore) = cached.nm_devices.insert(std::make_pair(device_path, device));
39
40 // Iterate over all currently known wifis
41 it->second.for_each_access_point([this, device_path, &ul](const core::dbus::types::ObjectPath& path)
42@@ -567,7 +575,7 @@
43 const core::dbus::types::ObjectPath& path,
44 std::unique_lock<std::mutex>&)
45 {
46- cached.wireless_devices.erase(path);
47+ cached.nm_devices.erase(path);
48 }
49
50 void connectivity::OfonoNmConnectivityManager::Private::on_access_point_added(
51@@ -577,8 +585,8 @@
52 {
53 // Let's see if we have a device known for the path. We return early
54 // if we do not know about the device.
55- auto itd = cached.wireless_devices.find(device_path);
56- if (itd == cached.wireless_devices.end())
57+ auto itd = cached.nm_devices.find(device_path);
58+ if (itd == cached.nm_devices.end() || itd->second.type() != xdg::NetworkManager::Device::Type::wifi)
59 return;
60
61 xdg::NetworkManager::AccessPoint ap
62@@ -638,8 +646,8 @@
63 // We only consider cached devices and do not reach out to enumerate all of the devices
64 // to prevent from excessive dbus roundtrips.
65 std::lock_guard<std::mutex> lg{cached.guard};
66- if (cached.wireless_devices.count(path) > 0)
67- type = cached.wireless_devices.at(path).type();
68+ if (cached.nm_devices.count(path) > 0 )
69+ type = cached.nm_devices.at(path).type();
70 }
71
72 // We interpret a primary connection over a modem device as
73@@ -672,7 +680,7 @@
74 }
75 }
76
77- characteristics = characteristics | all_characteristics();
78+ characteristics = characteristics | all_characteristics();
79 } else if (type == xdg::NetworkManager::Device::Type::wifi)
80 {
81 characteristics = characteristics | connectivity::Characteristics::connection_goes_via_wifi;
82@@ -684,6 +692,7 @@
83 // Empty on purpose.
84 }
85
86+ LOG(INFO) << characteristics << std::endl;
87 return characteristics;
88 }
89
90
91=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h'
92--- src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h 2015-04-14 14:26:38 +0000
93+++ src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h 2015-04-27 19:37:56 +0000
94@@ -162,7 +162,7 @@
95 std::map<core::dbus::types::ObjectPath, detail::CachedRadioCell::Ptr> cells;
96 std::map<core::dbus::types::ObjectPath, org::Ofono::Manager::Modem> modems;
97 std::map<core::dbus::types::ObjectPath, detail::CachedWirelessNetwork::Ptr> wifis;
98- std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> wireless_devices;
99+ std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> nm_devices;
100 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::ActiveConnection> primary_connection;
101 std::map<core::dbus::types::ObjectPath, org::freedesktop::NetworkManager::Device> primary_connection_devices;
102 } cached;

Subscribers

People subscribed via source and target branches