platform/core/connectivity/ua-manager.git
4 years agoChange the timestamp value to use the monotonic timer accepted/tizen/unified/20191115.125601 submit/tizen/20191115.102151
saerome.kim [Thu, 14 Nov 2019 09:59:11 +0000 (18:59 +0900)]
Change the timestamp value to use the monotonic timer

- 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>
4 years agoChange the timestamp value to use the monotonic timer
saerome.kim [Thu, 14 Nov 2019 09:59:11 +0000 (18:59 +0900)]
Change the timestamp value to use the monotonic timer

- 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: I24c1dbbec39417f6f13ec87dfff8c3239572722c
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoChange position of _uam_pm_stop_detection()
Lokesh [Thu, 14 Nov 2019 11:28:00 +0000 (16:58 +0530)]
Change position of _uam_pm_stop_detection()

Do _uam_pm_stop_detection() for both presence and absence together,
so that motion plugin sends detection_stopped event.

Change-Id: I9fb0e1696c16cb59eb0c3c7f910101844364b5ec
Signed-off-by: Lokesh <l.kasana@samsung.com>
4 years agoStart continuous detection only on sensors present in monitor
Abhay agarwal [Mon, 11 Nov 2019 06:10:05 +0000 (11:40 +0530)]
Start continuous detection only on sensors present in monitor

Instead of always starting continuous detection, start only when particular
environmental sensor is being detected by atleast one application.

Change-Id: I0e4baac40074fcd7b1cedf139dfe1e773b1c7049
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
4 years agoIn detection_stopped event, consider when no environmental sensors exist
Lokesh [Mon, 11 Nov 2019 01:43:55 +0000 (07:13 +0530)]
In detection_stopped event, consider when no environmental sensors exist

1/ If there is no environmental sensor, send UAM_DETECTION_CYCLE_END only once.
2/ First update service->remaining_time, then start various detections.
3/ Environmental sensors may send detection_stopped before start_detection of
connectivity sensor, which results in multiple detection stopped events to CAPI
within a detection window.

Change-Id: I1c149fe8be8f3f86bf053ac8167df765948df72e
Signed-off-by: Lokesh <l.kasana@samsung.com>
4 years agoDetection stopped event updated with detection cycle mid/end
Lokesh [Wed, 6 Nov 2019 10:12:39 +0000 (15:42 +0530)]
Detection stopped event updated with detection cycle mid/end

Every one minute we receive environmental presence/absence and detection
stopped calls. Earlier _uam_core_handle_detection_stopped() sends
detection_stopped_event which then called __ua_user_state_clean() and
cleaned recorded WIFI/BLE data in CAPI. Hence it cannot be used for
next one minute cycles of environmental sensors.

Change-Id: Ibad4cbf5e05840b31a593984a0f00f1ca4b72ae9
Signed-off-by: Lokesh <l.kasana@samsung.com>
4 years agoFix first detection stopped callback due to motion sensor
Lokesh [Thu, 7 Nov 2019 08:40:25 +0000 (14:10 +0530)]
Fix first detection stopped callback due to motion sensor

_uam_core_handle_detection_stopped() should work only if detection has been
started on that sensor previously.

Change-Id: I32b04ed63bc108606a59c0d64066cf9efa42ad52
Signed-off-by: Lokesh <l.kasana@samsung.com>
4 years agoFix memory leak
saerome.kim [Thu, 14 Nov 2019 03:37:49 +0000 (12:37 +0900)]
Fix memory leak

- Problem: during aging test, heap is increasing bit by bit.
- Cause: when updating the device list, the BLE payload is not freed.
- Solution: release BLE payload after updating the device list.

Change-Id: I2019643888883ca1c53ea16d9565e178ab6ec28f
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoAdd functionality that allow changing user's name accepted/tizen/unified/20191111.152608 submit/tizen/20191111.122616
saerome.kim [Mon, 11 Nov 2019 10:34:35 +0000 (19:34 +0900)]
Add functionality that allow changing user's name

- Problem: Users want to change their name.
- Cause: it is not supported to change the user name once user information
  added to ua-manager DB.
- Solution: Make the user can change his name even user-information added.

Change-Id: I54901e5c24da13239e8cce7d35063d15ed6ca975
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoFix crash issue on sensor status change event
Abhay agarwal [Mon, 11 Nov 2019 07:40:05 +0000 (13:10 +0530)]
Fix crash issue on sensor status change event

ua-manager crash was observed with sensor status change event
Destination: [(null)], event: [UNKNOWN ERROR], signal: [SensorStatusChanged]

Change-Id: I04610425e6019c51d3bd083ee59084a706e93eff
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
4 years agoAdd the compiler flag required for performing GTest
saerome.kim [Fri, 8 Nov 2019 09:46:19 +0000 (18:46 +0900)]
Add the compiler flag required for performing GTest

