[TV Profile]: Add new CAPI to get WiFi Module State 58/131858/10
authorManeesh Jain <maneesh.jain@samsung.com>
Wed, 31 May 2017 05:42:01 +0000 (11:12 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Thu, 22 Jun 2017 04:53:22 +0000 (10:23 +0530)
Description: Added support of following to get the Wi-Fi
Module state. (Attached or Detached)
    1./ wifi_manager_get_module_state()

This CAPI may useful only for TV Profile case where user can insert or
remove the Wi-Fi Module.

Change-Id: Ia18b8a1e4a7b1ce25739a03ca32d0c4b83eb79e3
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
include/wifi-manager.h
include/wifi_internal.h
src/wifi_internal.c
src/wifi_manager.c
test/wifi_manager_test.c

index 900c51f15b9c49022dbeb6238578f8486bec5501..5576b8df383a4f78a8f16c5066118ac24cba4e28 100755 (executable)
@@ -231,6 +231,15 @@ typedef enum {
        WIFI_MANAGER_TDLS_DISCOVERY_STATE_FINISHED = 1,   /**< Discovery is finished */
 } wifi_manager_tdls_discovery_state_e;
 
+/**
+ * @brief Enumeration for the Wi-Fi Module state.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       WIFI_MANAGER_MODULE_STATE_DETACHED = 0,  /**< Wi-Fi Module is detached */
+       WIFI_MANAGER_MODULE_STATE_ATTACHED = 1,  /**< Wi-Fi Module is attached */
+} wifi_manager_module_state_e;
+
 /**
 * @}
 */
@@ -1532,6 +1541,19 @@ int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
  */
 int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi);
 
+/**
+ * @brief Gets the Wi-Fi Module state.
+ * @since_tizen 4.0
+ * @param[in] wifi            The Wi-Fi handle
+ * @param[out] state          The Wi-Fi Module state
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION    Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED     Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_get_module_state(wifi_manager_h wifi, wifi_manager_module_state_e *state);
 
 /**
 * @}
@@ -1620,6 +1642,7 @@ int wifi_manager_ap_clone(wifi_manager_ap_h *cloned_ap, wifi_manager_ap_h origin
  */
 int wifi_manager_ap_refresh(wifi_manager_ap_h ap);
 
+
 /**
 * @}
 */
index c4fd23e21e2eae277b33c7af1e3b70d024490216..e0baa4c26b9b5195e856457b3d9a8c0bfcb558f1 100755 (executable)
@@ -62,6 +62,8 @@ typedef enum {
        WIFI_SUPPORTED_FEATURE_MAX,
 } wifi_supported_feature_e;
 
+/* It is specific to TV Profile that WiFi Module can be insert or remove in platform */
+#define VCONFKEY_WIFI_DEVICE_STATUS_UEVENT "memory/wifi/device/status_uevent"
 
 #define CHECK_FEATURE_SUPPORTED(...) \
        do { \
@@ -249,6 +251,7 @@ int _wifi_set_autoscan(bool autoscan);
 int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode);
 int _wifi_get_autoscan(bool *autoscan);
 int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode);
+int _wifi_get_module_state(wifi_manager_module_state_e *state);
 
 
 
index 83910c68608571fc022575f495ee7340c636ed59..30ba76ffe5ce0f8981f5c6f9bdabc52bb31276a5 100755 (executable)
@@ -1898,9 +1898,8 @@ int _wifi_load_configurations(void)
                gchar *id = config_ids->data;
 
                h = g_new0(wifi_config_s, 1);
-               if (h == NULL) {
+               if (h == NULL)
                        break;
-               }
 
                if (g_str_has_suffix(id, "ieee8021x") == TRUE) {
                        h->eap_config = g_new0(wifi_eap_config_s, 1);
@@ -2209,4 +2208,29 @@ int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode)
 
        return WIFI_MANAGER_ERROR_NONE;
 }
+
+int _wifi_get_module_state(wifi_manager_module_state_e *state)
+{
+       int rv = 0;
+       int wifi_device_status = 0;
+
+       rv = vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &wifi_device_status);
+
+       if (rv < 0) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get vconf value [%s]\n",
+                                               VCONFKEY_WIFI_DEVICE_STATUS_UEVENT);
+               return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+       }
+
+       if (wifi_device_status == 0) {
+               WIFI_LOG(WIFI_INFO, "Wi-Fi Module is detached");
+               *state = WIFI_MANAGER_MODULE_STATE_DETACHED;
+       } else {
+               WIFI_LOG(WIFI_INFO, "Wi-Fi Module is attached");
+               *state = WIFI_MANAGER_MODULE_STATE_ATTACHED;
+       }
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
 //LCOV_EXCL_STOP
index 0157e958a91687a2bc1d2ca751ff4eeda426f974..43069c6804b97b3e585ccb5cd6aa335bbf5cfc9b 100755 (executable)
@@ -846,3 +846,18 @@ EXPORT_API int wifi_manager_get_autoscan_mode(wifi_manager_h wifi,
 }
 //LCOV_EXCL_STOP
 
+EXPORT_API int wifi_manager_get_module_state(wifi_manager_h wifi,
+                                       wifi_manager_module_state_e *state)
+
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (state == NULL || !(__wifi_check_handle_validity(wifi))) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       return _wifi_get_module_state(state);
+
+}
+
index 2f6201b5a9d8022da013da2c876985a32714368c..9c6a281b62966b4fab08b9bf11bdc6558972f35b 100755 (executable)
@@ -1955,6 +1955,33 @@ int test_wifi_manager_tdls_disable_channel_switch(void)
        }
        return 1;
 }
+int test_wifi_manager_get_module_state(void)
+{
+       int rv = 0;
+       wifi_manager_module_state_e module_state;
+
+       rv = wifi_manager_get_module_state(wifi, &module_state);
+
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("Fail to get wifi module state [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+
+       printf("Success to get WiFI Module state : ");
+       switch (module_state) {
+       case WIFI_MANAGER_MODULE_STATE_ATTACHED:
+               printf("Wi-Fi Module Attached \n");
+               break;
+       case WIFI_MANAGER_MODULE_STATE_DETACHED:
+               printf("Wi-Fi Module Detached\n");
+               break;
+       default:
+               printf("Unknown\n");
+       }
+
+       return 1;
+}
+
 
 int test_wifi_manager_connect_hidden_ap(void)
 {
@@ -2242,6 +2269,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("A   - Get Auto Scan Mode\n");
                printf("B   - Enable TDLS Channel Switch Request\n");
                printf("C   - Disable TDLS Channel Switch Request\n");
+               printf("D   - Get Wi-Fi Module State\\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
@@ -2364,6 +2392,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'C':
                rv = test_wifi_manager_tdls_disable_channel_switch();
                break;
+       case 'D':
+               rv = test_wifi_manager_get_module_state();
+               break;
        default:
                break;
        }