- Problem: real-time timestamp causes various problems.
- Cause: If the time zone is changed or the system time is initialized,
the wrong timestamp may be generated.
- Solution:
1. Change to use the monotonic timer when creating a timestamp.
2. Add new plugin API that enables the BLE plugin can save real-time
timestamp.
Change-Id: I2508ecdb15977f6278fb2eeec89dc5caba77537f
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
Name: ua-manager
Summary: User awareness manager
-Version: 0.12.19
+Version: 0.13.0
Release: 1
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
void _uam_core_handle_status_changed(unsigned int sensor, void *info);
-void __send_sensor_absence_event(uam_sensor_info_s *sensor_info, unsigned int sensor);
-
#ifdef __cplusplus
}
#endif
unsigned long long timestamp);
/* update */
-int _uam_device_db_update_device_timestamp(
+int _uam_device_db_update_device_lastseen(
char *device_id, int tech_type, char *address, unsigned long long timestamp);
int _uam_device_db_update_device_presence(
char *device_id, int tech_type, char *address, int presence_state);
FUNC_EXIT;
}
-void ble_device_update_timestamp_callback(
- unsigned long long timestamp, uas_device_info_t *device)
-{
- FUNC_ENTRY;
-
- int ret;
- uam_device_info_s *dev_info;
-
- ret_if(NULL == device);
-
- dev_info = _pm_util_uas_dev_info_to_uam_dev_info(device);
- ret_if(NULL == dev_info);
-
- dev_info->type = UAM_TECH_TYPE_BLE;
-
- ret = __uam_db_begin_transaction();
- if (UAM_ERROR_NONE != ret) {
- UAM_WARN("_uam_device_db_update_device_timestamp failed");
- g_free(dev_info);
- return;
- }
-
- /* Update database (presence state & timestamp) */
- ret = _uam_device_db_update_device_timestamp(dev_info->device_id,
- dev_info->type, dev_info->mac, timestamp);
-
- if (UAM_ERROR_NONE != ret) {
- UAM_WARN("_uam_device_db_update_device_timestamp failed");
- __uam_db_end_transaction(0);
- }
-
- __uam_db_end_transaction(1);
- g_free(dev_info);
-
- FUNC_EXIT;
-}
-
uas_callbacks_t ble_cbs = {
.state_changed_cb = ble_state_changed_callback,
.detection_state_cb = ble_detection_state_changed_cb,
.device_detected_cb = ble_device_detection_callback,
.device_added_cb = ble_device_added_callback,
.device_active_scan_cb = NULL,
- .device_update_timestamp_cb = ble_device_update_timestamp_callback
};
.device_detected_cb = NULL,
.device_added_cb = NULL,
.device_active_scan_cb = NULL,
- .device_update_timestamp_cb = NULL
};
.device_detected_cb = NULL,
.device_added_cb = NULL,
.device_active_scan_cb = NULL,
- .device_update_timestamp_cb = NULL
};
device->operating_system = dev->os;
device->discriminant = dev->discriminant;
+ device->last_seen = dev->last_seen;
g_strlcpy(device->device_id, dev->device_id, UAM_DEVICE_ID_MAX_STRING_LEN);
memset(device->payload.duid, 0, UAM_BLE_PAYLOAD_DUID_LEN + 1);
.device_detected_cb = wifi_device_detection_callback,
.device_added_cb = wifi_device_added_callback,
.device_active_scan_cb = wifi_active_scan_callback,
- .device_update_timestamp_cb = NULL
};
* limitations under the License.
*
*/
-
+#include <error.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "ua-api.h"
{
int ret;
struct timespec t;
+
ret = clock_gettime(CLOCK_MONOTONIC, &t);
if (-1 == ret) {
- UAM_ERR("Failed to call clock_gettime [%d]", ret);
+ UAM_ERR("Failed to call clock_gettime [%d]", errno);
return 0;
}
- return ((unsigned long long)(t.tv_sec)*1000000000LL + t.tv_nsec) / 1000;
-}
+ return ((unsigned long long)(t.tv_sec) * 1000000000LL + t.tv_nsec) / 1000000;
+}
\ No newline at end of file
int ret = UAM_ERROR_NONE;
GSList *svc_list = NULL;
uam_db_user_info_t *user = NULL;
- unsigned long long timestamp;
UAM_INFO("[%d]", user_id);
svc_list = g_slist_append(svc_list, service);
}
- timestamp = _uam_get_timestamp();
__uam_core_add_dev_to_list(user, dev_info,
- UAM_PRESENCE_STATE_PRESENT, timestamp, svc_list);
+ UAM_PRESENCE_STATE_PRESENT, dev_info->last_seen, svc_list);
retv_if(UAM_ERROR_NONE != __uam_db_begin_transaction(), UAM_ERROR_DB_FAILED);
/* Add device to database */
ret = _uam_device_db_insert_device_info(user->user_id,
- dev_info, UAM_PRESENCE_STATE_PRESENT, timestamp);
+ dev_info, UAM_PRESENCE_STATE_PRESENT, dev_info->last_seen);
if (UAM_ERROR_NONE != ret) {
UAM_WARN("Device addition to persistent DB failed");
__uam_db_end_transaction(0);
FUNC_EXIT;
}
-void __send_sensor_absence_event(uam_sensor_info_s *sensor_info, unsigned int sensor)
+static void __send_sensor_absence_event(uam_sensor_info_s *sensor_info,
+ unsigned int sensor)
{
FUNC_ENTRY;
GSList *l;
user->account, svc->name,device_id));
UAM_DBG("Sent UAM_EVENT_USER_PRESENCE_DETECTED to %s"
" on device %s"
- " for 0x%8.8X, User: %s Service: %s",
+ " for 0x%8.8X, User: %s Service: %s Timestamp: %llu",
mon->name, device_id,
sensor, user->account,
- svc->name);
+ svc->name,
+ user->timestamp);
}
}
}
/* Update database (presence state & timestamp) */
- ret = _uam_device_db_update_device_timestamp(dev_info->device_id,
- dev_info->type, dev_info->mac, tech->timestamp);
+ ret = _uam_device_db_update_device_lastseen(dev_info->device_id,
+ dev_info->type, dev_info->mac, dev_info->last_seen);
if (UAM_ERROR_NONE != ret) {
- UAM_WARN("_uam_device_db_update_device_timestamp failed");
+ UAM_WARN("_uam_device_db_update_device_lastseen failed");
__uam_db_end_transaction(0);
return ret;
}
{
FUNC_ENTRY;
GSList *l;
- long timestamp;
/*
* For each service, find users absent on given sensor. Then for each
if (!user)
continue;
- timestamp = time(NULL);
- if (-1 == timestamp)
- UAM_ERR("time() return -1");
- else
- user->timestamp = (unsigned long long)timestamp;
+ user->timestamp = 0;
_uam_manager_send_event(mon->name,
UAM_EVENT_USER_ABSENCE_DETECTED,
g_variant_new("(utss)", sensor, user->timestamp,
user->account, svc->name));
UAM_DBG("Sent UAM_EVENT_USER_ABSENCE_DETECTED to %s"
- " for 0x%8.8X, User: %s Service: %s"
- " timestamp [%llu]",
- mon->name, sensor, user->account,
- svc->name, user->timestamp);
+ " for 0x%8.8X, User: %s Service: %s",
+ mon->name, sensor, user->account, svc->name);
}
}
return error_code;
}
-int _uam_device_db_update_device_timestamp(char *device_id, int tech_type,
+int _uam_device_db_update_device_lastseen(char *device_id, int tech_type,
char *address, unsigned long long timestamp)
{
int error_code = UAM_ERROR_NONE;
* - User detection supported,
*/
typedef enum {
- UAS_NOT_SUPPORT_USER,
- UAS_SUPPORT_USER
+ UAS_NOT_SUPPORT_USER, /**< This means that not including user_id */
+ UAS_SUPPORT_USER /**< This means that including user_id */
} uas_capability_e;
/* Detection event types */
typedef enum {
- UAS_PRESENCE = 0x01,
- UAS_ABSENCE = 0x02
+ UAS_PRESENCE = 0x01, /**< Presence event */
+ UAS_ABSENCE = 0x02 /**< Absence event */
} uas_detection_type_e;
/* Device address information structure */
typedef struct {
- uas_address_type_e type;
- char *address;
+ uas_address_type_e type; /**< Address fype for the connectivity */
+ char *address; /**< Address data */
} uas_address_info_t;
/* Device ble payload information structure */
/* Device information structure */
typedef struct {
- int user_id;
- unsigned int supported_techs;
- char *device_id;
- int os;
- int num_addr;
- uas_address_info_t *addr_list;
+ int user_id; /**< User ID for the DB */
+ unsigned int supported_techs; /**< Connectivity type */
+ char *device_id; /**< Device ID */
+ int os; /**< OS type (Tizen,Android, iOS) */
+ int num_addr; /**< The number of address list */
+ uas_address_info_t *addr_list; /**< Address list (IP, Subnet Mask, Gateway etc) */
int discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
- uas_ble_payload_t *payload;
+ unsigned long long last_seen; /**< Last seen time */
+ uas_ble_payload_t *payload; /**< BLE payload for BLE device filtering */
} uas_device_info_t;
/* Sensor information structure */
typedef void (*uas_device_active_scan_callback)(
uas_active_scan_event_e event, const uas_device_info_t *device);
-/*
- * Callback to be invoked in response to search_active_devices() API
- *
- * [Param] timestamp - Timestamp to update.
- * [Param] device - Device information to update.
- */
-typedef void (*uas_device_update_timestamp_callback)(unsigned long long timestamp,
- uas_device_info_t *device);
-
/* UA plug-in callback structure */
typedef struct {
uas_device_detection_callback device_detected_cb; /**< For connectivity sensors */
uas_device_added_callback device_added_cb; /**< For connectivity sensors */
uas_device_active_scan_callback device_active_scan_cb; /**< For connectivity sensors */
- uas_device_update_timestamp_callback device_update_timestamp_cb; /**< Update device timestamp */
} uas_callbacks_t;
typedef struct {