Change-Id: I3d3b21e4f0dc34e351dd060d4aeff5a72fbee575
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoFixed the problem where enabler method fails
saerome.kim [Fri, 8 Nov 2019 08:52:10 +0000 (17:52 +0900)]
Fixed the problem where enabler method fails

- Problem: The net.uamd.enabler method call fails.
- Cause: Invoke the 'enable' method to an object is not registered in
  dbus system.
- Solution: Remove 'enabler' interface and combine 'enabler' to
  '/net/uamd' interface

Change-Id: Ia40394ceb7d83a4305b0c0ab953ea6ffc423f9df
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoApply secure option
saerome.kim [Fri, 8 Nov 2019 08:44:37 +0000 (17:44 +0900)]
Apply secure option

- Problem: There is no FORTIFY option.
- Cause: Unlike the SSP that catches the stack BOF, a protection technique is
  needed to catch the BOF that occurs in a general memory buffer.
- Solution: apply FORTIFY and stack-canar options.

Change-Id: I1c1d45f1edfb0e017bdd8a3a3c1f42469f324220
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoFix the problem of not removing the device added to the default user or service
saerome.kim [Fri, 8 Nov 2019 06:19:09 +0000 (15:19 +0900)]
Fix the problem of not removing the device added to the default user or service

- Problem: can't remove a device from default-user.
- Cause: A device can be added to a default user or a default service,
  but can not be deleted.
- Solution: Deleting the default user checker.

Change-Id: I7bcce4fd4ac45e411e1be19fb793cf1532d366f7
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoCountermeasure if time() returns -1
saerome.kim [Fri, 8 Nov 2019 06:02:23 +0000 (15:02 +0900)]
Countermeasure if time() returns -1

- Problem: timestamp value may contain abnormal value.
- Cause: time() can retuern -1.
- Solution: We agreed to set the timestamp to 0 when time() returns -1.

Change-Id: I8d6189212589d28f09bac75b6075d7652415f4c7
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
4 years agoSet default values for payload
Lokesh [Tue, 5 Nov 2019 08:55:43 +0000 (14:25 +0530)]
Set default values for payload

Change-Id: I2d863d2c0ff566bab6a5910613adc6912adddc38
Signed-off-by: Lokesh <l.kasana@samsung.com>
5 years agoImprove error handling by returning error code
Abhay agarwal [Mon, 4 Nov 2019 15:28:37 +0000 (20:58 +0530)]
Improve error handling by returning error code

Change-Id: Idb6b9e9f2076972a0a4d4a2dedd173d7badfbc48
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoRemove duplicate code to copy device
Abhay agarwal [Mon, 4 Nov 2019 05:35:20 +0000 (11:05 +0530)]
Remove duplicate code to copy device

Change-Id: Idb87db47775d437a19d9c18f4321de6e41870f4f
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoReturn error code while handling devices
Abhay agarwal [Mon, 4 Nov 2019 04:38:29 +0000 (10:08 +0530)]
Return error code while handling devices

- Improve error handling by returning error code

Change-Id: I6d0da4c9a819345b808aaa913c2fa31e00f431a4
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoModify DB transactions to return when fail
Abhay agarwal [Thu, 31 Oct 2019 06:16:07 +0000 (11:46 +0530)]
Modify DB transactions to return when fail

- Problem: If the transaction fails, more queries are being run on database
to insert/update/delete data from it without starting the transaction.
- Solution: Rollback and return from the function when transaction fails.

Change-Id: I086e56cae6a4964925fd8ee63b486469fe052314
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoFix the problem that can't add a device to a user
saerome.kim [Fri, 1 Nov 2019 01:10:13 +0000 (10:10 +0900)]
Fix the problem that can't add a device to a user

- Problem: Once user_id exceeded 0xFFFF then can't add a device to the
  user anymore.
- Cause: ua-manager is managing user_id as a maximun 16-bit unsigned
  integer.
- Solution: change user_id type to 32-bit integer.

Change-Id: I31cdf1fe7bc7ed580091f81fd50f48882f715cbe
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFix NULL dereferencing
Lokesh [Thu, 31 Oct 2019 09:29:40 +0000 (14:59 +0530)]
Fix NULL dereferencing

Check null dereferencing while reading payload variables from device database.

Change-Id: Icd52bf9ebe27c6380b3974635f9dce524f94c837
Signed-off-by: Lokesh <l.kasana@samsung.com>
5 years agoFix memcpy's size parameter
Lokesh [Thu, 31 Oct 2019 07:43:48 +0000 (13:13 +0530)]
Fix memcpy's size parameter

