Merge lp:~phablet-team/network-manager/lp1445080-wily into lp:~network-manager/network-manager/ubuntu
- lp1445080-wily
- Merge into ubuntu
Status: | Merged |
---|---|
Approved by: | Mathieu Trudel-Lapierre |
Approved revision: | 970 |
Merged at revision: | 969 |
Proposed branch: | lp:~phablet-team/network-manager/lp1445080-wily |
Merge into: | lp:~network-manager/network-manager/ubuntu |
Prerequisite: | lp:~phablet-team/network-manager/lp1461593-wily |
Diff against target: |
762 lines (+301/-188) 6 files modified
debian/changelog (+7/-0) debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch (+215/-183) debian/patches/lp1445080-modify-device-modem-avail.patch (+44/-0) debian/patches/lp1445080-nm-modem-check-for-set-mm-enabled-func.patch (+28/-0) debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch (+5/-5) debian/patches/series (+2/-0) |
To merge this branch: | bzr merge lp:~phablet-team/network-manager/lp1445080-wily |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mathieu Trudel-Lapierre | Approve | ||
Review via email: mp+264895@code.launchpad.net |
Commit message
Description of the change
This change re-factors the modem_state handling code in NMModemOfono to solve underlying race conditions in the handling of flight-mode.
Mathieu Trudel-Lapierre (cyphermox) wrote : | # |
- 967. By Tony Espy
-
debian/
patches/ add_ofono_ settings_ support. patch: remove code
that added APN, USERNAME and PASSWORD to NM_SETTING_GSM object.
NM doesn't actually need access to these settings, and USERNAME/
PASSWORD can cause issues with NM's secrets needed logic. - 968. By Tony Espy
-
debian/
patches/ 0001-wwan- add-support- for-using- oFono-as- a-modem- manager. patch,
debian/patches/ lp1461593- add-nm- settings- connection- reset-retries- methods. patch,
debian/patches/ add_ofono_ settings_ support. patch,
debian/patches/ lp1461593- add-modem- reconnect- delay-to- policy. patch: More changes
to NMModemOfono's modem_state handling. Added get/set_reset_retries_ timeout
methods to NMSettingsConnection, and use the set method to lower the timeout for
ofono connections to 30s. Finally added a 5s delay to NM_POLICY's activation
logic triggered when a modem device is disconnected. This allows modem time to
settle and NM to process the resulting DBus state changes. (LP: #1461593) - 969. By Tony Espy
-
Updated new patches for DEP-3, and re-ordered ofono patches.
- 970. By Tony Espy
-
debian/
patches/ 0001-wwan- add-support- for-using- oFono-as- a-modem- manager. patch,
debian/patches/ lp1445080- modify- device- modem-avail. patch,
debian/patches/ lp1445080- nm-modem- check-for- set-mm- enabled- func.patch,
debian/patches/ lp1461593- add-modem- reconnect- delay-to- policy. patch: These
changes collectively fix flight-mode on arale ( and other devices ), due to
some fundemental race conditions in the ofono logic. (LP: #1445080, #1440917)
Tony Espy (awe) wrote : | # |
Updated to fold the core changes into existing patches, created new patches for core changes, and ensure that new patches have DEP-3 headers.
Yes, some of the core changes were discussed upstream, but as I wasn't getting much traction with upstream and the changes needed to land for phone networking stabilization, the changes were landed in the phone overlay PPA after being reviewed and thoroughly tested.
> What is the likely impact on non-ofono modems of the changes to nm_device_modem to not return that connections are unavailable when the modem is still in NM_MODEM_
Actually, that's not how the change works. The change ensures that devices with a modem_state <= SEARCHING are considered unavailable. As INITIALIZING is less than SEARCHING, modems in this state will still be considered unavailable. This is consistent with the function documentation for nm_device_
Mathieu Trudel-Lapierre (cyphermox) : | # |
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-07-17 20:04:13 +0000 |
3 | +++ debian/changelog 2015-07-17 20:04:14 +0000 |
4 | @@ -15,6 +15,13 @@ |
5 | logic triggered when a modem device is disconnected. This allows modem time to |
6 | settle and NM to process the resulting DBus state changes. (LP: #1461593) |
7 | |
8 | + * debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch, |
9 | + debian/patches/lp1445080-modify-device-modem-avail.patch, |
10 | + debian/patches/lp1445080-nm-modem-check-for-set-mm-enabled-func.patch, |
11 | + debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch: These |
12 | + changes collectively fix flight-mode on arale ( and other devices ), due to |
13 | + some fundemental race conditions in the ofono logic. (LP: #1445080, #1440917) |
14 | + |
15 | -- Tony Espy <espy@canonical.com> Wed, 15 Jul 2015 15:35:17 -0400 |
16 | |
17 | network-manager (0.9.10.0-4ubuntu18) wily; urgency=medium |
18 | |
19 | === modified file 'debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch' |
20 | --- debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-07-17 20:04:13 +0000 |
21 | +++ debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-07-17 20:04:14 +0000 |
22 | @@ -304,7 +304,7 @@ |
23 | =================================================================== |
24 | --- /dev/null |
25 | +++ network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.c |
26 | -@@ -0,0 +1,1147 @@ |
27 | +@@ -0,0 +1,1179 @@ |
28 | +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ |
29 | +/* NetworkManager -- Network link manager |
30 | + * |
31 | @@ -361,14 +361,13 @@ |
32 | + |
33 | + char **interfaces; |
34 | + char *context_path; |
35 | ++ char *imsi; |
36 | + |
37 | + gboolean modem_online; |
38 | + gboolean gprs_attached; |
39 | -+ gboolean gprs_powered; |
40 | + |
41 | + NMIP4Config *ip4_config; |
42 | + |
43 | -+ gboolean enabled; |
44 | +} NMModemOfonoPrivate; |
45 | + |
46 | +#define NM_OFONO_ERROR (nm_ofono_error_quark ()) |
47 | @@ -396,6 +395,43 @@ |
48 | + return TRUE; |
49 | +} |
50 | + |
51 | ++static void ofono_read_contexts (NMModemOfono *self); |
52 | ++ |
53 | ++static void |
54 | ++update_modem_state (NMModemOfono *self) |
55 | ++{ |
56 | ++ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
57 | ++ NMModemState state = nm_modem_get_state (NM_MODEM (self)); |
58 | ++ NMModemState new_state = NM_MODEM_STATE_UNKNOWN; |
59 | ++ const char *reason; |
60 | ++ |
61 | ++ nm_log_info (LOGD_MB, "(%s): %s: 'Attached': %s 'Online': %s 'IMSI': %s", |
62 | ++ nm_modem_get_path (NM_MODEM (self)), |
63 | ++ __func__, |
64 | ++ priv->gprs_attached ? "true" : "false", |
65 | ++ priv->modem_online ? "true" : "false", |
66 | ++ priv->imsi); |
67 | ++ |
68 | ++ if (priv->modem_online == FALSE) { |
69 | ++ new_state = NM_MODEM_STATE_DISABLED; |
70 | ++ reason = "modem 'Online=false'"; |
71 | ++ } else if (priv->imsi == NULL && state != NM_MODEM_STATE_ENABLING) { |
72 | ++ new_state = NM_MODEM_STATE_DISABLED; |
73 | ++ reason = "modem not ready"; |
74 | ++ } else if (priv->gprs_attached == FALSE) { |
75 | ++ if (state >= NM_MODEM_STATE_ENABLING) { |
76 | ++ new_state = NM_MODEM_STATE_SEARCHING; |
77 | ++ reason = "modem searching"; |
78 | ++ } |
79 | ++ } else { |
80 | ++ new_state = NM_MODEM_STATE_REGISTERED; |
81 | ++ reason = "modem ready"; |
82 | ++ } |
83 | ++ |
84 | ++ if (state != new_state) |
85 | ++ nm_modem_set_state (NM_MODEM (self), new_state, reason); |
86 | ++} |
87 | ++ |
88 | +/* Disconnect stuff */ |
89 | +typedef struct { |
90 | + NMModemOfono *self; |
91 | @@ -415,7 +451,6 @@ |
92 | + SimpleDisconnectContext *ctx = (SimpleDisconnectContext*) user_data; |
93 | + NMModemOfono *self = ctx->self; |
94 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
95 | -+ NMModemState state; |
96 | + GError *error = NULL; |
97 | + |
98 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
99 | @@ -430,15 +465,7 @@ |
100 | + |
101 | + simple_disconnect_context_free (ctx); |
102 | + |
103 | -+ /* No need to re-read contexts in this case... */ |
104 | -+ |
105 | -+ if (priv->modem_online && priv->gprs_powered && priv->gprs_attached) |
106 | -+ state = NM_MODEM_STATE_REGISTERED; |
107 | -+ else |
108 | -+ state = NM_MODEM_STATE_SEARCHING; |
109 | -+ |
110 | -+ nm_modem_set_state (NM_MODEM (self), state, |
111 | -+ nm_modem_state_to_string (state)); |
112 | ++ update_modem_state (self); |
113 | +} |
114 | + |
115 | +static void |
116 | @@ -448,16 +475,20 @@ |
117 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
118 | + SimpleDisconnectContext *ctx; |
119 | + GValue value = G_VALUE_INIT; |
120 | ++ NMModemState state = nm_modem_get_state (NM_MODEM (self)); |
121 | + |
122 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
123 | + |
124 | ++ if (state != NM_MODEM_STATE_CONNECTED) |
125 | ++ return; |
126 | ++ |
127 | + ctx = g_slice_new (SimpleDisconnectContext); |
128 | + ctx->self = g_object_ref (self); |
129 | + ctx->warn = warn; |
130 | + |
131 | + nm_modem_set_state (NM_MODEM (self), |
132 | -+ NM_MODEM_STATE_DISCONNECTING, |
133 | -+ nm_modem_state_to_string (NM_MODEM_STATE_DISCONNECTING)); |
134 | ++ NM_MODEM_STATE_DISCONNECTING, |
135 | ++ nm_modem_state_to_string (NM_MODEM_STATE_DISCONNECTING)); |
136 | + |
137 | + g_value_init (&value, G_TYPE_BOOLEAN); |
138 | + g_value_set_boolean (&value, FALSE); |
139 | @@ -468,7 +499,6 @@ |
140 | + G_TYPE_STRING, "Active", |
141 | + G_TYPE_VALUE, &value, |
142 | + G_TYPE_INVALID); |
143 | -+ |
144 | +} |
145 | + |
146 | +static void |
147 | @@ -494,37 +524,25 @@ |
148 | + |
149 | + return proxy; |
150 | +} |
151 | -+ |
152 | -+static void ofono_read_contexts (NMModemOfono *self); |
153 | -+ |
154 | +static void |
155 | -+update_ofono_enabled (NMModemOfono *self, |
156 | -+ gboolean new_enabled) |
157 | ++handle_attached (NMModemOfono *self, GValue *value) |
158 | +{ |
159 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
160 | -+ NMModemState new_state; |
161 | -+ |
162 | -+ if (new_enabled == priv->enabled) |
163 | -+ return; |
164 | -+ |
165 | -+ if (new_enabled) { |
166 | -+ new_state = NM_MODEM_STATE_REGISTERED; |
167 | -+ ofono_read_contexts (self); |
168 | -+ } else { |
169 | -+ new_state = NM_MODEM_STATE_SEARCHING; |
170 | ++ gboolean attached = g_value_get_boolean (value); |
171 | ++ |
172 | ++ if (priv->gprs_attached != attached) { |
173 | ++ priv->gprs_attached = attached; |
174 | ++ |
175 | ++ nm_log_info (LOGD_MB, "(%s): %s: new value for 'Attached': %s", |
176 | ++ nm_modem_get_path (NM_MODEM (self)), |
177 | ++ __func__, |
178 | ++ attached ? "true" : "false"); |
179 | ++ |
180 | ++ update_modem_state (self); |
181 | + } |
182 | -+ |
183 | -+ nm_modem_set_state (NM_MODEM (self), |
184 | -+ new_state, |
185 | -+ nm_modem_state_to_string (new_state)); |
186 | -+ |
187 | -+ priv->enabled = new_enabled; |
188 | -+ |
189 | -+ nm_log_info (LOGD_MB, "(%s) now in state: %s", |
190 | -+ nm_modem_get_path (NM_MODEM (self)), |
191 | -+ nm_modem_state_to_string(new_state)); |
192 | +} |
193 | + |
194 | ++ |
195 | +static void |
196 | +get_ofono_conn_manager_properties_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) |
197 | +{ |
198 | @@ -537,8 +555,8 @@ |
199 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
200 | + |
201 | + if (!dbus_g_proxy_end_call (proxy, call_id, &error, |
202 | -+ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
203 | -+ G_TYPE_INVALID)) { |
204 | ++ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
205 | ++ G_TYPE_INVALID)) { |
206 | + nm_log_warn (LOGD_MB, "failed get connection manager properties: (%d) %s", |
207 | + error ? error->code : -1, |
208 | + error && error->message ? error->message : "(unknown)"); |
209 | @@ -546,34 +564,13 @@ |
210 | + } |
211 | + |
212 | + value = g_hash_table_lookup (properties, "Attached"); |
213 | -+ if (value) |
214 | -+ priv->gprs_attached = g_value_get_boolean (value); |
215 | -+ else |
216 | -+ nm_log_warn (LOGD_MB, "failed get GPRS state: unexpected reply type"); |
217 | -+ g_value_unset (value); |
218 | -+ |
219 | -+ value = g_hash_table_lookup (properties, "Powered"); |
220 | -+ if (value) |
221 | -+ priv->gprs_powered = g_value_get_boolean (value); |
222 | -+ else |
223 | -+ nm_log_warn (LOGD_MB, "failed get modem enabled state: unexpected reply type"); |
224 | -+ g_value_unset (value); |
225 | -+ |
226 | -+ update_ofono_enabled (self, priv->modem_online |
227 | -+ && priv->gprs_powered |
228 | -+ && priv->gprs_attached); |
229 | -+} |
230 | -+ |
231 | -+static void |
232 | -+get_ofono_conn_manager_properties (NMModemOfono *self) |
233 | -+{ |
234 | -+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
235 | -+ |
236 | -+ dbus_g_proxy_begin_call_with_timeout (priv->connman_proxy, |
237 | -+ "GetProperties", |
238 | -+ get_ofono_conn_manager_properties_done, |
239 | -+ self, NULL, 20000, |
240 | -+ G_TYPE_INVALID); |
241 | ++ if (value) { |
242 | ++ handle_attached (self, value); |
243 | ++ g_value_unset (value); |
244 | ++ } else |
245 | ++ nm_log_warn (LOGD_MB, "(%s): %s: no 'Attached' property found", |
246 | ++ nm_modem_get_path (NM_MODEM (self)), |
247 | ++ __func__); |
248 | +} |
249 | + |
250 | +static void |
251 | @@ -583,21 +580,81 @@ |
252 | + gpointer user_data) |
253 | +{ |
254 | + NMModemOfono *self = NM_MODEM_OFONO (user_data); |
255 | -+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
256 | -+ |
257 | -+ nm_log_dbg (LOGD_MB, "in %s", __func__); |
258 | -+ |
259 | -+ if (g_strcmp0 (key, "Powered") == 0 && G_VALUE_HOLDS_BOOLEAN (value)) { |
260 | -+ priv->gprs_powered = g_value_get_boolean (value); |
261 | -+ } else if (g_strcmp0 (key, "Attached") == 0 && G_VALUE_HOLDS_BOOLEAN (value)) { |
262 | -+ priv->gprs_attached = g_value_get_boolean (value); |
263 | -+ } else |
264 | -+ /* No need to update enabled for other property changes */ |
265 | ++ |
266 | ++ nm_log_dbg (LOGD_MB, "in %s", __func__); |
267 | ++ |
268 | ++ if (g_strcmp0 (key, "Attached") == 0 && G_VALUE_HOLDS_BOOLEAN (value)) |
269 | ++ handle_attached (self, value); |
270 | ++} |
271 | ++ |
272 | ++static void |
273 | ++handle_subscriber_identity(NMModemOfono *self, GValue *value) |
274 | ++{ |
275 | ++ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
276 | ++ const gchar *value_str = g_value_get_string (value); |
277 | ++ |
278 | ++ /* Check for empty DBus string value */ |
279 | ++ if (g_strcmp0 (value_str, "(null)") != 0) { |
280 | ++ |
281 | ++ if (g_strcmp0 (value_str, priv->imsi) != 0) { |
282 | ++ |
283 | ++ if (priv->imsi != NULL) { |
284 | ++ nm_log_warn (LOGD_MB, "SimManager:'SubscriberIdentity' changed: %s", priv->imsi); |
285 | ++ g_free(priv->imsi); |
286 | ++ } |
287 | ++ |
288 | ++ nm_log_info (LOGD_MB, "GetPropsDone: 'SubscriberIdentity': %s", priv->imsi); |
289 | ++ |
290 | ++ priv->imsi = g_strdup (value_str); |
291 | ++ ofono_read_contexts (self); |
292 | ++ update_modem_state (self); |
293 | ++ } |
294 | ++ } |
295 | ++} |
296 | ++ |
297 | ++ |
298 | ++static void |
299 | ++get_ofono_sim_properties_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) |
300 | ++{ |
301 | ++ NMModemOfono *self = NM_MODEM_OFONO (user_data); |
302 | ++ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
303 | ++ NMModemState state = nm_modem_get_state (NM_MODEM (self)); |
304 | ++ GError *error = NULL; |
305 | ++ GHashTable *properties = NULL; |
306 | ++ GValue *value = NULL; |
307 | ++ const gchar *value_str; |
308 | ++ |
309 | ++ nm_log_dbg (LOGD_MB, "in %s", __func__); |
310 | ++ |
311 | ++ if (!dbus_g_proxy_end_call (proxy, call_id, &error, |
312 | ++ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
313 | ++ G_TYPE_INVALID)) { |
314 | ++ nm_log_warn (LOGD_MB, "failed to get ofono SimManager properties: (%d) %s", |
315 | ++ error ? error->code : -1, |
316 | ++ error && error->message ? error->message : "(unknown)"); |
317 | + return; |
318 | -+ |
319 | -+ update_ofono_enabled (self, priv->modem_online |
320 | -+ && priv->gprs_powered |
321 | -+ && priv->gprs_attached); |
322 | ++ } |
323 | ++ |
324 | ++ value = g_hash_table_lookup (properties, "SubscriberIdentity"); |
325 | ++ |
326 | ++ if (value) { |
327 | ++ handle_subscriber_identity (self, value); |
328 | ++ g_value_unset (value); |
329 | ++ } else { |
330 | ++ nm_log_warn (LOGD_MB, "failed to get SimManager:'SubscriberIdentity'; not found"); |
331 | ++ } |
332 | ++} |
333 | ++ |
334 | ++static void |
335 | ++ofono_sim_properties_changed (DBusGProxy *proxy, |
336 | ++ const char *key, |
337 | ++ GValue *value, |
338 | ++ gpointer user_data) |
339 | ++{ |
340 | ++ NMModemOfono *self = NM_MODEM_OFONO (user_data); |
341 | ++ |
342 | ++ if (g_strcmp0 (key, "SubscriberIdentity") == 0 && G_VALUE_HOLDS_STRING (value)) |
343 | ++ handle_subscriber_identity (self, value); |
344 | +} |
345 | + |
346 | +static void |
347 | @@ -625,32 +682,15 @@ |
348 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
349 | + DBusGConnection *bus; |
350 | + DBusGProxy *settings_proxy; |
351 | -+ GHashTable *properties; |
352 | -+ GError *error = NULL; |
353 | -+ const char *imsi; |
354 | + |
355 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
356 | -+ nm_log_info (LOGD_MB, "(%s): trying to read IMSI contexts from oFono files", |
357 | -+ nm_modem_get_path (NM_MODEM (self))); |
358 | ++ |
359 | ++ if (priv->imsi == NULL) { |
360 | ++ nm_log_warn (LOGD_MB, "No 'SubscriberIdentity', so can't read ofono GPRS contexts"); |
361 | ++ return; |
362 | ++ } |
363 | + |
364 | + bus = nm_dbus_manager_get_connection (priv->dbus_mgr); |
365 | -+ |
366 | -+ dbus_g_proxy_call_with_timeout (priv->simmanager_proxy, |
367 | -+ "GetProperties", |
368 | -+ 20000, |
369 | -+ &error, |
370 | -+ G_TYPE_INVALID, |
371 | -+ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
372 | -+ G_TYPE_INVALID); |
373 | -+ |
374 | -+ if (error) { |
375 | -+ nm_log_warn (LOGD_MB, "Could not get SIM properties: %s", |
376 | -+ error && error->message ? error->message : "(unknown)"); |
377 | -+ g_clear_error (&error); |
378 | -+ } |
379 | -+ |
380 | -+ imsi = g_value_get_string (g_hash_table_lookup (properties, "SubscriberIdentity")); |
381 | -+ |
382 | + settings_proxy = dbus_g_proxy_new_for_name (bus, |
383 | + "com.canonical.NMOfono", |
384 | + "/com/canonical/NMOfono", |
385 | @@ -660,7 +700,7 @@ |
386 | + dbus_g_proxy_begin_call_with_timeout (settings_proxy, |
387 | + "ReadImsiContexts", ofono_read_imsi_contexts_done, |
388 | + self, NULL, 20000, |
389 | -+ G_TYPE_STRING, imsi, |
390 | ++ G_TYPE_STRING, priv->imsi, |
391 | + G_TYPE_INVALID); |
392 | + else |
393 | + nm_log_warn (LOGD_MB, "could not get proxy to the oFono Settings plugin."); |
394 | @@ -696,17 +736,23 @@ |
395 | +{ |
396 | + NMModemOfono *self = NM_MODEM_OFONO (user_data); |
397 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
398 | ++ gboolean online; |
399 | + |
400 | + nm_log_dbg (LOGD_MB, "in %s: %s", __func__, key); |
401 | + |
402 | + if (g_strcmp0 (key, "Online") == 0 && G_VALUE_HOLDS_BOOLEAN (value)) { |
403 | -+ priv->modem_online = g_value_get_boolean (value); |
404 | -+ nm_log_info (LOGD_MB, "(%s) modem is now %s", |
405 | -+ nm_modem_get_path (NM_MODEM (self)), |
406 | -+ priv->modem_online ? "Online" : "Offline"); |
407 | -+ update_ofono_enabled (self, priv->modem_online |
408 | -+ && priv->gprs_powered |
409 | -+ && priv->gprs_attached); |
410 | ++ |
411 | ++ online = g_value_get_boolean (value); |
412 | ++ if (online != priv->modem_online) { |
413 | ++ priv->modem_online = online; |
414 | ++ |
415 | ++ nm_log_info (LOGD_MB, "(%s) modem is now %s", |
416 | ++ nm_modem_get_path (NM_MODEM (self)), |
417 | ++ online ? "Online" : "Offline"); |
418 | ++ |
419 | ++ update_modem_state (self); |
420 | ++ } |
421 | ++ |
422 | + } else if (g_strcmp0 (key, "Interfaces") == 0 && G_VALUE_HOLDS_BOXED (value)) { |
423 | + gboolean found_simmanager = FALSE; |
424 | + gboolean found_conn_manager = FALSE; |
425 | @@ -729,26 +775,48 @@ |
426 | + priv->simmanager_proxy = get_ofono_proxy (self, |
427 | + nm_modem_get_path (NM_MODEM (self)), |
428 | + OFONO_DBUS_INTERFACE_SIM_MANAGER); |
429 | ++ dbus_g_proxy_add_signal (priv->simmanager_proxy, "PropertyChanged", |
430 | ++ G_TYPE_STRING, G_TYPE_VALUE, |
431 | ++ G_TYPE_INVALID); |
432 | ++ dbus_g_proxy_connect_signal (priv->simmanager_proxy, "PropertyChanged", |
433 | ++ G_CALLBACK (ofono_sim_properties_changed), |
434 | ++ self, |
435 | ++ NULL); |
436 | ++ |
437 | ++ dbus_g_proxy_begin_call_with_timeout (priv->simmanager_proxy, |
438 | ++ "GetProperties", |
439 | ++ get_ofono_sim_properties_done, |
440 | ++ self, NULL, 20000, |
441 | ++ G_TYPE_INVALID); |
442 | + } |
443 | -+ } else { |
444 | -+ if (priv->simmanager_proxy) { |
445 | ++ } else if (priv->simmanager_proxy) { |
446 | + nm_log_info (LOGD_MB, "(%s): SimManager interface disappeared", |
447 | + nm_modem_get_path (NM_MODEM (self))); |
448 | + g_object_unref (priv->simmanager_proxy); |
449 | + priv->simmanager_proxy = NULL; |
450 | -+ } |
451 | ++ |
452 | ++ g_free (priv->imsi); |
453 | ++ priv->imsi = NULL; |
454 | ++ |
455 | ++ update_modem_state (self); |
456 | + } |
457 | + |
458 | + if (found_conn_manager) { |
459 | + if (!priv->connman_proxy) { |
460 | + nm_log_info (LOGD_MB, "(%s): found new ConnectionManager interface", |
461 | + nm_modem_get_path (NM_MODEM (self))); |
462 | ++ |
463 | + priv->connman_proxy = get_ofono_proxy (self, |
464 | + nm_modem_get_path (NM_MODEM (self)), |
465 | + OFONO_DBUS_INTERFACE_CONNECTION_MANAGER); |
466 | + |
467 | + if (priv->connman_proxy) { |
468 | -+ get_ofono_conn_manager_properties (self); |
469 | ++ |
470 | ++ dbus_g_proxy_begin_call_with_timeout (priv->connman_proxy, |
471 | ++ "GetProperties", |
472 | ++ get_ofono_conn_manager_properties_done, |
473 | ++ self, NULL, 20000, |
474 | ++ G_TYPE_INVALID); |
475 | + |
476 | + dbus_g_proxy_add_signal (priv->connman_proxy, "PropertyChanged", |
477 | + G_TYPE_STRING, G_TYPE_VALUE, |
478 | @@ -774,20 +842,18 @@ |
479 | + NULL); |
480 | + } |
481 | + } |
482 | -+ } else { |
483 | -+ if (priv->connman_proxy) { |
484 | -+ nm_log_info (LOGD_MB, "(%s): ConnectionManager interface disappeared", |
485 | -+ nm_modem_get_path (NM_MODEM (self))); |
486 | -+ g_object_unref (priv->connman_proxy); |
487 | -+ priv->connman_proxy = NULL; |
488 | -+ |
489 | -+ /* The connection manager proxy disappeared, we should |
490 | -+ * consider the modem disabled. |
491 | -+ */ |
492 | -+ update_ofono_enabled (self, FALSE); |
493 | -+ priv->gprs_powered = FALSE; |
494 | -+ priv->gprs_attached = FALSE; |
495 | -+ } |
496 | ++ } else if (priv->connman_proxy) { |
497 | ++ nm_log_info (LOGD_MB, "(%s): ConnectionManager interface disappeared", |
498 | ++ nm_modem_get_path (NM_MODEM (self))); |
499 | ++ g_object_unref (priv->connman_proxy); |
500 | ++ priv->connman_proxy = NULL; |
501 | ++ |
502 | ++ /* The connection manager proxy disappeared, we should |
503 | ++ * consider the modem disabled. |
504 | ++ */ |
505 | ++ priv->gprs_attached = FALSE; |
506 | ++ |
507 | ++ update_modem_state (self); |
508 | + } |
509 | + } |
510 | +} |
511 | @@ -1218,11 +1284,8 @@ |
512 | + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
513 | + NMSettingConnection *s_con; |
514 | + NMSettingGsm *s_gsm; |
515 | -+ GHashTable *properties; |
516 | -+ GError *error = NULL; |
517 | + const char *uuid; |
518 | + const char *id; |
519 | -+ const char *imsi; |
520 | + |
521 | + s_con = nm_connection_get_setting_connection (connection); |
522 | + g_assert (s_con); |
523 | @@ -1244,27 +1307,12 @@ |
524 | + return FALSE; |
525 | + } |
526 | + |
527 | -+ dbus_g_proxy_call_with_timeout (priv->simmanager_proxy, |
528 | -+ "GetProperties", |
529 | -+ 20000, |
530 | -+ &error, |
531 | -+ G_TYPE_INVALID, |
532 | -+ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
533 | -+ G_TYPE_INVALID); |
534 | -+ |
535 | -+ if (error) { |
536 | -+ nm_log_warn (LOGD_MB, "Could not get SIM properties to match connections: %s", |
537 | -+ error && error->message ? error->message : "(unknown)"); |
538 | -+ g_clear_error (&error); |
539 | -+ } |
540 | -+ |
541 | -+ imsi = g_value_get_string (g_hash_table_lookup (properties, "SubscriberIdentity")); |
542 | -+ if (! g_strrstr (id, imsi)) { |
543 | ++ if (! g_strrstr (id, priv->imsi)) { |
544 | + nm_log_dbg (LOGD_MB, "%s (%s) isn't for the right SIM, skipping.", id, uuid); |
545 | + return FALSE; |
546 | + } |
547 | + |
548 | -+ nm_log_dbg (LOGD_MB, "%s (%s) looks compatible with IMSI %s", id, uuid, imsi); |
549 | ++ nm_log_dbg (LOGD_MB, "%s (%s) looks compatible with IMSI %s", id, uuid, priv->imsi); |
550 | + |
551 | + return TRUE; |
552 | +} |
553 | @@ -1280,8 +1328,8 @@ |
554 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
555 | + |
556 | + if (!dbus_g_proxy_end_call (proxy, call_id, &error, |
557 | -+ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
558 | -+ G_TYPE_INVALID)) { |
559 | ++ DBUS_TYPE_G_MAP_OF_VARIANT, &properties, |
560 | ++ G_TYPE_INVALID)) { |
561 | + nm_log_warn (LOGD_MB, "failed get modem enabled state: (%d) %s", |
562 | + error ? error->code : -1, |
563 | + error && error->message ? error->message : "(unknown)"); |
564 | @@ -1314,27 +1362,6 @@ |
565 | +} |
566 | + |
567 | +static void |
568 | -+set_ofono_enabled (NMModem *self, gboolean enabled) |
569 | -+{ |
570 | -+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self); |
571 | -+ |
572 | -+ nm_log_info (LOGD_MB, "(%s): trying to set modem to %s", |
573 | -+ nm_modem_get_path (self), |
574 | -+ enabled ? "enabled" : "disabled"); |
575 | -+ |
576 | -+ /* |
577 | -+ * FIXME: this is code is a no-op; we should either make |
578 | -+ * work, or get rid of this function, or at least remove |
579 | -+ * the call to update_ofono_enabled. |
580 | -+ */ |
581 | -+ |
582 | -+ update_ofono_enabled (NM_MODEM_OFONO (self), |
583 | -+ priv->modem_online |
584 | -+ && priv->gprs_powered |
585 | -+ && priv->gprs_attached); |
586 | -+} |
587 | -+ |
588 | -+static void |
589 | +get_capabilities (NMModem *_self, |
590 | + NMDeviceModemCapabilities *modem_caps, |
591 | + NMDeviceModemCapabilities *current_caps) |
592 | @@ -1361,7 +1388,6 @@ |
593 | + priv->simmanager_proxy = NULL; |
594 | + |
595 | + priv->modem_online = FALSE; |
596 | -+ priv->gprs_powered = FALSE; |
597 | + priv->gprs_attached = FALSE; |
598 | + |
599 | + priv->ip4_config = NULL; |
600 | @@ -1413,18 +1439,25 @@ |
601 | + |
602 | + nm_log_dbg (LOGD_MB, "in %s", __func__); |
603 | + |
604 | -+ if (priv->connect_properties) |
605 | ++ if (priv->connect_properties) { |
606 | + g_hash_table_destroy (priv->connect_properties); |
607 | ++ priv->connect_properties = NULL; |
608 | ++ } |
609 | + |
610 | + if (priv->ip4_config) |
611 | -+ g_object_unref (priv->ip4_config); |
612 | ++ g_clear_object (&priv->ip4_config); |
613 | + |
614 | + if (priv->modem_proxy) |
615 | -+ g_object_unref (priv->modem_proxy); |
616 | ++ g_clear_object (&priv->modem_proxy); |
617 | + if (priv->connman_proxy) |
618 | -+ g_object_unref (priv->connman_proxy); |
619 | ++ g_clear_object (&priv->connman_proxy); |
620 | + if (priv->context_proxy) |
621 | -+ g_object_unref (priv->context_proxy); |
622 | ++ g_clear_object (&priv->context_proxy); |
623 | ++ |
624 | ++ if (priv->imsi) { |
625 | ++ g_free (priv->imsi); |
626 | ++ priv->imsi = NULL; |
627 | ++ } |
628 | + |
629 | + G_OBJECT_CLASS (nm_modem_ofono_parent_class)->dispose (object); |
630 | +} |
631 | @@ -1444,7 +1477,6 @@ |
632 | + object_class->dispose = dispose; |
633 | + |
634 | + modem_class->get_capabilities = get_capabilities; |
635 | -+ modem_class->set_mm_enabled = set_ofono_enabled; |
636 | + modem_class->disconnect = disconnect; |
637 | + modem_class->deactivate = deactivate; |
638 | + modem_class->check_connection_compatible = check_connection_compatible; |
639 | |
640 | === added file 'debian/patches/lp1445080-modify-device-modem-avail.patch' |
641 | --- debian/patches/lp1445080-modify-device-modem-avail.patch 1970-01-01 00:00:00 +0000 |
642 | +++ debian/patches/lp1445080-modify-device-modem-avail.patch 2015-07-17 20:04:14 +0000 |
643 | @@ -0,0 +1,44 @@ |
644 | +Author: Tony Espy <espy@canonical.com> |
645 | +Subject: Modify NMDeviceModem's available logic |
646 | + |
647 | +This patch modifies NMDeviceModem's available logic such that |
648 | +the device is only considered available if the modem_state is |
649 | +>= NM_MODEM_STATE_REGISTERED. NMDevice defines 'available' as |
650 | +meaning the device is in such a state that it can be activated. |
651 | +This change prevents NM from trying to activate a modem which |
652 | +is not yet ready to be activated. |
653 | + |
654 | +Bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1445080 |
655 | + |
656 | +Index: network-manager-0.9.10.0/src/devices/wwan/nm-device-modem.c |
657 | +=================================================================== |
658 | +--- network-manager-0.9.10.0.orig/src/devices/wwan/nm-device-modem.c |
659 | ++++ network-manager-0.9.10.0/src/devices/wwan/nm-device-modem.c |
660 | +@@ -340,8 +340,6 @@ check_connection_available (NMDevice *de |
661 | + return FALSE; |
662 | + |
663 | + state = nm_modem_get_state (priv->modem); |
664 | +- if (state <= NM_MODEM_STATE_INITIALIZING) |
665 | +- return FALSE; |
666 | + |
667 | + if (state == NM_MODEM_STATE_LOCKED) { |
668 | + NMSettingGsm *s_gsm = nm_connection_get_setting_gsm (connection); |
669 | +@@ -351,6 +349,9 @@ check_connection_available (NMDevice *de |
670 | + return FALSE; |
671 | + } |
672 | + |
673 | ++ if (state <= NM_MODEM_STATE_SEARCHING) |
674 | ++ return FALSE; |
675 | ++ |
676 | + return TRUE; |
677 | + } |
678 | + |
679 | +@@ -475,7 +476,7 @@ is_available (NMDevice *dev) |
680 | + |
681 | + g_assert (priv->modem); |
682 | + modem_state = nm_modem_get_state (priv->modem); |
683 | +- if (modem_state <= NM_MODEM_STATE_INITIALIZING) { |
684 | ++ if (modem_state <= NM_MODEM_STATE_SEARCHING) { |
685 | + nm_log_dbg (LOGD_MB, "(%s): not available because modem is not ready (%s)", |
686 | + nm_device_get_iface (dev), |
687 | + nm_modem_state_to_string (modem_state)); |
688 | |
689 | === added file 'debian/patches/lp1445080-nm-modem-check-for-set-mm-enabled-func.patch' |
690 | --- debian/patches/lp1445080-nm-modem-check-for-set-mm-enabled-func.patch 1970-01-01 00:00:00 +0000 |
691 | +++ debian/patches/lp1445080-nm-modem-check-for-set-mm-enabled-func.patch 2015-07-17 20:04:14 +0000 |
692 | @@ -0,0 +1,28 @@ |
693 | +Author: Tony Espy <espy@canonical.com> |
694 | +Subject: NMModem: check for child class' set_mm_enabled func before calling |
695 | + |
696 | +This patch add a check to NMModem's set_mm_enabled function |
697 | +to check that a sub-class defines the function before calling |
698 | +it. Some modem implementation, such as NMModemOfono, don't |
699 | +define a set_mm_enabled function, as this control of ofono's |
700 | +modem 'Online' property is handled externally by urfkill. |
701 | + |
702 | +Bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1445080 |
703 | + |
704 | +--- |
705 | + |
706 | +Index: network-manager-0.9.10.0/src/devices/wwan/nm-modem.c |
707 | +=================================================================== |
708 | +--- network-manager-0.9.10.0.orig/src/devices/wwan/nm-modem.c |
709 | ++++ network-manager-0.9.10.0/src/devices/wwan/nm-modem.c |
710 | +@@ -203,7 +203,9 @@ nm_modem_set_mm_enabled (NMModem *self, |
711 | + return; |
712 | + } |
713 | + |
714 | +- NM_MODEM_GET_CLASS (self)->set_mm_enabled (self, enabled); |
715 | ++ /* Not all modem classes support set_mm_enabled */ |
716 | ++ if (NM_MODEM_GET_CLASS (self)->set_mm_enabled) |
717 | ++ NM_MODEM_GET_CLASS (self)->set_mm_enabled (self, enabled); |
718 | + |
719 | + /* Pre-empt the state change signal */ |
720 | + nm_modem_set_state (self, |
721 | |
722 | === modified file 'debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch' |
723 | --- debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch 2015-07-17 20:04:13 +0000 |
724 | +++ debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch 2015-07-17 20:04:14 +0000 |
725 | @@ -10,10 +10,10 @@ |
726 | |
727 | --- |
728 | |
729 | -Index: b/src/nm-policy.c |
730 | +Index: network-manager-0.9.10.0/src/nm-policy.c |
731 | =================================================================== |
732 | ---- a/src/nm-policy.c |
733 | -+++ b/src/nm-policy.c |
734 | +--- network-manager-0.9.10.0.orig/src/nm-policy.c |
735 | ++++ network-manager-0.9.10.0/src/nm-policy.c |
736 | @@ -1229,7 +1229,7 @@ sleeping_changed (NMManager *manager, GP |
737 | } |
738 | |
739 | @@ -83,8 +83,8 @@ |
740 | + nm_log_info (LOGD_DEVICE, "Connection '%s' disconnected, scheduling activate_check in %u seconds.", |
741 | + nm_connection_get_id (NM_CONNECTION (connection)), delay); |
742 | + else |
743 | -+ nm_log_info (LOGD_DEVICE, "Device has no connection; scheduling activate_check in %u seconds.", |
744 | -+ delay); |
745 | ++ nm_log_info (LOGD_DEVICE, "Device '%s' has no connection; scheduling activate_check in %u seconds.", |
746 | ++ nm_device_get_iface (device), delay); |
747 | + |
748 | + schedule_activate_check (policy, device, delay); |
749 | break; |
750 | |
751 | === modified file 'debian/patches/series' |
752 | --- debian/patches/series 2015-07-17 20:04:13 +0000 |
753 | +++ debian/patches/series 2015-07-17 20:04:14 +0000 |
754 | @@ -66,6 +66,8 @@ |
755 | lp1461593-add-nm-settings-connection-reset-retries-methods.patch |
756 | add_ofono_settings_support.patch |
757 | lp1461593-add-modem-reconnect-delay-to-policy.patch |
758 | +lp1445080-modify-device-modem-avail.patch |
759 | +lp1445080-nm-modem-check-for-set-mm-enabled-func.patch |
760 | |
761 | # killswitch |
762 | ignore_rfkill_if_urfkill_is_present.patch |
Have the code bits been discussed with upstream? What is the likely impact on non-ofono modems of the changes to nm_device_modem to not return that connections are unavailable when the modem is still in NM_MODEM_ STATE_INITIALIZ ING state, for example?
As per the other patches, I think the ofono code changes should be merged in to the main patch for the modem support (since we're at a development release, this makes it just one large patch to fixup when there is a need to refresh the patch, rather than conflicting, interdepending change sets), and any core changes should be in a separate, isolated patch so that we can send them upstream ASAP.
Since I don't know whether there has been careful testing of the impact of the NMDeviceModem changes on non-ofono modem -> Needs Information.