netreg: Ignore operator info when not registered
authorDenis Kenzior <denkenz@gmail.com>
Mon, 7 Jun 2010 16:22:13 +0000 (11:22 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 7 Jun 2010 17:57:46 +0000 (12:57 -0500)
Sometimes when we roam off the cell or are simply not registered, the
modem still reports a bogus operator.  We explicitly ignore this
condition in the core.

src/network.c

index 87a73e3..1692e40 100644 (file)
@@ -1220,6 +1220,15 @@ static void current_operator_callback(const struct ofono_error *error,
 
        DBG("%p, %p", netreg, netreg->current_operator);
 
+       /*
+        * Sometimes we try to query COPS right when we roam off the cell,
+        * in which case the operator information frequently comes in bogus.
+        * We ignore it here
+        */
+       if (netreg->status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
+                       netreg->status != NETWORK_REGISTRATION_STATUS_ROAMING)
+               current = NULL;
+
        if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
                DBG("Error during current operator");
                return;