Change-Id: Ie61b3d2aa18a1967d7b833d322584fdbf933ff65
Signed-off-by: Lokesh <l.kasana@samsung.com>
5 years agoFix the problem that the device can not be added to default_user accepted/tizen/unified/20191101.042011 submit/tizen/20191030.083316
saerome.kim [Wed, 30 Oct 2019 01:54:48 +0000 (10:54 +0900)]
Fix the problem that the device can not be added to default_user

- Problem: Unable to add device to default_user.
- Cause: ua-manager regards default_user's ID is always 1.
  However, If ua-manager has a problem occurred while accessing user-db,
  so all user information is deleted. In this case the user id of the default user
  is added to a value that is not 1.
- Solution: Deletes the hard-coded default user ID is 1.

Change-Id: I0d79364107aa7416c5b64b9481d2edc83801fbc4
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFix the problem that DB cannot be deleted if DB is not initialized.
saerome.kim [Mon, 28 Oct 2019 12:33:16 +0000 (21:33 +0900)]
Fix the problem that DB cannot be deleted if DB is not initialized.

- Problem: During factory reset, vendor-plugin can't initialize the DB.
- Cause: The DB was not opened before the DB initialization.
- Solution: Delete the DB when reset_cb() is called.

Change-Id: I65394d0c4ab9b9719cbe3f9f63f1ef82d243a583
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAdd supoort for database transactions submit/tizen/20191024.123502
Abhay agarwal [Thu, 24 Oct 2019 07:58:13 +0000 (13:28 +0530)]
Add supoort for database transactions

Change-Id: I5b1d1d07ad15385d4186647694f4f3bbbeb3aad0
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoModify ua-manager to support the vendor-plugin
saerome.kim [Wed, 23 Oct 2019 12:31:58 +0000 (21:31 +0900)]
Modify ua-manager to support the vendor-plugin

- Problem: we decided to remove the power-plugin.
- Cause: Recently, we decided to remove the power plugin and use the
  power-plugin.
- Solution: Modify ua-manager to support the vendor-plugin instead of
  the power plugin.

Change-Id: I3b726d46282fd6dfd437f7121a6209020ea4251d
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoModify to add the sensor status to sensor information
saerome.kim [Tue, 22 Oct 2019 07:24:41 +0000 (16:24 +0900)]
Modify to add the sensor status to sensor information

Change-Id: Ifc5394bde0f83e057b006072faebd254d3500ad9
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFix the problem that the Sensor Frameowk and UAF use different data
saerome.kim [Mon, 21 Oct 2019 11:44:26 +0000 (20:44 +0900)]
Fix the problem that the Sensor Frameowk and UAF use different data
format

- 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: I237f7201d7e7fed00858c47ca9350fcb1ad655c4
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAdd functionality to report instant sensor status change
saerome.kim [Mon, 21 Oct 2019 11:35:16 +0000 (20:35 +0900)]
Add functionality to report instant sensor status change

- Problem: in ABSENCE case, even the motion sensor detects ABSENCE
ua-manager reports this ABSENCE state after the detection window complete.
- Cause: If ABSENCE case, the ABSENCE can be jurged only when the
detction window complete.
- Solution: Whenever the sensor status is changed, plugin reports status
changed event immediately so that the user can recognize ABSENCE event
takes place during uncompleted ABSENCE detection window.

Change-Id: Ia5b12304976db4b89e5fa0977ea366a08361fc0e
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAdd new API to set low power mode accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix accepted/tizen/5.5/unified/20191031.023909 accepted/tizen/5.5/unified/mobile/hotfix/20201027.083806 accepted/tizen/unified/20191018.052936 submit/tizen/20191018.005538 submit/tizen_5.5/20191031.000003 submit/tizen_5.5_mobile_hotfix/20201026.185103 tizen_5.5.m2_release
saerome.kim [Thu, 17 Oct 2019 09:32:00 +0000 (18:32 +0900)]
Add new API to set low power mode

- Problem: it is needed that new API that can set low power mode
- Cause: without adding new API, build break occurs.
- Solution: add new API to set low power mode.

Change-Id: Ib5f9d4a4492953a146a383abdf32f7b7a7947d62
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoModify APIs to set low power mode for individual plugin
Abhay agarwal [Wed, 16 Oct 2019 15:23:23 +0000 (20:53 +0530)]
Modify APIs to set low power mode for individual plugin

Change-Id: I582417d1ee1df84043b17e36a97e4b8c06153016
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoReturn detailed error_code in _uam_add_ibeacon_adv_data() 94/215694/1 accepted/tizen/unified/20191017.035503 submit/tizen/20191017.002636
Lokesh [Mon, 14 Oct 2019 03:51:55 +0000 (09:21 +0530)]
Return detailed error_code in _uam_add_ibeacon_adv_data()

