From 6124022ab38222d1b9a239b3f21ec6c8a6eced0f Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Thu, 20 Sep 2012 08:41:30 -0700 Subject: [PATCH] modem-helpers: handle the case when operator name is "Unknown" Some modems report "Unknown" as the operator name when failed to obtain the actual value: --> 'AT+COPS=3,0;+COPS?' <-- '+COPS: 0,0,"Unknown",0OK' This patch prevents "Unknown" from being treated as a valid operator name. --- src/mm-modem-helpers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index db0bfbdf..6692b6fd 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1468,7 +1468,15 @@ mm_3gpp_parse_operator (const gchar *reply, */ if (!g_utf8_validate (operator, -1, NULL)) { g_free (operator); - operator = NULL; + return NULL; + } + + /* Some modems (Novatel LTE) return the operator name as "Unknown" when + * it fails to obtain the operator name. Return NULL in such case. + */ + if (g_ascii_strcasecmp (operator, "unknown") == 0) { + g_free (operator); + return NULL; } }