From: Anjali Nijhara Date: Fri, 23 Dec 2022 10:05:59 +0000 (+0530) Subject: Add Signal Handling for Module State Changed X-Git-Tag: accepted/tizen/unified/20230315.093508^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0dd362c77c9e0cd35fa86012ceba2c3a67cd1bbb;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Add Signal Handling for Module State Changed Change-Id: I4ef16436285425ca8bf920cd9c9f8ac542bc48c9 --- diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 55baacf..94f76f1 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -233,6 +233,7 @@ chown network_fw:network_fw /opt/usr/data/network %attr(500,network_fw,network_fw) %{_bindir}/net-config %attr(644,network_fw,network_fw) %{_sysconfdir}/resolv.conf %attr(644,network_fw,network_fw) %{TZ_SYS_ETC}/resolv.conf +%attr(644,root,root) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules %attr(644,root,root) %{_datadir}/dbus-1/system-services/* #DBus DAC %attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/* diff --git a/resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules b/resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules index e374072..6b1adc3 100755 --- a/resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules +++ b/resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules @@ -1,6 +1,6 @@ # Udev Rules for WiFi Chip attach/detach Events - -ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 1 -f" -ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 0 -f" - +ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/vconftool set -t string memory/wifi/device/ifname $name -f" +ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 1 -f" +ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/vconftool set -t string memory/wifi/device/ifname $name -f" +ACTION=="remove", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/vconftool set -t int memory/wifi/device/status_uevent 0 -f" diff --git a/src/wifi-power.c b/src/wifi-power.c index 8c39985..6437f9d 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -50,6 +50,10 @@ #define VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT "db/setting/network_with_lcd_off_limit" #endif +#define NETCONFIG_SIGNAL_MODULE_STATE_CHANGED "ModuleStateChanged" +#define VCONFKEY_WIFI_DEVICE_STATUS_UEVENT "memory/wifi/device/status_uevent" +#define VCONFKEY_WIFI_INTERFACE_NAME "memory/wifi/device/ifname" + #define WLAN_MAC_ADDR_MAX 20 #define ETH_MAC_ADDR_SIZE 6 #define NET_EXEC_PATH "/sbin/ifconfig" @@ -354,6 +358,38 @@ static void __netconfig_wifi_restrict_mode(keynode_t *node, void *user_data) } #endif +static void __netconfig_emit_wifi_module_state_signal(int wifi_module_state) +{ + GVariant *sig_params; + char *interface_name = NULL; + + interface_name = vconf_get_str(VCONFKEY_WIFI_INTERFACE_NAME); + + DBG("wifi module state [%d]", wifi_module_state); + + GVariantBuilder *module_state_info = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(module_state_info, "{sv}", "ifname", g_variant_new_string(interface_name)); + g_variant_builder_add(module_state_info, "{sv}", "status_uevent", g_variant_new_uint32(wifi_module_state)); + sig_params = g_variant_new("(@a{sv})", g_variant_builder_end(module_state_info)); + g_variant_builder_unref(module_state_info); + netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH, + NETCONFIG_WIFI_INTERFACE, NETCONFIG_SIGNAL_MODULE_STATE_CHANGED, sig_params); + + g_free(interface_name); +} + +static void __netconfig_wifi_module_state_changed_cb(keynode_t *node, void *data) +{ + int wifi_module_state = 0; + + if (node != NULL) + wifi_module_state = vconf_keynode_get_int(node); + else + netconfig_vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &wifi_module_state); + + __netconfig_emit_wifi_module_state_signal(wifi_module_state); +} + static void __netconfig_wifi_airplane_mode(keynode_t *node, void *user_data) { int wifi_state = 0, airplane_state = 0; @@ -800,6 +836,7 @@ void wifi_power_initialize(void) vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, __emergency_mode_changed_cb, NULL); vconf_notify_key_changed(VCONFKEY_PM_STATE, __pm_state_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, __netconfig_wifi_module_state_changed_cb, NULL); } void wifi_power_deinitialize(void)