Change-Id: I17f3d23aa5c7fdd8c5332858ae4190a439abc6f5
Signed-off-by: Lokesh <l.kasana@samsung.com>
5 years agoAdd APIs to support update service functionality accepted/tizen/unified/20191014.005011 submit/tizen/20191011.095843
Abhay Agarwal [Fri, 11 Oct 2019 06:24:57 +0000 (15:24 +0900)]
Add APIs to support update service functionality

Update service functionality is required to update service information
like presence threshold and absence threshold.

Change-Id: Ic7e8ab3c4efeef1c33d491bbc848a8e67e0de360
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFix a problem that ADD_DEVICE operation failed accepted/tizen/unified/20191011.101532 submit/tizen/20191011.062256
saerome.kim [Fri, 11 Oct 2019 02:06:14 +0000 (11:06 +0900)]
Fix a problem that ADD_DEVICE operation failed

- Problem: if the wrong information is entered and failed to ADD_DEVICE.
  user apps can't add devices anymore.
- Cause: When one app removes the user information  while adding the device,
  there is no way to know how the ADD_DEVICE  operation succeeded or not.
- Solution: notify the user with an error when ADD_DEVICE failed.

Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoManage device and service number with autoincrement property of sqlite accepted/tizen/unified/20191011.015435 submit/tizen/20191009.230917
Abhay Agarwal [Tue, 8 Oct 2019 09:25:36 +0000 (18:25 +0900)]
Manage device and service number with autoincrement property of sqlite

This patch modifies to manage database table field service_number, device_number
user_id and ibeacon_id with autoincrement property of sqlite.
Managing these field manually can result in unnecessary conflicts.

Change-Id: I159b9491d6984c56047a815d02f6d35123feb60d
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFix busy handler implementation and update database handle name
Abhay Agarwal [Tue, 8 Oct 2019 03:04:14 +0000 (12:04 +0900)]
Fix busy handler implementation and update database handle name

Use a more specific database handle name instead of using 'database', since this
may conflict with other global variables from external libraries by accident

Change-Id: If1cca3013dc8558d80722f3582c416243a4e41df
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFix to print proper error message from the sqlite database handle in error case
Abhay Agarwal [Tue, 8 Oct 2019 06:42:17 +0000 (15:42 +0900)]
Fix to print proper error message from the sqlite database handle in error case

Change-Id: Ic08a3e880931dba225decbd757b456a303b2bb76
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoRemove database recovery logic when sqlite command fails
Abhay Agarwal [Mon, 7 Oct 2019 09:57:57 +0000 (18:57 +0900)]
Remove database recovery logic when sqlite command fails

Current database recovery logic delete the current database and create a new database when
SQLite command fail, although SQLite cammand can also fail in case database is busy or locked.

Change-Id: Ib361c118427a5ef9f3ce6142c4d44d75475a045e
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years ago[Fix] Dereference after free issue in _pm_util_uas_device_info_free() accepted/tizen/unified/20191008.101528 accepted/tizen/unified/20191008.101533 submit/tizen/20191008.005850 submit/tizen/20191008.043811
Nishant Chaprana [Mon, 7 Oct 2019 06:15:12 +0000 (11:45 +0530)]
[Fix] Dereference after free issue in _pm_util_uas_device_info_free()

Change-Id: I813852e34b52bd72f11fcb59e5b9e71f661f8515
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
5 years agoFixed potential memory leak issue and prevent crash accepted/tizen/unified/20191007.234839 submit/tizen/20191007.022831
saerome.kim [Fri, 4 Oct 2019 09:45:56 +0000 (18:45 +0900)]
Fixed potential memory leak issue and prevent crash

There is a process of removing the user's device in the user remove process.
At that time, the tech_info that was put in the service list was not deleted
from the list.

Change-Id: If9cb86e2684b8cb434275560f719588f5f18b4d4
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAdded support to get service specific device discriminant
Abhay Agarwal [Fri, 4 Oct 2019 07:06:26 +0000 (16:06 +0900)]
Added support to get service specific device discriminant

Change-Id: I9c39654fd4d64731f680e425b31e53b0f42b3ede
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoImprove error handling and return error code in case of failure
Abhay Agarwal [Fri, 4 Oct 2019 01:39:47 +0000 (10:39 +0900)]
Improve error handling and return error code in case of failure

This commit improves the error handling in ua-manager by returning error codes
in case of failures instead of just giving warnings.

Change-Id: I2eddd477c04e2fd2a5d33842d8659fceff6b65d7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoImprove database API names
Abhay Agarwal [Fri, 4 Oct 2019 01:10:28 +0000 (10:10 +0900)]
Improve database API names

This commit modifies and improves the names of database APIs.
This changes API names from _ua_ to _uam_ to follow consistency in ua-manager.

Change-Id: I84132dbd0af3ddd3e5865eed0384921310810f63
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoAdd Database APIs to provide device service info during init
Abhay Agarwal [Wed, 2 Oct 2019 11:49:04 +0000 (20:49 +0900)]
Add Database APIs to provide device service info during init

