plugin-api: deviced: Add syscommon_plugin_deviced_battery_update_health_ovp_state() 43/300143/2 accepted/tizen/unified/20231122.172540
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 17 Oct 2023 09:11:31 +0000 (18:11 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 10 Nov 2023 08:10:57 +0000 (17:10 +0900)
When the battery health state is changed to OVP, update_health_ovp_state is called
according to deviced battery policy.
It is moved from deviced mobile plugin to syscommon plugin api.

Change-Id: I00daa9d69c73e41d4c00ea928d9823292a648f94
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery-interface.h
src/plugin-api/deviced/include/system/syscommon-plugin-deviced-battery.h
src/plugin-api/deviced/src/syscommon-plugin-deviced-battery.c

index 1088509412bb8690caeedeb0c4160643bd970cb7..5051157d682713af62a40771e86a45b45b13a8b2 100644 (file)
@@ -30,8 +30,14 @@ extern "C" {
 #endif
 
 #include <stdbool.h>
+
+enum syscommon_deviced_battery_noti_status {
+       DEVICED_BATTERY_NOTI_OFF,
+       DEVICED_BATTERY_NOTI_ON,
+};
 typedef struct _syscommon_plugin_backend_deviced_battery_funcs {
        bool (*is_possible_to_notify_battery_full) (void);
+       void (*update_health_ovp_state) (enum syscommon_deviced_battery_noti_status noti_status);
 
 } syscommon_plugin_backend_deviced_battery_funcs;
 
index 3e376b0a945c52d9b90e45410e73d859a40120ea..3565804b960975ba33d789a0306cbd2cecd716f8 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
 #endif
 
 #include <stdbool.h>
+#include <system/syscommon-plugin-deviced-battery-interface.h>
 
 /**
  * @brief Get the backend data of deviced-battery module
@@ -49,6 +50,12 @@ int syscommon_plugin_deviced_battery_put_backend(void);
  */
 int syscommon_plugin_deviced_battery_is_possible_to_notify_battery_full(bool *possible_notify);
 
+/**
+ * @brief Call theupdate_battery_health_ovp_state of deviced-battery module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_deviced_battery_update_health_ovp_state(enum syscommon_deviced_battery_noti_status noti_status);
+
 #ifdef __cplusplus
 }
 #endif
index bf459ae3a3ca8d5bf882b0349b9c3f4a0ec9a388..1b33cbaa3039648f1c4cf076262ae64980432fd1 100644 (file)
@@ -100,3 +100,23 @@ int syscommon_plugin_deviced_battery_is_possible_to_notify_battery_full(bool *po
        *possible_notify = funcs->is_possible_to_notify_battery_full();
        return 0;
 }
+
+EXPORT
+int syscommon_plugin_deviced_battery_update_health_ovp_state(enum syscommon_deviced_battery_noti_status noti_status)
+{
+       int ret = 0;
+
+       if (!funcs) {
+               ret = syscommon_plugin_deviced_battery_get_backend();
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (!funcs || !funcs->update_health_ovp_state) {
+               _E("No backend or no \"update_battery_health_ovp_state\" function");
+               return -ENOTSUP;
+       }
+
+       funcs->update_health_ovp_state(noti_status);
+       return 0;
+}
\ No newline at end of file