Fix the problem that the SF and UAF use different data format
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 21 Oct 2019 12:00:23 +0000 (21:00 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Wed, 23 Oct 2019 00:32:11 +0000 (09:32 +0900)
- Problem: The data format of timestamp is not different from the sensor
  framework.
- Cause: The UAF uses 32 bit timestamp but the sensor framework uses 64
  bit timestamp.
- Solution: Change timestamps in UAF with 64-bit unsigned long long.

Change-Id: I174627c17a17e5f59c2f9c04ed78f81b12ff0ebe
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
include/user-awareness-private.h
include/user-awareness.h [changed mode: 0644->0755]
packaging/capi-network-ua.spec
src/user-awareness-device.c
src/user-awareness-event-handler.c
src/user-awareness-users.c
src/user-awareness-util.c
test/uat-detections.c
test/uat-devices.c
test/uat-init.c
test/uat-users.c

index 7e6478e5e855b0fe5410cd593ccda45cf2cf0f8c..0a507f583fa3bb662010f0941a0f42f963f88d96 100644 (file)
@@ -202,12 +202,12 @@ typedef struct {
  */
 typedef struct {
        unsigned  int status; /**< Sensor status 1:PRESENCE 2:ABSENCE */
-       ua_sensor_h handle;
-       ua_sensor_e bitmask;
-       long int timestamp;
-       int accuracy;
-       int count;
-       double *values;
+       ua_sensor_h handle; /**< Sensor handle */
+       ua_sensor_e bitmask; /**< Sensor bitmask */
+       unsigned long long timestamp; /**< Timestamp */
+       int accuracy; /**< Accuracty from sensor device */
+       int count; /**< How many sensor data included */
+       double *values; /**< Sensor data */
 } ua_sensor_info_s;
 
 /**
@@ -304,7 +304,7 @@ typedef struct {
        gboolean isadded; /**< Is the device addition completed? */
        gboolean create_by_app; /**< Did app add this device information? */
        gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
-       long last_presence_timestamp; /**< timestamp of last presence */
+       unsigned long long last_presence_timestamp; /**< timestamp of last presence */
        ua_ble_payload_s *payload; /**< BLE payload to filter device*/
 } ua_dev_info_s;
 
old mode 100644 (file)
new mode 100755 (executable)
index 839f7d8..53bd1ad
@@ -1489,7 +1489,7 @@ int ua_user_get_name(
  * @post
  *
  */
-int ua_user_get_last_presence(ua_user_h user_handle, long *timestamp);
+int ua_user_get_last_presence(ua_user_h user_handle, unsigned long long *timestamp);
 
 /**
  * @ingroup CAPI_NETWORK_UA_MODULE
@@ -2432,7 +2432,7 @@ int ua_device_get_wifi_ipv4_address(
  */
 int ua_device_get_last_presence(
                ua_device_h device_handle,
-               long *timestamp);
+               unsigned long long *timestamp);
 
 /**
  * @ingroup CAPI_NETWORK_UA_MODULE
@@ -2893,7 +2893,7 @@ int ua_device_foreach_added_by_user(
  */
 int ua_sensor_get_timestamp(
                ua_sensor_h sensor_handle,
-               long int *timestamp);
+               unsigned long long *timestamp);
 
 /**
  * @ingroup CAPI_NETWORK_UA_MODULE
index 5e4cc8df8b2d84f140c09ef8843bddd50337f8e5..8d926e513d815b46de381c0231a9cdc3a7a0fb4c 100644 (file)
@@ -1,6 +1,6 @@
 Name: capi-network-ua
 Summary: User Awareness Framework CAPI
-Version: 0.12.0
+Version: 0.12.1
 Release: 1
 License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
index 7b71a130ed9e3bf9da76f8145867257347b4c802..2bc930833e7e2c865875714e43dafe6b0a0fcbf0 100644 (file)
@@ -920,7 +920,7 @@ int ua_device_get_discriminant(
 
 int ua_device_get_last_presence(
                ua_device_h device_handle,
-               long *timestamp)
+               unsigned long long *timestamp)
 {
        FUNC_ENTRY;
        ua_dev_info_s *device = (ua_dev_info_s *)device_handle;
index 3223f1d3693780a6c63103a4c07d73499f047a6d..1c0f3a53ac935f8505dd3bdc8b10be14dd4f464b 100644 (file)
@@ -91,7 +91,7 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param,
                sensor_info = event_param->data;
                ret_if(NULL == sensor_info);
 
-               UA_INFO("sensor: [%u], timestamp [%ld], accuracy [%d], value [%f]",
+               UA_INFO("sensor: [%u], timestamp [%llu], accuracy [%d], value [%f]",
                                sensor_info->sensor_bitmask, sensor_info->timestamp,
                                sensor_info->accuracy, sensor_info->values[0]);
                _ua_monitor_handle_user_presence_detected(sensor_info, NULL,
@@ -105,7 +105,7 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param,
                sensor_info = event_param->data;
                ret_if(NULL == sensor_info);
 
-               UA_INFO("sensor: [%u], timestamp [%ld], accuracy [%d], value [%f]",
+               UA_INFO("sensor: [%u], timestamp [%llu], accuracy [%d], value [%f]",
                                sensor_info->sensor_bitmask, sensor_info->timestamp,
                                sensor_info->accuracy, sensor_info->values[0]);
                _ua_monitor_handle_user_absence_detected(sensor_info, NULL, NULL);
@@ -118,7 +118,7 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param,
                sensor_info = event_param->data;
                ret_if(NULL == sensor_info);
 
-               UA_INFO("status [%d] sensor: [%u], timestamp [%ld], accuracy [%d], value [%f]",
+               UA_INFO("status [%d] sensor: [%u], timestamp [%llu], accuracy [%d], value [%f]",
                                sensor_info->status, sensor_info->sensor_bitmask, sensor_info->timestamp,
                                sensor_info->accuracy, sensor_info->values[0]);
 
index 057fefa90f89aa0d212f1f89a9a0fac9eee953aa..4a5a98e7ddb550df038baed4336258fc08c89bb9 100644 (file)
@@ -668,7 +668,7 @@ int ua_user_get_name(
        return UA_ERROR_NONE;
 }
 
-int ua_user_get_last_presence(ua_user_h user_handle, long *timestamp)
+int ua_user_get_last_presence(ua_user_h user_handle, unsigned long long *timestamp)
 {
        FUNC_ENTRY;
        ua_user_info_s *user = (ua_user_info_s *)user_handle;
index d066063e24c03b8657f130d88237d2d5d0080236..40dc102d4760ecbee63a9fcd29a6a826af3e5777 100644 (file)
@@ -362,7 +362,7 @@ GSList *ua_sensor_get_sensor_handle_list(
 
 int ua_sensor_get_timestamp(
                ua_sensor_h sensor_handle,
-               long int *timestamp)
+               unsigned long long *timestamp)
 {
        FUNC_ENTRY;
        ua_sensor_info_s *sensor;
index ce0476c3186579016e9c4517105cc4c0745e6c83..b0b24b316ac2b287dcde4fce92aceb2903a42b2d 100644 (file)
@@ -79,7 +79,7 @@ static void __sensor_presence_detected_sensor_info(ua_sensor_e sensor,
        int ret;
        char buf[MENU_DATA_SIZE] = {0, };
        char final_buf[MENU_DATA_SIZE * 4] = {0, };
-       long int timestamp;
+       unsigned long long timestamp;
        int info_count = 0;
        GSList *values = NULL;
        double *value;
@@ -108,7 +108,7 @@ static void __sensor_presence_detected_sensor_info(ua_sensor_e sensor,
                strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
                memset(buf, 0, MENU_DATA_SIZE);
        }
-       msgb("[%s] information detected at timestamp [%ld] value [%s]",
+       msgb("[%s] information detected at timestamp [%llu] value [%s]",
                uat_get_sensor_bitmask_str(sensor), timestamp,
                        final_buf);
 
index 6b71985ec2529fe8bfbaecccf93b558889f2ef78..75e4087140f60f2bff1dc8d6c952ec4f8703b9d1 100644 (file)
@@ -157,7 +157,7 @@ static bool __foreach_added_device_cb(
        char *wifi_bssid = NULL;
        char *ipv4 = NULL;
        bool required = false;
-       long timestamp = 0;
+       unsigned long long timestamp = 0;
        bool discriminant = false;
        char service_id = 0;
        char device_icon = 0;
@@ -218,7 +218,7 @@ static bool __foreach_added_device_cb(
 
                        ret_temp = ua_device_get_last_presence(handle, &timestamp);
                        if (UA_ERROR_NONE == ret_temp)
-                               msgb("Last present at : %ld", timestamp);
+                               msgb("Last present at : %llu", timestamp);
 
                        ret_temp = ua_device_get_payload_service_id(handle, &service_id);
                        if (UA_ERROR_NONE == ret_temp)
@@ -259,7 +259,7 @@ static bool __service_foreach_added_device_cb(
        char *ipv4 = NULL;
        bool required = false;
        bool discriminant = false;
-       long timestamp = 0;
+       unsigned long long timestamp = 0;
        char service_id = 0;
        char device_icon = 0;
        char purpose = 0;
@@ -322,7 +322,7 @@ static bool __service_foreach_added_device_cb(
 
                        ret_temp = ua_device_get_last_presence(handle, &timestamp);
                        if (UA_ERROR_NONE == ret_temp)
-                               msgb("Last present at : %ld", timestamp);
+                               msgb("Last present at : %llu", timestamp);
 
                        ret_temp = ua_device_get_payload_service_id(handle, &service_id);
                        if (UA_ERROR_NONE == ret_temp)
index 10a0fad7022d006260b5b9e2df22ba97ac5489d1..508168bc99d0eb17555f860d30843ed13f6c44c2 100644 (file)
@@ -44,7 +44,7 @@ static void __user_detected_foreach_sensors(gpointer data,
        int ret;
        char buf[MENU_DATA_SIZE] = {0, };
        char final_buf[MENU_DATA_SIZE * 4] = {0, };
-       long int timestamp;
+       unsigned long long timestamp;
        int info_count = 0;
        GSList *values = NULL;
        double *value;
@@ -81,7 +81,7 @@ static void __user_detected_foreach_sensors(gpointer data,
                strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
                memset(buf, 0, MENU_DATA_SIZE);
        }
-       msgb("[%s] information detected at timestamp [%ld] value [%s]",
+       msgb("[%s] information detected at timestamp [%llu] value [%s]",
                uat_get_sensor_bitmask_str(bitmask), timestamp,
                        final_buf);
 
@@ -199,7 +199,7 @@ static void __sensor_status_changed_cb(ua_sensor_status_e status,
        int ret;
        double *value;
        GSList *l = 0;
-       long int timestamp;
+       unsigned long long timestamp;
        int info_count = 0;
        ua_sensor_e sensor;
        GSList *values = NULL;
@@ -240,7 +240,7 @@ static void __sensor_status_changed_cb(ua_sensor_status_e status,
                strncat(final_buf, buf, sizeof(buf) - strlen(buf) - 1);
                memset(buf, 0, MENU_DATA_SIZE);
        }
-       msgr("[%s] information detected at timestamp [%ld] value [%s]",
+       msgr("[%s] information detected at timestamp [%llu] value [%s]",
                uat_get_sensor_bitmask_str(sensor), timestamp, final_buf);
 
        g_slist_free(values);
index fbd7df2130b07ceb2577e9fffd1274e40dc62377..5e821572def706609ff48e1a2fbaf12df4e4af1b 100644 (file)
@@ -89,7 +89,7 @@ static bool __foreach_registered_user_cb(
 
        char *account = NULL;
        char *name = NULL;
-       long timestamp = 0;
+       unsigned long long timestamp = 0;
 
        if (user_handle) {
 
@@ -111,7 +111,7 @@ static bool __foreach_registered_user_cb(
 
                ret = ua_user_get_last_presence(user_handle, &timestamp);
                if (UA_ERROR_NONE == ret)
-                       msgb("last present at %ld", timestamp);
+                       msgb("last present at %llu", timestamp);
        }
 
        return true;