From 9e9cf7a8800d634a5e04b0396f209cdefdb34e98 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 15 Oct 2012 15:35:23 +0300 Subject: [PATCH] technology: Fix hardblocked state on non hw rfkillable switch added If hardblock is on and a new device is inserted and detected as not hardblocked, then it will be possible to enable/disable it (soft rfkill) independently to the main hw rfkill switch. --- src/technology.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/technology.c b/src/technology.c index 976964a..290ec24 100644 --- a/src/technology.c +++ b/src/technology.c @@ -1340,7 +1340,8 @@ void __connman_technology_set_connected(enum connman_service_type type, static connman_bool_t technology_apply_rfkill_change(struct connman_technology *technology, connman_bool_t softblock, - connman_bool_t hardblock) + connman_bool_t hardblock, + connman_bool_t new_rfkill) { gboolean hardblock_changed = FALSE; gboolean apply = TRUE; @@ -1353,18 +1354,21 @@ static connman_bool_t technology_apply_rfkill_change(struct connman_technology * if (technology->hardblocked == hardblock) goto softblock_change; - start = g_hash_table_get_values(rfkill_list); - for (list = start; list != NULL; list = list->next) { - struct connman_rfkill *rfkill = list->data; + if (!(new_rfkill == TRUE && hardblock == FALSE)) { + start = g_hash_table_get_values(rfkill_list); - if (rfkill->type != technology->type) - continue; + for (list = start; list != NULL; list = list->next) { + struct connman_rfkill *rfkill = list->data; - if (rfkill->hardblock != hardblock) - apply = FALSE; - } + if (rfkill->type != technology->type) + continue; - g_list_free(start); + if (rfkill->hardblock != hardblock) + apply = FALSE; + } + + g_list_free(start); + } if (apply == FALSE) goto softblock_change; @@ -1438,7 +1442,7 @@ done: /* If hardblocked, there is no need to handle softblocked state */ if (technology_apply_rfkill_change(technology, - softblock, hardblock) == TRUE) + softblock, hardblock, TRUE) == TRUE) return 0; /* @@ -1485,7 +1489,7 @@ int __connman_technology_update_rfkill(unsigned int index, /* If hardblocked, there is no need to handle softblocked state */ if (technology_apply_rfkill_change(technology, - softblock, hardblock) == TRUE) + softblock, hardblock, FALSE) == TRUE) return 0; if (global_offlinemode == TRUE) @@ -1524,7 +1528,7 @@ int __connman_technology_remove_rfkill(unsigned int index, return -ENXIO; technology_apply_rfkill_change(technology, - technology->softblocked, !technology->hardblocked); + technology->softblocked, !technology->hardblocked, FALSE); technology_put(technology); -- 2.7.4