Send the system event into bt-core process 92/89992/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 28 Sep 2016 04:18:20 +0000 (13:18 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 28 Sep 2016 04:18:20 +0000 (13:18 +0900)
Change-Id: I7729e062ff477d6fe3331db798bb69c898bc18cd
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-core/bt-core-adapter.c
bt-core/bt-core-dbus-handler.c
bt-core/include/bt-core-adapter.h
bt-service/bt-service-common.c

index 3db0fa4..5a82fe5 100644 (file)
@@ -38,6 +38,8 @@ static gboolean is_recovery_mode = FALSE;
 static int bt_status_before[BT_MODE_MAX] = { VCONFKEY_BT_STATUS_OFF, };
 static int bt_le_status_before[BT_MODE_MAX] = { VCONFKEY_BT_LE_STATUS_OFF, };
 
+static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value);
+
 static void __bt_core_set_status(bt_status_t status)
 {
        adapter_status = status;
@@ -614,6 +616,30 @@ gboolean _bt_core_enable_core(void)
        return TRUE;
 }
 
+gboolean _bt_core_set_transfer_value(gboolean value)
+{
+       const char *event_val = NULL;
+       gboolean ret = TRUE;
+
+       BT_DBG("value: %d", value);
+
+       event_val = value ? EVT_VAL_BT_TRANSFERING : EVT_VAL_BT_NON_TRANSFERING;
+
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_TRANSFERING_STATE,
+                                               event_val) != ES_R_OK) {
+               BT_ERR("Fail to set BT state value");
+               ret = FALSE;
+       }
+
+       if (ret == FALSE || value == FALSE) {
+               BT_DBG("Terminate bt-core process");
+               g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
+       }
+
+       BT_DBG("-");
+       return ret;
+}
+
 gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
 {
 
@@ -819,6 +845,15 @@ void _bt_core_adapter_added_cb(void)
                return;
        }
        _bt_set_flightmode_request(FALSE);
+
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
+                                               EVT_VAL_BT_ON) != ES_R_OK)
+               BT_ERR("Fail to set BT state value");
+
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
+                                               EVT_VAL_BT_LE_ON) != ES_R_OK)
+               BT_ERR("Fail to set BT LE state value");
+
        _bt_core_terminate();
 }
 
index 6894cbc..1cc475f 100755 (executable)
@@ -324,6 +324,9 @@ static const gchar bt_core_introspection_xml[] =
 "     </method>"
 "     <method name='EnableCore'>"
 "     </method>"
+"        <method name='SetTransferValue'>"
+"          <arg type='b' name='value' direction='in'/>"
+"        </method>"
 "     <method name='FactoryTestMode'>"
 "          <arg type='s' name='type' direction='in'/>"
 "          <arg type='s' name='arg' direction='in'/>"
@@ -361,6 +364,13 @@ static void __bt_core_dbus_method(GDBusConnection *connection,
                ret = _bt_core_disable_adapter_le();
        } else if (g_strcmp0(method_name, "EnableCore") == 0) {
                ret = _bt_core_enable_core();
+       } else if (g_strcmp0(method_name, "SetTransferValue") == 0) {
+               gboolean value = FALSE;
+
+               g_variant_get(parameters, "(b)", &value);
+               BT_DBG("Transfer value: %d", value);
+
+               ret = _bt_core_set_transfer_value(value);
        } else if (g_strcmp0(method_name, "FactoryTestMode") == 0) {
                const char *type = NULL;
                const char *arg = NULL;
index 54091ad..f56d8eb 100755 (executable)
@@ -83,6 +83,7 @@ gboolean _bt_core_enable_adapter_le(void);
 gboolean _bt_core_disable_adapter_le(void);
 gboolean __bt_core_reset_adapter(void);
 gboolean _bt_core_enable_core(void);
+gboolean _bt_core_set_transfer_value(gboolean value);
 gboolean _bt_core_factory_test_mode(const char *type, const char *arg);
 
 void _bt_core_update_status(void);
index 48710a0..346d630 100644 (file)
@@ -870,7 +870,9 @@ int _bt_byte_arr_cmp_with_mask(const char *data1, const char *data2,
 
 int _bt_eventsystem_set_value(const char *event, const char *key, const char *value)
 {
-       int ret;
+       int ret = ES_R_OK;
+/* Send event system event in bt-core process because bt-service's permission is not system in now */
+\r#if 0
        bundle *b = NULL;
 
        b = bundle_create();
@@ -882,7 +884,7 @@ int _bt_eventsystem_set_value(const char *event, const char *key, const char *va
        BT_DBG("eventsystem_send_system_event result: %d", ret);
 
        bundle_free(b);
-
+#endif
        return ret;
 }