summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2022-09-16 14:25:38 +0530
committerAbhay Agarwal <ay.agarwal@samsung.com>2022-09-26 14:28:16 +0530
commit47718fd3c69c44e3b67359850db209240294a732 (patch)
treebfb83f7ba641ea4cd4f0dd1557af1ee4560cc5f9
parentec43969197ea9abf8e4a9bf5fd66e6e2acff93a7 (diff)
downloadua-manager-47718fd3c69c44e3b67359850db209240294a732.tar.gz
ua-manager-47718fd3c69c44e3b67359850db209240294a732.tar.bz2
ua-manager-47718fd3c69c44e3b67359850db209240294a732.zip
Remove code duplicacy in converting detection mode
Change-Id: I05d5d3af3bf8b34c750267eb37b6ce4ec1a7c987 Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r--ua-daemon/src/pm/ua-plugin-manager.c34
-rw-r--r--ua-daemon/src/pm/ua-pm-util.c18
-rw-r--r--ua-daemon/src/pm/ua-pm-util.h2
3 files changed, 24 insertions, 30 deletions
diff --git a/ua-daemon/src/pm/ua-plugin-manager.c b/ua-daemon/src/pm/ua-plugin-manager.c
index ad51b50..b2d5e5a 100644
--- a/ua-daemon/src/pm/ua-plugin-manager.c
+++ b/ua-daemon/src/pm/ua-plugin-manager.c
@@ -533,21 +533,8 @@ int _uam_pm_start_detection(unsigned int detection_mode, unsigned int bitmask)
int scan_mode = UAS_SCAN_MODE_LOW_LATENCY;
extern uam_vendor_plugin_info_t* vendor_plugin;
int ret = UAM_ERROR_INTERNAL;
- uas_detection_type_e type;
-
- switch (detection_mode) {
- case UAM_DETECT_PRESENCE:
- type = UAS_PRESENCE;
- break;
- case UAM_DETECT_ABSENCE:
- type = UAS_ABSENCE;
- break;
- case UAM_DETECT_LOCATION:
- type = UAS_LOCATION;
- break;
- default:
- type = UAS_PRESENCE | UAS_ABSENCE;
- }
+
+ uas_detection_type_e type = _pm_util_uam_detection_to_uas_detection(detection_mode);
if (vendor_plugin && vendor_plugin->api)
vendor_plugin->api->get_scan_level(&scan_mode);
@@ -590,21 +577,8 @@ int _uam_pm_stop_detection(unsigned int detection_mode, unsigned int bitmask)
int id;
int status;
int ret = UAM_ERROR_INTERNAL;
- uas_detection_type_e type;
-
- switch (detection_mode) {
- case UAM_DETECT_PRESENCE:
- type = UAS_PRESENCE;
- break;
- case UAM_DETECT_ABSENCE:
- type = UAS_ABSENCE;
- break;
- case UAM_DETECT_LOCATION:
- type = UAS_LOCATION;
- break;
- default:
- type = UAS_PRESENCE | UAS_ABSENCE;
- }
+
+ uas_detection_type_e type = _pm_util_uam_detection_to_uas_detection(detection_mode);
for (id = UAS_PLUGIN_ID_BLE; id < UAS_PLUGIN_ID_MAX; id++) {
uam_sensor_plugin_info_t *plugin = plugins[id];
diff --git a/ua-daemon/src/pm/ua-pm-util.c b/ua-daemon/src/pm/ua-pm-util.c
index 837d0fd..37c698a 100644
--- a/ua-daemon/src/pm/ua-pm-util.c
+++ b/ua-daemon/src/pm/ua-pm-util.c
@@ -467,3 +467,21 @@ uam_sensor_info_s *_pm_util_uas_sensor_info_to_uam_sensor_info(
FUNC_EXIT;
return sensor_info;
}
+
+uas_detection_type_e _pm_util_uam_detection_to_uas_detection(unsigned int detection_mode)
+{
+ FUNC_ENTRY;
+
+ switch (detection_mode) {
+ case UAM_DETECT_PRESENCE:
+ return UAS_PRESENCE;
+ case UAM_DETECT_ABSENCE:
+ return UAS_ABSENCE;
+ break;
+ case UAM_DETECT_LOCATION:
+ return UAS_LOCATION;
+ break;
+ default:
+ return UAS_PRESENCE | UAS_ABSENCE;
+ }
+}
diff --git a/ua-daemon/src/pm/ua-pm-util.h b/ua-daemon/src/pm/ua-pm-util.h
index e45d73f..136c103 100644
--- a/ua-daemon/src/pm/ua-pm-util.h
+++ b/ua-daemon/src/pm/ua-pm-util.h
@@ -61,6 +61,8 @@ void _pm_util_uas_payload_to_uam_payload(
uam_ble_payload_s *dst_payload,
uas_payload_info_t *src_payload);
+uas_detection_type_e _pm_util_uam_detection_to_uas_detection(unsigned int detection_mode);
+
#ifdef __cplusplus
}
#endif