Add signal handling for P2P Tethering 97/304697/1
authorAnjali Nijhara <a.nijhara@samsung.com>
Tue, 23 Jan 2024 08:21:24 +0000 (13:51 +0530)
committerAnjali Nijhara <a.nijhara@samsung.com>
Tue, 23 Jan 2024 08:22:09 +0000 (13:52 +0530)
Change-Id: Iac6541785d78a223d5640fd2a88f0e3e932de71c
Signed-off-by: Anjali Nijhara <a.nijhara@samsung.com>
include/tethering_private.h
src/tethering.c
tools/tethering_test.c

index 882edf1..b6a36c2 100644 (file)
@@ -194,6 +194,8 @@ typedef enum {
        E_SIGNAL_NET_CLOSED = 0,
        E_SIGNAL_WIFI_TETHER_ON,
        E_SIGNAL_WIFI_TETHER_OFF,
+       E_SIGNAL_P2P_TETHER_ON,
+       E_SIGNAL_P2P_TETHER_OFF,
        E_SIGNAL_USB_TETHER_ON,
        E_SIGNAL_USB_TETHER_OFF,
        E_SIGNAL_BT_TETHER_ON,
@@ -220,6 +222,8 @@ typedef enum {
 #define SIGNAL_NAME_STA_DISCONNECT     "sta_disconnected"
 #define SIGNAL_NAME_WIFI_TETHER_ON     "wifi_on"
 #define SIGNAL_NAME_WIFI_TETHER_OFF    "wifi_off"
+#define SIGNAL_NAME_P2P_TETHER_ON   "p2p_on"
+#define SIGNAL_NAME_P2P_TETHER_OFF  "p2p_off"
 #define SIGNAL_NAME_USB_TETHER_ON      "usb_on"
 #define SIGNAL_NAME_USB_TETHER_OFF     "usb_off"
 #define SIGNAL_NAME_BT_TETHER_ON       "bluetooth_on"
index acca9ae..55fc98a 100755 (executable)
@@ -78,6 +78,14 @@ static void __handle_wifi_tether_off(GDBusConnection *connection, const gchar *s
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data);
 
+static void __handle_p2p_tether_on(GDBusConnection *connection, const gchar *sender_name,
+               const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data);
+
+static void __handle_p2p_tether_off(GDBusConnection *connection, const gchar *sender_name,
+               const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
+               GVariant *parameters, gpointer user_data);
+
 static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data);
@@ -130,6 +138,8 @@ static __tethering_sig_t sigs[] = {
        {0, SIGNAL_NAME_NET_CLOSED, __handle_net_closed},
        {0, SIGNAL_NAME_WIFI_TETHER_ON, __handle_wifi_tether_on},
        {0, SIGNAL_NAME_WIFI_TETHER_OFF, __handle_wifi_tether_off},
+       {0, SIGNAL_NAME_P2P_TETHER_ON, __handle_p2p_tether_on},
+       {0, SIGNAL_NAME_P2P_TETHER_OFF, __handle_p2p_tether_off},
        {0, SIGNAL_NAME_USB_TETHER_ON, __handle_usb_tether_on},
        {0, SIGNAL_NAME_USB_TETHER_OFF, __handle_usb_tether_off},
        {0, SIGNAL_NAME_BT_TETHER_ON, __handle_bt_tether_on},
@@ -566,6 +576,28 @@ static void __handle_wifi_tether_off(GDBusConnection *connection, const gchar *s
        DBG("-\n");
 }
 
+static void __handle_p2p_tether_on(GDBusConnection *connection, const gchar *sender_name,
+                       const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
+                       GVariant *parameters, gpointer user_data)
+{
+       DBG("+\n");
+       TETHERING_LOCK;
+       __invoke_enable_cb((__tethering_h *)user_data, TETHERING_TYPE_P2P, false);
+       TETHERING_UNLOCK;
+       DBG("-\n");
+}
+
+static void __handle_p2p_tether_off(GDBusConnection *connection, const gchar *sender_name,
+                       const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
+                       GVariant *parameters, gpointer user_data)
+{
+       DBG("+\n");
+       TETHERING_LOCK;
+       __invoke_disabled_cb((__tethering_h *)user_data, TETHERING_TYPE_P2P, parameters);
+       TETHERING_UNLOCK;
+       DBG("-\n");
+}
+
 static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                        GVariant *parameters, gpointer user_data)
index 6a01a38..1f5ed94 100755 (executable)
@@ -751,7 +751,7 @@ static int test_tethering_enable(void)
        if (!__get_tethering_type(&type))
                return -1;
 
-       if (type != TETHERING_TYPE_WIFI)
+       if (type != TETHERING_TYPE_WIFI && type != TETHERING_TYPE_P2P)
                return -1;
 
        printf("Select 0: Normal, 1: Wi-Fi sharing, 2: Dual band hotspot\n");