Remove code duplicacy in converting detection mode 24/282024/1
authorAbhay Agarwal <ay.agarwal@samsung.com>
Fri, 16 Sep 2022 08:55:38 +0000 (14:25 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 26 Sep 2022 08:58:16 +0000 (14:28 +0530)
Change-Id: I05d5d3af3bf8b34c750267eb37b6ce4ec1a7c987
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/pm/ua-pm-util.h

index ad51b501c0dfc047f97c6c76d4e8476c22f9f6d7..b2d5e5a802dba5f5e1ac0af6623bd2a20e8a8e7b 100644 (file)
@@ -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];
index 837d0fd605b2bcfc439194e41371a2358761cbeb..37c698a1cd241412fe2dd924157224519cf0d42a 100644 (file)
@@ -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;
+       }
+}
index e45d73fdf858236fa2c66a6ebc6042c100b6d3f1..136c103a35aca7d965c6a29cbff5c545bdd3dfe9 100644 (file)
@@ -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