Fix that the device is not added while detecting devices.
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 5 Dec 2019 09:22:22 +0000 (18:22 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 5 Dec 2019 10:28:09 +0000 (19:28 +0900)
- Problem: If adding a device while detecting the device, the first device
  detection callback is not called.
- Cause: If the broadcast MAC is used as a source filed in APR Request packet,
  can't distinguish ARP Response whether the device detected or the device added.
- Solution: Modified the device is not added while detecting devices.

Change-Id: Iad779411cecc89869b1aa77522cefd22e7106ecb
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/ua-manager.spec
ua-daemon/src/pm/ua-cloud-plugin-handler.c
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/ua-manager-db.c

index 14d5bdef55ed38d05608e3858c06eded6280d2c2..53d8877f5ad362333e0152f91a95054e29f133ff 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.13
+Version:    0.13.14
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index d4bf9a842c7ec5eef64599dd9c0b212ae44a3076..e65f0dfafb13b7da7ffa9222ea5a28d72b019c78 100644 (file)
@@ -98,6 +98,7 @@ static int remove_user(const char *account)
 static int add_device(const char *account, uap_device_info_t *dev_info)
 {
        FUNC_ENTRY;
+       int ret;
        uam_device_info_s device;
        uam_user_info_s user;
 
@@ -115,13 +116,12 @@ static int add_device(const char *account, uap_device_info_t *dev_info)
        memset(&device, 0x00, sizeof(uam_device_info_s));
        __uap_to_uam_device_info(&device, dev_info);
 
-       if (UAM_ERROR_NONE != _uam_core_add_device(account, &device)) {
+       ret = _uam_core_add_device(account, &device);
+       if (UAM_ERROR_NONE != ret)
                UAM_ERR("_uam_core_remove_user() failed");
-               return UAP_STATUS_FAIL;
-       }
 
        FUNC_EXIT;
-       return UAP_STATUS_SUCCESS;
+       return ret;
 }
 
 static int remove_device(const char *device_id, int type)
index c5ae741a00efacc536ca4611321378d5b9e4a437..78e3c5d7f5399ab900bfccea653927a49f90785e 100644 (file)
@@ -305,6 +305,28 @@ static void __uas_device_list_free(int count, uas_device_info_t *devices)
        FUNC_EXIT;
 }
 
+static int __get_uas_error_code(int error)
+{
+       switch (error) {
+       case UAS_STATUS_SUCCESS: /* 0x00 */
+               return UAM_ERROR_NONE;
+       case UAS_STATUS_FAIL: /* 0x01 */
+               return UAM_ERROR_INTERNAL;
+       case UAS_STATUS_NOT_READY: /* 0x02 */
+               return UAM_ERROR_NOT_INITIALIZED;
+       case UAS_STATUS_NOMEM: /* 0x03 */
+               return UAM_ERROR_OUT_OF_MEMORY;
+       case UAS_STATUS_BUSY: /* 0x04 */
+               return UAM_ERROR_RESOURCE_BUSY;
+       case UAS_STATUS_ALREADY_DONE: /* 0x05 */
+               return UAM_ERROR_ALREADY_DONE;
+       case UAS_STATUS_UNSUPPORTED: /* 0x06 */
+               return UAM_ERROR_NOT_SUPPORTED;
+       default:
+               return UAM_ERROR_INTERNAL;
+       }
+}
+
 static uas_device_info_t *__get_uas_device_list(int id, GSList *devices, int *num_devices)
 {
        FUNC_ENTRY;
@@ -399,7 +421,9 @@ gboolean _uam_pm_is_sensor_ready(unsigned int sensor_bitmask)
 int _uam_pm_register_device(int user_id, const uam_device_info_s *dev)
 {
        FUNC_ENTRY;
+
        int id;
+       int ret = UAM_ERROR_NONE;
        uam_sensor_plugin_info_t *plugin;
        uas_device_info_t *device = NULL;
 
@@ -416,14 +440,16 @@ int _uam_pm_register_device(int user_id, const uam_device_info_s *dev)
        retv_if(NULL == device, UAM_ERROR_INTERNAL);
 
        device->user_id = user_id;
-       if (UAS_STATUS_SUCCESS != plugin->api->add_device(device)) {
+
+       ret = plugin->api->add_device(device);
+       if (UAS_STATUS_SUCCESS != ret) {
                UAM_ERR("plugin->add_device() failed");
-               return UAM_ERROR_INTERNAL;
        }
+
        _pm_util_uas_device_info_free(device);
 
        FUNC_EXIT;
-       return UAM_ERROR_NONE;
+       return __get_uas_error_code(ret);
 }
 
 int _uam_pm_unregister_device(int user_id, const uam_device_info_s *dev)
index 4f709dad747f16c838c298d4f657b1f6f9152aa5..3431f20fa5bfa392729b05a56871ffdbb771998a 100644 (file)
@@ -54,7 +54,7 @@
        "duid TEXT, " \
        "device_icon TEXT, " \
        "FOREIGN KEY(user_id) REFERENCES userdata(user_id), " \
-       "UNIQUE (device_id, tech_type, address) " \
+       "UNIQUE (device_id, tech_type) " \
        "); "
 
 #define CREATE_SERVICES_TABLE "CREATE TABLE IF NOT EXISTS services ( " \