From 1e0ef892f6fe3c2fe779d5f6a6fb88bfee699963 Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Tue, 21 Jul 2020 13:04:58 +0530 Subject: [PATCH] Add txpower argument in enable_wifi_tethering and reload_wifi_settings method call Change-Id: I841bd8c12782c7095a65d17efd526c8b230c515e Signed-off-by: Nishant Chaprana --- include/mobileap_notification.h | 6 ++++++ include/mobileap_softap.h | 1 + include/mobileap_wifi.h | 14 ++++++++------ include/tethering-dbus-interface.xml | 2 ++ packaging/mobileap-agent.spec | 2 +- src/mobileap_notification.c | 10 +++++----- src/mobileap_wifi.c | 25 ++++++++++++++++++------- unittest/unittest.cpp | 24 ++++++++++++------------ 8 files changed, 53 insertions(+), 31 deletions(-) diff --git a/include/mobileap_notification.h b/include/mobileap_notification.h index d9e1811..414df8d 100644 --- a/include/mobileap_notification.h +++ b/include/mobileap_notification.h @@ -37,4 +37,10 @@ struct notification_handler_t { extern struct notification_handler_t notification_handler; void _init_notification_handler(void); void _deinit_notification_handler(void); + +int _create_timeout_noti(mobile_ap_type_e type); +int _create_connected_noti(mobile_ap_type_e type, int count); +int _update_connected_noti(mobile_ap_type_e type, int count); +int _delete_connected_noti(void); +void _create_security_restriction_noti(mobile_ap_type_e type); #endif diff --git a/include/mobileap_softap.h b/include/mobileap_softap.h index 67e9148..cfbe1e7 100755 --- a/include/mobileap_softap.h +++ b/include/mobileap_softap.h @@ -296,6 +296,7 @@ typedef struct { mobile_ap_address_type_e address_type; uint32_t ip_addr; + int txpower; } softap_settings_t; typedef struct { diff --git a/include/mobileap_wifi.h b/include/mobileap_wifi.h index 0104181..5a9f3f0 100644 --- a/include/mobileap_wifi.h +++ b/include/mobileap_wifi.h @@ -54,9 +54,10 @@ gboolean _is_trying_wifi_operation(void); mobile_ap_error_code_e _reload_softap_settings(Tethering *obj, softap_settings_t *settings); gboolean tethering_enable_wifi_tethering(Tethering *obj, - GDBusMethodInvocation *context, - gchar *ssid, gchar *key, gchar* mode, gint channel, gint visibility, - gint mac_filter, gint max_sta, gint security_type, gint address_type); + GDBusMethodInvocation *context, gchar *ssid, + gchar *key, gchar *mode, gint channel, gint visibility, + gint mac_filter, gint max_sta, gint security_type, + gint txpower, gint address_type); /* Soft AP */ softap_settings_t *_get_softap_settings(); @@ -71,9 +72,10 @@ gboolean tethering_disable_wifi_tethering(Tethering *obj, GDBusMethodInvocation *context, gint address_type); gboolean tethering_reload_wifi_settings(Tethering *obj, - GDBusMethodInvocation *context, - gchar *ssid, gchar *key, gchar* mode, gint channel, gint visibility, - gint mac_filter, gint max_sta, gint security_type); + GDBusMethodInvocation *context, gchar *ssid, + gchar *key, gchar *mode, gint channel, gint visibility, + gint mac_filter, gint max_sta, gint security_type, + gint txpower); gboolean tethering_get_wifi_tethering_passphrase(Tethering *obj, GDBusMethodInvocation *context); diff --git a/include/tethering-dbus-interface.xml b/include/tethering-dbus-interface.xml index c041bb2..b79a08a 100755 --- a/include/tethering-dbus-interface.xml +++ b/include/tethering-dbus-interface.xml @@ -23,6 +23,7 @@ + @@ -94,6 +95,7 @@ + diff --git a/packaging/mobileap-agent.spec b/packaging/mobileap-agent.spec index 9977402..e9c3cf3 100644 --- a/packaging/mobileap-agent.spec +++ b/packaging/mobileap-agent.spec @@ -1,6 +1,6 @@ Name: mobileap-agent Summary: Mobile AP daemon for setting tethering environments -Version: 1.0.136 +Version: 1.0.137 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/mobileap_notification.c b/src/mobileap_notification.c index 416eda8..1138974 100644 --- a/src/mobileap_notification.c +++ b/src/mobileap_notification.c @@ -85,7 +85,7 @@ static int __create_status_noti(const char *content) return MOBILE_AP_ERROR_NONE; } -static int _create_timeout_noti(mobile_ap_type_e type) +int _create_timeout_noti(mobile_ap_type_e type) { DBG("+\n"); @@ -279,7 +279,7 @@ static int _delete_timeout_noti(void) return MOBILE_AP_ERROR_NONE; } -static int _create_connected_noti(mobile_ap_type_e type, int count) +int _create_connected_noti(mobile_ap_type_e type, int count) { DBG("+\n"); notification_h noti = NULL; @@ -409,7 +409,7 @@ FAIL: return MOBILE_AP_ERROR_INTERNAL; } -static int _update_connected_noti(mobile_ap_type_e type, int count) +int _update_connected_noti(mobile_ap_type_e type, int count) { DBG("+\n"); @@ -472,7 +472,7 @@ FAIL: return MOBILE_AP_ERROR_INTERNAL; } -static int _delete_connected_noti(void) +int _delete_connected_noti(void) { DBG("+\n"); notification_h noti = NULL; @@ -525,7 +525,7 @@ static void _create_tethering_active_noti(void) return; } -static void _create_security_restriction_noti(mobile_ap_type_e type) +void _create_security_restriction_noti(mobile_ap_type_e type) { bundle *b = NULL; char restricted_type[MAX_BUF_SIZE] = {0, }; diff --git a/src/mobileap_wifi.c b/src/mobileap_wifi.c index 5dcb232..72db253 100755 --- a/src/mobileap_wifi.c +++ b/src/mobileap_wifi.c @@ -54,9 +54,9 @@ static GDBusMethodInvocation *g_context = NULL; static guint wifi_recovery_timeout_id = 0; static gboolean prev_wifi_on = FALSE; static gboolean is_softap = FALSE; -static softap_settings_t wifi_settings = {"", "", "", "", 0, 0, 0, 0, 0, 0, 0}; -static softap_settings_t wifi_ap_settings = {"", "", "", "", 0, 0, 0, MOBILE_AP_MAX_WIFI_STA, 0, 0, 0}; -static softap_settings_t obj_softap_settings = {"", "", "", "", 0, 0, 0, 0, 0, 0, 0}; +static softap_settings_t wifi_settings = {"", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0}; +static softap_settings_t wifi_ap_settings = {"", "", "", "", 0, 0, 0, MOBILE_AP_MAX_WIFI_STA, 0, 0, 0, 0}; +static softap_settings_t obj_softap_settings = {"", "", "", "", 0, 0, 0, 0, 0, 0, 0, 0}; static wifi_manager_h wifi_manager = NULL; @@ -406,9 +406,10 @@ static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *dst, s dst->max_sta = src->max_sta; dst->address_type = src->address_type; dst->ip_addr = src->ip_addr; + dst->txpower = src->txpower; - SDBG("ssid : %s security type : %d ip address: 0x%X hide mode : %d mac filter : %d max_sta: %d hw_mode: %s vendor: %s \n", - dst->ssid, dst->security_type, dst->ip_addr, dst->hide_mode, dst->mac_filter, dst->max_sta, dst->mode, dst->vendor_elements); + SDBG("ssid : %s security type : %d ip address: 0x%X hide mode : %d mac filter : %d max_sta: %d hw_mode: %s vendor: %s txpower: %d\n", + dst->ssid, dst->security_type, dst->ip_addr, dst->hide_mode, dst->mac_filter, dst->max_sta, dst->mode, dst->vendor_elements, dst->txpower); return MOBILE_AP_ERROR_NONE; } @@ -445,6 +446,9 @@ static gboolean __is_equal_softap_settings(softap_settings_t *a, softap_settings if (a->ip_addr != b->ip_addr) return FALSE; + if (a->txpower != b->txpower) + return FALSE; + return TRUE; } @@ -903,7 +907,9 @@ mobile_ap_error_code_e _reload_softap_settings_for_softap(Softap *obj, softap_se gboolean tethering_enable_wifi_tethering(Tethering *obj, GDBusMethodInvocation *context, gchar *ssid, - gchar *key, gchar *mode, gint channel, gint visibility, gint mac_filter, gint max_sta, gint security_type, gint address_type) + gchar *key, gchar *mode, gint channel, gint visibility, + gint mac_filter, gint max_sta, gint security_type, + gint txpower, gint address_type) { DBG("+\n"); mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE; @@ -953,6 +959,7 @@ gboolean tethering_enable_wifi_tethering(Tethering *obj, wifi_settings.mac_filter = mac_filter; wifi_settings.max_sta = max_sta; wifi_settings.address_type = address_type; + wifi_settings.txpower = txpower; if (wifi_recovery_timeout_id) { DBG("Wi-Fi recovery is cancelled\n"); //LCOV_EXCL_LINE @@ -1028,7 +1035,9 @@ gboolean tethering_disable_wifi_tethering(Tethering *obj, gboolean tethering_reload_wifi_settings(Tethering *obj, GDBusMethodInvocation *context, gchar *ssid, - gchar *key, gchar *mode, gint channel, gint visibility, gint mac_filter, gint max_sta, gint security_type) + gchar *key, gchar *mode, gint channel, gint visibility, + gint mac_filter, gint max_sta, gint security_type, + gint txpower) { mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE; softap_settings_t settings = {0, }; @@ -1061,6 +1070,8 @@ gboolean tethering_reload_wifi_settings(Tethering *obj, g_strlcpy(settings.vendor_elements, "", sizeof(settings.vendor_elements)); + settings.txpower = txpower; + ret = _reload_softap_settings(obj, &settings); if (ret != MOBILE_AP_ERROR_NONE) ERR("_reload_softap_settings is failed\n"); //LCOV_EXCL_LINE diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index 302ffc8..c4acc4f 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -202,10 +202,10 @@ TEST_F(MobileAP, mobileap_agent_test_p2p_set_ssid_p) { } TEST_F(MobileAP, mobileap_agent_test_usb_tethering_enable_disable_p) { - int ret = tethering_enable_usb_tethering(obj, NULL); + int ret = tethering_enable_usb_tethering(obj, NULL, MOBILE_AP_ADDRESS_TYPE_IPV4); EXPECT_EQ(ret, TRUE); - ret = tethering_disable_usb_tethering(obj, NULL); + ret = tethering_disable_usb_tethering(obj, NULL, MOBILE_AP_ADDRESS_TYPE_IPV4); EXPECT_EQ(ret, TRUE); } @@ -213,15 +213,15 @@ TEST_F(MobileAP, mobileap_agent_test_enable_disable_wifi_tethering_n) { int ret = 0; /* SSID Length: 0 */ - ret = tethering_enable_wifi_tethering(obj, NULL, "", "password", "g", 6, 1, 0, 10, 1, 0); + ret = tethering_enable_wifi_tethering(obj, NULL, "", "password", "g", 6, 1, 0, 10, 1, 0, 100); EXPECT_EQ(ret, FALSE); /* Security Type: WPA2_PSK, Password Length: 0 */ - ret = tethering_enable_wifi_tethering(obj, NULL, "test", "", "g", 6, 1, 0, 10, 1, 0); + ret = tethering_enable_wifi_tethering(obj, NULL, "test", "", "g", 6, 1, 0, 10, 1, 0, 100); EXPECT_EQ(ret, FALSE); /* Invalid address type */ - ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 3); + ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 3, 100); EXPECT_EQ(ret, FALSE); ret = tethering_disable_wifi_tethering(obj, NULL, MOBILE_AP_ADDRESS_TYPE_IPV4); @@ -229,11 +229,11 @@ TEST_F(MobileAP, mobileap_agent_test_enable_disable_wifi_tethering_n) { } TEST_F(MobileAP, mobileap_agent_test_enable_reload_disable_wifi_tethering_p) { - int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0); + int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0, 100); run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); - ret = tethering_reload_wifi_settings(obj, NULL, "test", "password", "g", 11, 1, 0, 10, 1); + ret = tethering_reload_wifi_settings(obj, NULL, "test", "password", "g", 11, 1, 0, 10, 1, 100); run_gmain_loop(3000); EXPECT_EQ(ret, TRUE); @@ -243,7 +243,7 @@ TEST_F(MobileAP, mobileap_agent_test_enable_reload_disable_wifi_tethering_p) { } TEST_F(MobileAP, mobileap_agent_test_get_data_packet_usage_p) { - int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0); + int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0, 100); run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); @@ -269,7 +269,7 @@ TEST_F(MobileAP, mobileap_agent_test_set_get_wifi_tethering_passphrase_p) { } TEST_F(MobileAP, mobileap_agent_test_set_mtu_p) { - int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0); + int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0, 100); run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); @@ -301,7 +301,7 @@ TEST_F(MobileAP, mobileap_agent_test_enable_port_filtering_p) { } TEST_F(MobileAP, mobileap_agent_test_wps_p) { - int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0); + int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 0, 100); run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); @@ -317,7 +317,7 @@ TEST_F(MobileAP, mobileap_agent_test_wps_p) { } TEST_F(MobileAP, mobileap_agent_test_enable_disable_wifi_ipv6_tethering_p) { - int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 1); + int ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 1, 100); run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); @@ -528,7 +528,7 @@ TEST_F(MobileAP, mobileap_agent_test_disable_all_tethering_p) { run_gmain_loop(2000); EXPECT_EQ(ret, TRUE); - ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 1); + ret = tethering_enable_wifi_tethering(obj, NULL, "test", "password", "g", 6, 1, 0, 10, 1, 1, 100); run_gmain_loop(4000); EXPECT_EQ(ret, TRUE); -- 2.7.4