Change-Id: Icc1e80615aafdde423c53ec9e3d4e64372d0d323
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoHandle service device mapping and filter detected devices
Abhay Agarwal [Wed, 2 Oct 2019 10:30:24 +0000 (19:30 +0900)]
Handle service device mapping and filter detected devices

This commit handles the service specific device discriminant and filters
the detected devices from plugins based on this discriminant.

Change-Id: I5c2194f455a51403161a6011665d606c0677a4ed
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agocleanup device services table when a device is removed
Abhay Agarwal [Wed, 2 Oct 2019 07:00:01 +0000 (16:00 +0900)]
cleanup device services table when a device is removed

This commit cleanup the corresponding device entries from device_services table.

Change-Id: Ie8d3166f520a7577f547c22966907b92f1a7b054
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoDatabase APIs to update device service information
Abhay Agarwal [Wed, 2 Oct 2019 01:02:49 +0000 (10:02 +0900)]
Database APIs to update device service information

Change-Id: I61ccb0da2cbcf76e8c7a38ba7f2e8b8a77e047c1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoDatabase modifications to handle service specific discriminant
Abhay Agarwal [Wed, 2 Oct 2019 02:36:30 +0000 (11:36 +0900)]
Database modifications to handle service specific discriminant

Change-Id: I836d476ef93e473f8dfe2119b25cb400e4628b5c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoProvide service based device discriminant
Abhay Agarwal [Tue, 1 Oct 2019 03:59:31 +0000 (12:59 +0900)]
Provide service based device discriminant

Change-Id: I4e88160885fcdd80679a45539126890080718a9f
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoUA-API Modification for service based device discriminant
Abhay Agarwal [Tue, 1 Oct 2019 01:08:46 +0000 (10:08 +0900)]
UA-API Modification for service based device discriminant

Change-Id: If9a8e63f2b2ed0fdd0638abee09bee4105cf3430
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoSend presence/absence events when sensor info is NULL accepted/tizen/unified/20191004.003626 submit/tizen/20191002.073539
Abhay Agarwal [Wed, 2 Oct 2019 02:10:54 +0000 (11:10 +0900)]
Send presence/absence events when sensor info is NULL

This commit sends the presence/absence events to capi with NULL
values in case sensor info received is NULL.

1087646: var_deref_model: Passing null pointer sensor_info to
         __send_sensor_presence_event, which dereferences it.

Change-Id: I9f18cf338e94b41d40211e0d8d7bd3218d775366
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFixed crash issue
saerome.kim [Tue, 1 Oct 2019 22:49:07 +0000 (07:49 +0900)]
Fixed crash issue

A crash occurs in a harsh environment because the memory is broken.
To prevent incorrect access, make variables allocated to heap as null after
variable free().

Change-Id: Iee9c4df9af93354ff96e179765d22c39aa2df685
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoProvide sensor information in absence callback submit/tizen/20191001.125608
Abhay Agarwal [Tue, 1 Oct 2019 06:23:06 +0000 (15:23 +0900)]
Provide sensor information in absence callback

This commit modifies the absence sensor callback and provides the detected
sensor information to CAPI for environmental sensors.

Change-Id: Ib80eaa7377c69c630bdc76703445f16e23d2fd86
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years ago[Fix] [GLib Err] GLib-0x08: g_variant_unref: assertion 'value->ref_count > 0' failed accepted/tizen/unified/20191002.013423 submit/tizen/20191001.112138
Nishant Chaprana [Mon, 30 Sep 2019 14:55:22 +0000 (20:25 +0530)]
[Fix] [GLib Err] GLib-0x08: g_variant_unref: assertion 'value->ref_count > 0' failed

Change-Id: I2eb368406a9ad8684fa28269194fa674c1995ca6
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
5 years agoFixed a problem that can't create DB.
saerome.kim [Mon, 30 Sep 2019 12:24:31 +0000 (21:24 +0900)]
Fixed a problem that can't create DB.

If there is no DB file or the size is 0, the DB file is not created.

Change-Id: If967a1ae63f1d0d61a344ff805663e1be647bbe0
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years ago[Fix] services receiving detection callback on every detection for connectivity sensors.
Abhay Agarwal [Mon, 30 Sep 2019 08:18:05 +0000 (17:18 +0900)]
[Fix] services receiving detection callback on every detection for connectivity sensors.

Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
This patch fix the issue of services receiving detection callback after every detection.
After this patch services will only receive detection event only once in their detection cycle.
This patch does not affect the environmental sensors callback.

Change-Id: Idea2cf785dbe302c921ef18f67d70bc500896dbd

5 years ago[Fix] possible null pointer dereference
Nishant Chaprana [Fri, 27 Sep 2019 07:22:13 +0000 (12:52 +0530)]
[Fix] possible null pointer dereference

