Include bt_onoff tool in capi-network-bluetooth-test rpm 77/219177/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 3 Dec 2019 01:35:16 +0000 (10:35 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 3 Dec 2019 01:35:16 +0000 (10:35 +0900)
Change-Id: I7181a75c22d7ae9a5a7104b8a3e25553ab87f931
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
packaging/capi-network-bluetooth.spec
test/CMakeLists.txt
test/bt_onoff.c

index 2e37b83..60b1984 100644 (file)
@@ -119,7 +119,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
 %files test
 %manifest %{name}.manifest
 %{_bindir}/bt_unit_test
-#%{_bindir}/bt_onoff
+%{_bindir}/bt_onoff
 #/etc/smack/accesses.d/capi-network-bluetooth-test.efl
 
 %files devel
index bb1758f..00c90eb 100644 (file)
@@ -17,4 +17,4 @@ FOREACH(src ${sources})
 ENDFOREACH()
 
 INSTALL(TARGETS bt_unit_test DESTINATION bin)
-#INSTALL(TARGETS bt_onoff DESTINATION bin)
+INSTALL(TARGETS bt_onoff DESTINATION bin)
index 28c7c89..038bc5f 100644 (file)
 
 GMainLoop *main_loop = NULL;
 static guint onoff_timer = 0;
+static int cnt = 0;
+
+static gboolean __bt_onoff_timeout_cb(gpointer data);
+
+static void __bt_retry_onoff(bt_adapter_state_e state)
+{
+       int ret;
+
+       cnt++;
+
+       TC_PRT("Retry cnt: %d", cnt);
+
+       onoff_timer = g_timeout_add(20000, (GSourceFunc)__bt_onoff_timeout_cb, NULL);
+
+       if (state == BT_ADAPTER_DISABLED)
+               ret = bt_adapter_enable();
+       else
+               ret = bt_adapter_disable();
+
+       TC_PRT("bt_adapter_%s() error(%d)",
+       state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret);
+}
 
 static void __bt_adapter_state_changed_cb(int result,
        bt_adapter_state_e adapter_state, void *user_data)
@@ -45,10 +67,7 @@ static void __bt_adapter_state_changed_cb(int result,
                execv("all_log_dump.sh", argv);
        }
 
-       if (main_loop)
-               g_main_loop_quit(main_loop);
-       else
-               exit(0);
+       __bt_retry_onoff(adapter_state);
 }
 
 static gboolean __bt_onoff_timeout_cb(gpointer data)
@@ -92,13 +111,14 @@ int main(int argc, char *argv[])
                NULL);
 
        if (argc <= 1) {
-               if (state == BT_ADAPTER_DISABLED)
+               if (state == BT_ADAPTER_DISABLED) {
                        ret = bt_adapter_enable();
                else
                        ret = bt_adapter_disable();
+
                TC_PRT("bt_adapter_%s() error(%d)",
-                       state == BT_ADAPTER_DISABLED ? "enable" : "disable",
-                       ret);
+               state == BT_ADAPTER_DISABLED ? "enable" : "disable", ret);
+               }
        } else {
                if (argv[1][0] == '0') {
                        if (state == BT_ADAPTER_DISABLED) {