Toggle offline mode only if device enablement succeeds
[platform/upstream/connman.git] / src / device.c
index fc72544..aab0c83 100644 (file)
@@ -1056,16 +1056,22 @@ int __connman_device_enable(struct connman_device *device)
 
 int __connman_device_enable_persistent(struct connman_device *device)
 {
+       int err;
+
        DBG("device %p", device);
 
        device->powered_persistent = TRUE;
 
-       if (__connman_profile_get_offlinemode() == TRUE)
-               __connman_profile_set_offlinemode(FALSE, FALSE);
-
        __connman_storage_save_device(device);
 
-       return __connman_device_enable(device);
+       err = __connman_device_enable(device);
+       if (err == 0 || err == -EINPROGRESS) {
+               if (__connman_profile_get_offlinemode() == TRUE)
+                       __connman_profile_set_offlinemode(FALSE, FALSE);
+
+       }
+
+       return err;
 }
 
 int __connman_device_disable(struct connman_device *device)