Change-Id: I7200c678c1aa3d9c40b44cab18c5fe84a065b9a3
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
5 years agoSet default light threshold as 2
saerome.kim [Fri, 27 Sep 2019 06:24:42 +0000 (15:24 +0900)]
Set default light threshold as 2

Change-Id: I4a4da9d914bffb0535a803b5f24080aaa26fb850
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAllow device to be removed when discriminant disabled accepted/tizen/unified/20190929.221439 submit/tizen/20190927.055416
Abhay Agarwal [Fri, 27 Sep 2019 03:51:07 +0000 (12:51 +0900)]
Allow device to be removed when discriminant disabled

Change-Id: I5aeb906656032597a6656ccceeed02706239e4e7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFixed svace issues.
saerome.kim [Fri, 27 Sep 2019 01:38:01 +0000 (10:38 +0900)]
Fixed svace issues.

410291: Potential Memory Leak.
410713: Handle leak of SQLLite statement.
401702, 410740, 410741: Memory leak.
410742: Missing null-check.

Change-Id: I709b77dc29699c434e94bc5645455bcfdeb53bed
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoUpdate default presence/absence threshold
Abhay Agarwal [Thu, 26 Sep 2019 05:30:15 +0000 (14:30 +0900)]
Update default presence/absence threshold

Change-Id: I3ef0ad7c4cdecaa7e2dcabb4d696f2bc53623e6b
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoAPI Support for set presence/absence threshold
Abhay Agarwal [Wed, 25 Sep 2019 10:42:45 +0000 (19:42 +0900)]
API Support for set presence/absence threshold

Change-Id: I74daf1f806afa4df35fbb8c6e20acefd86b57151
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agosensor info memory issues
Abhay Agarwal [Tue, 24 Sep 2019 03:53:06 +0000 (12:53 +0900)]
sensor info memory issues

Change-Id: I5a8cfee673741c30cb7c1cb24dbb562256669efe
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoProvide sensor information in detection callback
Abhay Agarwal [Fri, 20 Sep 2019 10:13:35 +0000 (19:13 +0900)]
Provide sensor information in detection callback

Change-Id: Ic36c9180ad27660ab20059f05cd5441a3cbc6ae1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoAdded script to create .ua-manager-data.db
saerome.kim [Tue, 24 Sep 2019 03:50:05 +0000 (12:50 +0900)]
Added script to create .ua-manager-data.db
Added APACHE-2.0 license in ua_db.sql

Change-Id: I6068784d0b2bd60d5a7478922ca12d20b188bd94
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoupdate ua_db.sql for db migration support
Abhay Agarwal [Tue, 24 Sep 2019 01:39:12 +0000 (10:39 +0900)]
update ua_db.sql for db migration support

Change-Id: I7b7b5dfd85e196e6e71243955f9e38861d597d6a
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoFixed svace issues. accepted/tizen/unified/20190923.225303 submit/tizen/20190923.121724
saerome.kim [Mon, 23 Sep 2019 12:12:07 +0000 (21:12 +0900)]
Fixed svace issues.

410290, 410291, 410292, 410293: Memory leak due to unrelaseing
returned pointer after calling sql3_mrprintf()

Change-Id: I4eb8c49027f25c1e901905848ee0ff6f930b440c
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFixed a coverity issue.
saerome.kim [Mon, 23 Sep 2019 08:45:19 +0000 (17:45 +0900)]
Fixed a coverity issue.

