Merge lp:~cyphermox/network-manager/powersave+primaryconnectiontype into lp:~phablet-team/network-manager/rtm
- powersave+primaryconnectiontype
- Merge into rtm
Proposed by
Mathieu Trudel-Lapierre
Status: | Merged |
---|---|
Approved by: | Ricardo Salveti |
Approved revision: | 864 |
Merged at revision: | 863 |
Proposed branch: | lp:~cyphermox/network-manager/powersave+primaryconnectiontype |
Merge into: | lp:~phablet-team/network-manager/rtm |
Diff against target: |
373 lines (+337/-0) 5 files modified
debian/changelog (+18/-0) debian/libnm-util2.symbols (+1/-0) debian/patches/powersave.patch (+114/-0) debian/patches/primary_connection_type.patch (+202/-0) debian/patches/series (+2/-0) |
To merge this branch: | bzr merge lp:~cyphermox/network-manager/powersave+primaryconnectiontype |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
Review via email: mp+239556@code.launchpad.net |
Commit message
Description of the change
- Add powersave (barajas bug 1367745)
- New PrimaryConnecti
To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote : | # |
Revision history for this message
Ricardo Salveti (rsalveti) wrote : | # |
*Will create a package
Revision history for this message
Ricardo Salveti (rsalveti) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2014-10-15 19:24:43 +0000 |
3 | +++ debian/changelog 2014-10-24 13:10:24 +0000 |
4 | @@ -1,3 +1,21 @@ |
5 | +network-manager (0.9.8.8-0ubuntu29) UNRELEASED; urgency=medium |
6 | + |
7 | + [ Mathieu Trudel-Lapierre ] |
8 | + * debian/patches/powersave.patch: enable powersave mode when wifi devices |
9 | + are activated; disable it when we're disconnected so as not to interfere |
10 | + with scanning and getting connected again to some network. (LP: #1384823) |
11 | + * debian/libnm-util2.symbols: update symbols file for new method |
12 | + nm_connection_get_connection_type introduced for the PrimaryConnectionType |
13 | + patch. |
14 | + |
15 | + [ Ryan Lortie ] |
16 | + * debian/patches/primary_connection_type.patch: export the type of the |
17 | + currently active primary connection (the one that currently owns the |
18 | + default gateway), for use by applications to figure out when not to do |
19 | + heavy requests, for example, while on mobile broadband. (LP: #1384776) |
20 | + |
21 | + -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Thu, 23 Oct 2014 15:05:25 -0400 |
22 | + |
23 | network-manager (0.9.8.8-0ubuntu28) utopic; urgency=medium |
24 | |
25 | * debian/patches/add_ofono_support.patch: Ignore calls to set_mm_enabled; |
26 | |
27 | === modified file 'debian/libnm-util2.symbols' |
28 | --- debian/libnm-util2.symbols 2013-02-26 15:00:41 +0000 |
29 | +++ debian/libnm-util2.symbols 2014-10-24 13:10:24 +0000 |
30 | @@ -10,6 +10,7 @@ |
31 | nm_connection_error_get_type@Base 0.7.0 |
32 | nm_connection_error_quark@Base 0.7.0 |
33 | nm_connection_for_each_setting_value@Base 0.7.0 |
34 | + nm_connection_get_connection_type@Base 0.9.8.8-0ubuntu29~ |
35 | nm_connection_get_id@Base 0.8.998 |
36 | nm_connection_get_path@Base 0.7.0 |
37 | nm_connection_get_setting@Base 0.7.0 |
38 | |
39 | === added file 'debian/patches/powersave.patch' |
40 | --- debian/patches/powersave.patch 1970-01-01 00:00:00 +0000 |
41 | +++ debian/patches/powersave.patch 2014-10-24 13:10:24 +0000 |
42 | @@ -0,0 +1,114 @@ |
43 | +From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> |
44 | +Subject: Enable the use of powersave mode on supporting wireless devices |
45 | +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1384823 |
46 | + |
47 | +--- |
48 | + src/nm-device-wifi.c | 5 +++++ |
49 | + src/wifi/wifi-utils-nl80211.c | 23 +++++++++++++++++++++++ |
50 | + src/wifi/wifi-utils-private.h | 3 +++ |
51 | + src/wifi/wifi-utils.c | 8 ++++++++ |
52 | + 4 files changed, 39 insertions(+) |
53 | + |
54 | +Index: b/src/nm-device-wifi.c |
55 | +=================================================================== |
56 | +--- a/src/nm-device-wifi.c |
57 | ++++ b/src/nm-device-wifi.c |
58 | +@@ -959,6 +959,8 @@ deactivate (NMDevice *dev) |
59 | + /* Reset MAC address back to initial address */ |
60 | + _set_hw_addr (self, priv->initial_hw_addr, "reset"); |
61 | + |
62 | ++ wifi_utils_set_powersave (priv->wifi_data, FALSE); |
63 | ++ |
64 | + /* Ensure we're in infrastructure mode after deactivation; some devices |
65 | + * (usually older ones) don't scan well in adhoc mode. |
66 | + */ |
67 | +@@ -3489,12 +3491,15 @@ device_state_changed (NMDevice *device, |
68 | + nm_supplicant_interface_disconnect (priv->supplicant.iface); |
69 | + break; |
70 | + case NM_DEVICE_STATE_ACTIVATED: |
71 | ++ wifi_utils_set_powersave (priv->wifi_data, TRUE); |
72 | + activation_success_handler (device); |
73 | + break; |
74 | + case NM_DEVICE_STATE_FAILED: |
75 | ++ wifi_utils_set_powersave (priv->wifi_data, FALSE); |
76 | + activation_failure_handler (device); |
77 | + break; |
78 | + case NM_DEVICE_STATE_DISCONNECTED: |
79 | ++ wifi_utils_set_powersave (priv->wifi_data, FALSE); |
80 | + /* Kick off a scan to get latest results */ |
81 | + priv->scan_interval = SCAN_INTERVAL_MIN; |
82 | + cancel_pending_scan (self); |
83 | +Index: b/src/wifi/wifi-utils-nl80211.c |
84 | +=================================================================== |
85 | +--- a/src/wifi/wifi-utils-nl80211.c |
86 | ++++ b/src/wifi/wifi-utils-nl80211.c |
87 | +@@ -248,6 +248,28 @@ wifi_nl80211_set_mode (WifiData *data, c |
88 | + return FALSE; |
89 | + } |
90 | + |
91 | ++static gboolean |
92 | ++wifi_nl80211_set_powersave (WifiData *data, gboolean powersave) |
93 | ++{ |
94 | ++ WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data; |
95 | ++ struct nl_msg *msg; |
96 | ++ int err; |
97 | ++ |
98 | ++ msg = nl80211_alloc_msg (nl80211, NL80211_CMD_SET_POWER_SAVE, 0); |
99 | ++ |
100 | ++ if (powersave) |
101 | ++ NLA_PUT_U32 (msg, NL80211_ATTR_PS_STATE, NL80211_PS_ENABLED); |
102 | ++ else |
103 | ++ NLA_PUT_U32 (msg, NL80211_ATTR_PS_STATE, NL80211_PS_DISABLED); |
104 | ++ |
105 | ++ err = nl80211_send_and_recv (nl80211, msg, NULL, NULL); |
106 | ++ return err ? FALSE : TRUE; |
107 | ++ |
108 | ++nla_put_failure: |
109 | ++ nlmsg_free (msg); |
110 | ++ return FALSE; |
111 | ++} |
112 | ++ |
113 | + /* @divisor: pass what value @xbm should be divided by to get dBm */ |
114 | + static guint32 nl80211_xbm_to_percent (gint32 xbm, guint32 divisor) |
115 | + { |
116 | +@@ -739,6 +761,7 @@ wifi_nl80211_init (const char *iface, in |
117 | + nl80211 = wifi_data_new (iface, ifindex, sizeof (*nl80211)); |
118 | + nl80211->parent.get_mode = wifi_nl80211_get_mode; |
119 | + nl80211->parent.set_mode = wifi_nl80211_set_mode; |
120 | ++ nl80211->parent.set_powersave = wifi_nl80211_set_powersave; |
121 | + nl80211->parent.get_freq = wifi_nl80211_get_freq; |
122 | + nl80211->parent.find_freq = wifi_nl80211_find_freq; |
123 | + nl80211->parent.get_ssid = wifi_nl80211_get_ssid; |
124 | +Index: b/src/wifi/wifi-utils.c |
125 | +=================================================================== |
126 | +--- a/src/wifi/wifi-utils.c |
127 | ++++ b/src/wifi/wifi-utils.c |
128 | +@@ -104,6 +104,14 @@ wifi_utils_set_mode (WifiData *data, con |
129 | + return data->set_mode ? data->set_mode (data, mode) : TRUE; |
130 | + } |
131 | + |
132 | ++gboolean |
133 | ++wifi_utils_set_powersave (WifiData *data, gboolean powersave) |
134 | ++{ |
135 | ++ g_return_val_if_fail (data != NULL, FALSE); |
136 | ++ |
137 | ++ return data->set_powersave ? data->set_powersave (data, powersave) : TRUE; |
138 | ++} |
139 | ++ |
140 | + guint32 |
141 | + wifi_utils_get_freq (WifiData *data) |
142 | + { |
143 | +Index: b/src/wifi/wifi-utils-private.h |
144 | +=================================================================== |
145 | +--- a/src/wifi/wifi-utils-private.h |
146 | ++++ b/src/wifi/wifi-utils-private.h |
147 | +@@ -36,6 +36,9 @@ struct WifiData { |
148 | + |
149 | + gboolean (*set_mode) (WifiData *data, const NM80211Mode mode); |
150 | + |
151 | ++ /* Set power saving mode on an interface (nl80211 only) */ |
152 | ++ gboolean (*set_powersave) (WifiData *data, gboolean powersave); |
153 | ++ |
154 | + /* Return current frequency in MHz (really associated BSS frequency) */ |
155 | + guint32 (*get_freq) (WifiData *data); |
156 | + |
157 | |
158 | === added file 'debian/patches/primary_connection_type.patch' |
159 | --- debian/patches/primary_connection_type.patch 1970-01-01 00:00:00 +0000 |
160 | +++ debian/patches/primary_connection_type.patch 2014-10-24 13:10:24 +0000 |
161 | @@ -0,0 +1,202 @@ |
162 | +From 01dab14dbba76dd804858cad5f3b6ec4605b0d1a Mon Sep 17 00:00:00 2001 |
163 | +From: Ryan Lortie <desrt@desrt.ca> |
164 | +Date: Thu, 23 Oct 2014 13:56:52 -0400 |
165 | +Subject: [PATCH] Add PrimaryConnectionType property to the manager |
166 | + |
167 | +This will provide an extremely easy way for applications to find out |
168 | +what type of connection the system is currently using. They might want |
169 | +to do this to avoid using data if a phone is on a 3G connection, for |
170 | +example. |
171 | + |
172 | +Backported from https://bugzilla.gnome.org/show_bug.cgi?id=739080 |
173 | +--- |
174 | + introspection/nm-manager.xml | 8 ++++++++ |
175 | + libnm-util/libnm-util.ver | 1 + |
176 | + libnm-util/nm-connection.c | 21 +++++++++++++++++++++ |
177 | + libnm-util/nm-connection.h | 2 ++ |
178 | + src/nm-active-connection.c | 11 +++++++++++ |
179 | + src/nm-active-connection.h | 2 ++ |
180 | + src/nm-manager.c | 15 +++++++++++++++ |
181 | + src/nm-manager.h | 1 + |
182 | + 8 files changed, 61 insertions(+) |
183 | + |
184 | +diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml |
185 | +index a0e2773..97ffc87 100644 |
186 | +--- a/introspection/nm-manager.xml |
187 | ++++ b/introspection/nm-manager.xml |
188 | +@@ -326,6 +326,14 @@ |
189 | + </tp:docstring> |
190 | + </property> |
191 | + |
192 | ++ <property name="PrimaryConnectionType" type="s" access="read"> |
193 | ++ <tp:docstring> |
194 | ++ The connection type of the "primary" active connection being |
195 | ++ used to access the network. This is the same as the Type |
196 | ++ property on the object indicated by PrimaryConnection. |
197 | ++ </tp:docstring> |
198 | ++ </property> |
199 | ++ |
200 | + <property name="ActivatingConnection" type="o" access="read"> |
201 | + <tp:docstring> |
202 | + The object path of an active connection that is currently |
203 | +diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver |
204 | +index 04f2a91..dd68293 100644 |
205 | +--- a/libnm-util/libnm-util.ver |
206 | ++++ b/libnm-util/libnm-util.ver |
207 | +@@ -11,6 +11,7 @@ global: |
208 | + nm_connection_error_get_type; |
209 | + nm_connection_error_quark; |
210 | + nm_connection_for_each_setting_value; |
211 | ++ nm_connection_get_connection_type; |
212 | + nm_connection_get_id; |
213 | + nm_connection_get_path; |
214 | + nm_connection_get_setting; |
215 | +diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c |
216 | +index 15b1685..e684138 100644 |
217 | +--- a/libnm-util/nm-connection.c |
218 | ++++ b/libnm-util/nm-connection.c |
219 | +@@ -1249,6 +1249,27 @@ nm_connection_get_id (NMConnection *connection) |
220 | + return nm_setting_connection_get_id (s_con); |
221 | + } |
222 | + |
223 | ++/** |
224 | ++ * nm_connection_get_connection_type: |
225 | ++ * @connection: the #NMConnection |
226 | ++ * |
227 | ++ * A shortcut to return the type from the connection's #NMSettingConnection. |
228 | ++ * |
229 | ++ * Returns: the type from the connection's 'connection' setting |
230 | ++ **/ |
231 | ++const char * |
232 | ++nm_connection_get_connection_type (NMConnection *connection) |
233 | ++{ |
234 | ++ NMSettingConnection *s_con; |
235 | ++ |
236 | ++ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); |
237 | ++ |
238 | ++ s_con = nm_connection_get_setting_connection (connection); |
239 | ++ g_return_val_if_fail (s_con != NULL, NULL); |
240 | ++ |
241 | ++ return nm_setting_connection_get_connection_type (s_con); |
242 | ++} |
243 | ++ |
244 | + /*************************************************************/ |
245 | + |
246 | + /** |
247 | +diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h |
248 | +index 4d060cc..d6a18f7 100644 |
249 | +--- a/libnm-util/nm-connection.h |
250 | ++++ b/libnm-util/nm-connection.h |
251 | +@@ -187,6 +187,8 @@ const char * nm_connection_get_uuid (NMConnection *connection); |
252 | + |
253 | + const char * nm_connection_get_id (NMConnection *connection); |
254 | + |
255 | ++const char * nm_connection_get_connection_type (NMConnection *connection); |
256 | ++ |
257 | + NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection); |
258 | + NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection); |
259 | + NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection); |
260 | +diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c |
261 | +index 6e3a5da..5faded1 100644 |
262 | +--- a/src/nm-active-connection.c |
263 | ++++ b/src/nm-active-connection.c |
264 | +@@ -137,6 +137,17 @@ nm_active_connection_get_connection (NMActiveConnection *self) |
265 | + } |
266 | + |
267 | + const char * |
268 | ++nm_active_connection_get_connection_type (NMActiveConnection *self) |
269 | ++{ |
270 | ++ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); |
271 | ++ |
272 | ++ if (priv->connection == NULL) |
273 | ++ return NULL; |
274 | ++ |
275 | ++ return nm_connection_get_connection_type (priv->connection); |
276 | ++} |
277 | ++ |
278 | ++const char * |
279 | + nm_active_connection_get_path (NMActiveConnection *self) |
280 | + { |
281 | + return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->path; |
282 | +diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h |
283 | +index 2f17c58..0401f88 100644 |
284 | +--- a/src/nm-active-connection.h |
285 | ++++ b/src/nm-active-connection.h |
286 | +@@ -70,6 +70,8 @@ void nm_active_connection_export (NMActiveConnection *self); |
287 | + NMConnection *nm_active_connection_get_connection (NMActiveConnection *self); |
288 | + const char * nm_active_connection_get_name (NMActiveConnection *self); |
289 | + |
290 | ++const char * nm_active_connection_get_connection_type (NMActiveConnection *self); |
291 | ++ |
292 | + const char * nm_active_connection_get_path (NMActiveConnection *self); |
293 | + |
294 | + const char * nm_active_connection_get_specific_object (NMActiveConnection *self); |
295 | +diff --git a/src/nm-manager.c b/src/nm-manager.c |
296 | +index 9c82d14..11a50f2 100644 |
297 | +--- a/src/nm-manager.c |
298 | ++++ b/src/nm-manager.c |
299 | +@@ -291,6 +291,7 @@ enum { |
300 | + PROP_ACTIVE_CONNECTIONS, |
301 | + PROP_CONNECTIVITY, |
302 | + PROP_PRIMARY_CONNECTION, |
303 | ++ PROP_PRIMARY_CONNECTION_TYPE, |
304 | + PROP_ACTIVATING_CONNECTION, |
305 | + |
306 | + /* Not exported */ |
307 | +@@ -4054,6 +4055,7 @@ policy_default_device_changed (GObject *object, GParamSpec *pspec, gpointer user |
308 | + priv->primary_connection = ac ? g_object_ref (ac) : NULL; |
309 | + nm_log_dbg (LOGD_CORE, "PrimaryConnection now %s", ac ? nm_active_connection_get_name (ac) : "(none)"); |
310 | + g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION); |
311 | ++ g_object_notify (G_OBJECT (self), NM_MANAGER_PRIMARY_CONNECTION_TYPE); |
312 | + } |
313 | + } |
314 | + |
315 | +@@ -4660,6 +4662,7 @@ get_property (GObject *object, guint prop_id, |
316 | + GSList *iter; |
317 | + GPtrArray *active; |
318 | + const char *path; |
319 | ++ const char *type; |
320 | + |
321 | + switch (prop_id) { |
322 | + case PROP_VERSION: |
323 | +@@ -4705,6 +4708,10 @@ get_property (GObject *object, guint prop_id, |
324 | + path = priv->primary_connection ? nm_active_connection_get_path (priv->primary_connection) : "/"; |
325 | + g_value_set_boxed (value, path); |
326 | + break; |
327 | ++ case PROP_PRIMARY_CONNECTION_TYPE: |
328 | ++ type = priv->primary_connection ? nm_active_connection_get_connection_type (priv->primary_connection) : NULL; |
329 | ++ g_value_set_string (value, type ? type : ""); |
330 | ++ break; |
331 | + case PROP_ACTIVATING_CONNECTION: |
332 | + path = priv->activating_connection ? nm_active_connection_get_path (priv->activating_connection) : "/"; |
333 | + g_value_set_boxed (value, path); |
334 | +@@ -4981,6 +4988,14 @@ nm_manager_class_init (NMManagerClass *manager_class) |
335 | + G_PARAM_READABLE)); |
336 | + |
337 | + g_object_class_install_property |
338 | ++ (object_class, PROP_PRIMARY_CONNECTION_TYPE, |
339 | ++ g_param_spec_string (NM_MANAGER_PRIMARY_CONNECTION_TYPE, "", "", |
340 | ++ NULL, |
341 | ++ G_PARAM_READABLE | |
342 | ++ G_PARAM_STATIC_STRINGS)); |
343 | ++ |
344 | ++ |
345 | ++ g_object_class_install_property |
346 | + (object_class, PROP_ACTIVATING_CONNECTION, |
347 | + g_param_spec_boxed (NM_MANAGER_ACTIVATING_CONNECTION, |
348 | + "Activating connection", |
349 | +diff --git a/src/nm-manager.h b/src/nm-manager.h |
350 | +index 9884d05..a0c9065 100644 |
351 | +--- a/src/nm-manager.h |
352 | ++++ b/src/nm-manager.h |
353 | +@@ -61,6 +61,7 @@ typedef enum { |
354 | + #define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections" |
355 | + #define NM_MANAGER_CONNECTIVITY "connectivity" |
356 | + #define NM_MANAGER_PRIMARY_CONNECTION "primary-connection" |
357 | ++#define NM_MANAGER_PRIMARY_CONNECTION_TYPE "primary-connection-type" |
358 | + #define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection" |
359 | + |
360 | + /* Not exported */ |
361 | +-- |
362 | +2.1.0 |
363 | + |
364 | |
365 | === modified file 'debian/patches/series' |
366 | --- debian/patches/series 2014-10-15 19:24:43 +0000 |
367 | +++ debian/patches/series 2014-10-24 13:10:24 +0000 |
368 | @@ -43,3 +43,5 @@ |
369 | remove-extra-scan_done-on-scan-start.patch |
370 | scan_update_last_seen.patch |
371 | cull_aps_on_scan_done_signal.patch |
372 | +powersave.patch |
373 | +primary_connection_type.patch |
LGTM
Will create a patch and test to see if it actually works as expected (before top approval).