- 1087243 (#1 of 1): var_deref_model: Passing null pointer database to
sqlite3_busy_handler, which dereferences it.

Change-Id: I7ca3b4ec8c3fe26544ae7a2986088fae76e8cd9a
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years ago[Fix] Absence detection callback 37/214437/1
Abhay Agarwal [Wed, 18 Sep 2019 10:33:58 +0000 (19:33 +0900)]
[Fix] Absence detection callback

Change-Id: Id9acbf51ab574be1348f9342612f4b4abe2dd426
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years ago[Fix] Presence detection callback 36/214436/1
Abhay Agarwal [Wed, 18 Sep 2019 04:34:12 +0000 (13:34 +0900)]
[Fix] Presence detection callback

Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
This patch fix the issue of presence callback not being received in ALL mode,
when light presence was detected before motion.

Change-Id: Id1b5811d695a66762ac70ef8e77f46b413f43081

5 years agoAdd functionality to check database version 35/214435/1
Abhay Agarwal [Tue, 17 Sep 2019 09:16:38 +0000 (18:16 +0900)]
Add functionality to check database version

Change-Id: I3c8f7194cd04b2822569de24e9e8e763b16c5311
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
5 years agoChaged default detection cycle: 900sec 54/213954/1
saerome.kim [Tue, 17 Sep 2019 02:21:29 +0000 (11:21 +0900)]
Chaged default detection cycle: 900sec
Remove an unused config. file.

Change-Id: Idc026724fd32d4cba16528cd9988cd3d2d441217
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoEnable continuous monitoring for envionmental sensors accepted/tizen/unified/20190917.034055 submit/tizen/20190916.120818
Abhay agarwal [Mon, 2 Sep 2019 09:29:33 +0000 (14:59 +0530)]
Enable continuous monitoring for envionmental sensors

Change-Id: Ib96df58d03eb615dad246beee28f12130fc999ec
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoFixed a coverity issue
saerome.kim [Mon, 16 Sep 2019 09:50:11 +0000 (18:50 +0900)]
Fixed a coverity issue

1047600 leaked_storage: Variable out_var going out of scope leaks the storage it points to.

Change-Id: I1aaae9068efe4cce8c020f3e974909a119c52c15
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoAdd database API to clear adv table
Abhay agarwal [Fri, 13 Sep 2019 07:13:49 +0000 (12:43 +0530)]
Add database API to clear adv table

Change-Id: I1fa74d4d5adff3e3121e6357c54f4a997f3e5478
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years ago[Fix] coding style and remove extra comments
Abhay agarwal [Mon, 9 Sep 2019 06:58:44 +0000 (12:28 +0530)]
[Fix] coding style and remove extra comments

Change-Id: I455546293fc2982e5433c52998ab42b580bad1b1
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoRemove duplicate code to check table creation
Abhay agarwal [Fri, 6 Sep 2019 11:15:03 +0000 (16:45 +0530)]
Remove duplicate code to check table creation

Change-Id: I8973346679cfb0fd58cf6e8c6889cdb697fab885
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoRemove extra comments from code
Abhay agarwal [Fri, 6 Sep 2019 09:35:46 +0000 (15:05 +0530)]
Remove extra comments from code

Change-Id: I4a03ab1b941a2c3cca4392d99fe0dd9073268ddb
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoUpdate DB recovery logic
Abhay agarwal [Fri, 6 Sep 2019 06:25:29 +0000 (11:55 +0530)]
Update DB recovery logic

Change-Id: I2f43ff3c4842f5ffdb6b315ae2bda72f80edb1b2
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoRefactor db code to increase SAM score
Abhay agarwal [Thu, 5 Sep 2019 13:45:09 +0000 (19:15 +0530)]
Refactor db code to increase SAM score

Change-Id: I080dc2c315851b5f0166c20ef8bf9ac856ae6b3b
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoUpdate integrity check error codes
Abhay agarwal [Thu, 5 Sep 2019 11:33:44 +0000 (17:03 +0530)]
Update integrity check error codes

Change-Id: I21cb36f401a0684f21f850ad92002d4e054f0117
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoSet maximum attempts to access db in case db is locked
Abhay agarwal [Thu, 5 Sep 2019 11:04:52 +0000 (16:34 +0530)]
Set maximum attempts to access db in case db is locked

Change-Id: Ibed4b25c766e8e84ca6446737db8ccaa5aea4440
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoMove common db function from user table file
Abhay agarwal [Thu, 5 Sep 2019 10:00:34 +0000 (15:30 +0530)]
Move common db function from user table file

Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
This patch also refactor the check_integrity function in multiple useful functions
Changes done as per db review

Change-Id: Ie9d0c08c9b2c64ac9d289cd73526ee4232f615ab

5 years ago[DB Review] DB commitee review comments.
saerome.kim [Thu, 5 Sep 2019 08:21:48 +0000 (17:21 +0900)]
[DB Review] DB commitee review comments.

Change-Id: Id8431c88a9cc4e6a673d9b947501768aa171d3db
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFix DB review issues 57/213357/1 accepted/tizen/unified/20190904.224508 submit/tizen/20190904.113521
Abhay agarwal [Wed, 4 Sep 2019 09:34:10 +0000 (15:04 +0530)]
Fix DB review issues

4. There is no code for releasing 'adv' table at _ua_db_deinitialize().
8. When checking the table in__check_integrity(),
 206 line: printing UAM_DB_IBEACON_ADV_TABLE using sqlite3_mprintf,
 221 line: On the other hand, printing UAM_DB_DEVICES_TABLE out when checking done successfully.

Change-Id: Ic8c0ab234bbaaa1d68a06c3fa6fc13cc51dcbce9
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoFixed a svace issue 40/213340/2
saerome.kim [Wed, 4 Sep 2019 07:36:25 +0000 (16:36 +0900)]
Fixed a svace issue

406758: Non-terminated string of size 32.

Change-Id: I7d868df7f6a97ad886281e586dd468e5a0115e18
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFixed the problem that device can't be added to each plugin when ua-manager restart. accepted/tizen/unified/20190904.011549 submit/tizen/20190903.134657
saerome.kim [Tue, 3 Sep 2019 04:41:36 +0000 (13:41 +0900)]
Fixed the problem that device can't be added to each plugin when ua-manager restart.

Change-Id: I6ee109be28f9044575f48b83884864da2a33fd07
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoGet ibeacon adv list during initialization and add to plugin accepted/tizen/unified/20190830.110648 submit/tizen/20190830.050936
Abhay agarwal [Thu, 29 Aug 2019 10:47:57 +0000 (16:17 +0530)]
Get ibeacon adv list during initialization and add to plugin

Change-Id: I583c89dcfad00b10f4836d01f2ce5da73bfc6483
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoSupoort to add iBeacon Adv data in BLE Plugin
Abhay agarwal [Wed, 28 Aug 2019 08:18:53 +0000 (13:48 +0530)]
Supoort to add iBeacon Adv data in BLE Plugin

Change-Id: Iffacdd262e02c6d7cbeec3b93404c383207c6f24
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoAPI set to store ibeacon adv data
Abhay agarwal [Wed, 28 Aug 2019 04:58:12 +0000 (10:28 +0530)]
API set to store ibeacon adv data

Change-Id: Idffb8e303fba1f423e6f7692b51b25d92b2b6fc5
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years ago[Fix] Allow device to be removed when in default service accepted/tizen/unified/20190826.225907 accepted/tizen/unified/20190829.101441 submit/tizen/20190826.140219 submit/tizen/20190827.131417
Abhay agarwal [Mon, 26 Aug 2019 04:57:42 +0000 (10:27 +0530)]
[Fix] Allow device to be removed when in default service

Change-Id: I95f7209e7d25d8b4408ccacd5c92d632a6d8e6ed
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoRemove device only when not being used by any service
Abhay agarwal [Thu, 22 Aug 2019 12:00:52 +0000 (17:30 +0530)]
Remove device only when not being used by any service

Change-Id: I3fc7bfc47acc7fa82d29c5ca57d064d6728b1be1
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
5 years agoFixed the Coverity and Svace issues.
saerome.kim [Mon, 26 Aug 2019 09:08:05 +0000 (18:08 +0900)]
Fixed the Coverity and Svace issues.

1078581 Dereferencing null pointer tech.
1078570 leaked_storage: Variable 'app' going out of scope leaks the storage it points to.
386920 leaked_storage: Variable 'mac' going out of scope leaks the storage it points to.

Change-Id: I8dee929466df35ec1e577770846c9423a2ba895e
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoRemoved d-bus warning message
saerome.kim [Mon, 26 Aug 2019 05:17:36 +0000 (14:17 +0900)]
Removed d-bus warning message

- [GLib Err] GLib-0x08: g_variant_unref: assertion 'value->ref_count > 0' failed

Change-Id: Ieeeb6761bce1a6fe90f841195488b7ddd75d44e8
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFixed a bug that NULL DB path problem. 61/212561/1
saerome.kim [Fri, 23 Aug 2019 04:41:20 +0000 (13:41 +0900)]
Fixed a bug that NULL DB path problem.

Once used a parameter with either lon or '_' chracter in the middle or
the parameter, that regarded as NULL. In this case  DB path regarded as NULL.

Change-Id: Ief0b51b5fb01daf32badb01e7fd5d9d550514f6b
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoFixed Doxygen issues in header file and corrected spelling mistake in log print 63/212463/1 accepted/tizen/unified/20190822.105942 submit/tizen/20190822.051725
Nishant Chaprana [Wed, 21 Aug 2019 12:42:38 +0000 (18:12 +0530)]
Fixed Doxygen issues in header file and corrected spelling mistake in log print

Change-Id: I4bca73b41dd7f4d1ef8b10c716ec996a7d8ccb08
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
5 years agoRemoved 'users' group's access permission. 62/212462/1
saerome.kim [Wed, 21 Aug 2019 12:35:01 +0000 (21:35 +0900)]
Removed 'users' group's access permission.

- Do not allow 'users' group to access ua-manager.

Change-Id: I9fd90f925ff7716096ba37e160cb48715a5da440
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoIncreased SAM score 61/212461/1
saerome.kim [Wed, 21 Aug 2019 12:33:58 +0000 (21:33 +0900)]
Increased SAM score

- Increase Duplicated Code ratio.
- Removed all Global Variable violations.
- Removed all Predefined Preprocessor violations.

Change-Id: I059dfc8d902ef9a6bf9be282380d0e6ba1aad3bd
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
5 years agoModification to store device_icon in database
Abhay agarwal [Tue, 20 Aug 2019 05:17:16 +0000 (10:47 +0530)]
Modification to store device_icon in database

Change-Id: Ia3a477355b5d6e1de2b9dcc57d95a3bce5b68c5e
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>