To use deviced plugin battery module, plugin backend battery module getter/setter are added.
And, new plugin module definition "SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY" is added.
Also, to utilize plugin backend battery module function,
new battery interface header and source file was created.
To use plugin backend module, these are newly added.
- int syscommon_plugin_deviced_battery_get_backend(void);
- int syscommon_plugin_deviced_battery_put_backend(void);
- int syscommon_plugin_deviced_battery_is_possible_to_notify_battery_full(bool *possible_notify);
-> This is used to determine whether to inform the fully charged or not.
* libsyscommon.spec typo was also corrected.
Change-Id: I30a76504cd27ab44000459080fb7cd0f72f42c92
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-DPLUGIN_API_DEVICED_MAJORVER=${PLUGIN_API_DEVICED_MAJORVER} \
-DPLUGIN_API_COMMON_ENABLE_DLOG=1 \
-DPLUGIN_API_RESOURCED_ENABLE_DLOG=1 \
- -DPLUGIN_API_DEVICEDD_ENABLE_DLOG=1
+ -DPLUGIN_API_DEVICED_ENABLE_DLOG=1
make %{?_smp_mflags}
%install
enum syscommon_plugin_module {
SYSCOMMON_PLUGIN_MODULE_UNKNOWN = 0,
SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK,
+ SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY,
SYSCOMMON_PLUGIN_MODULE_END,
};
.num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK]),
.abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK],
},
+ [SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY] = {
+ .group = PLUGIN_GROUP_DEVICED,
+ .module = SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY,
+ .license = PLUGIN_LICENSE_APACHE_2_0,
+ .module_name = "SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY",
+ .backend_module_name = "deviced-battery",
+ .library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-battery.so",
+ .library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-battery.so",
+ .symbol_name = "system_plugin_backend_deviced_battery",
+ .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY]),
+ .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY],
+ },
};
#endif /* __PLUGIN_API_LIST_H__ */
# Please remove them from SRCS and add 'syscommon-plugin-api-common'
# to PKG_MODULES.
SET(SRCS src/syscommon-plugin-deviced-display.c
+ src/syscommon-plugin-deviced-battery.c
../common/src/syscommon-plugin-api-common.c
../common/src/syscommon-plugin-api-conf.c)
--- /dev/null
+/**
+ * MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SYSCOMMON_PLUGIN_DEVICED_BATTERY_INTERFACE_H__
+#define __SYSCOMMON_PLUGIN_DEVICED_BATTERY_INTERFACE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+typedef struct _syscommon_plugin_backend_deviced_battery_funcs {
+ bool (*is_possible_to_notify_battery_full) (void);
+
+} syscommon_plugin_backend_deviced_battery_funcs;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__SYSCOMMON_PLUGIN_DEVICED_BATTERY_INTERFACE_H__
--- /dev/null
+/**
+ * MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SYSCOMMON_PLUGIN_DEVICED_BATTERY_H__
+#define __SYSCOMMON_PLUGIN_DEVICED_BATTERY_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+
+/**
+ * @brief Get the backend data of deviced-battery module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_deviced_battery_get_backend(void);
+
+/**
+ * @brief Put the backend data of deviced-battery module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_deviced_battery_put_backend(void);
+
+/**
+ * @brief Call the is_possible_to_notify_battery_full function of deviced-battery module
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_deviced_battery_is_possible_to_notify_battery_full(bool *possible_notify);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__SYSCOMMON_PLUGIN_DEVICED_BATTERY_H__
--- /dev/null
+/**
+ * MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#ifdef ENABLE_DLOG
+#include <dlog.h>
+
+#define _D(fmt, args...) SLOGD(fmt, ##args)
+#define _I(fmt, args...) SLOGI(fmt, ##args)
+#define _W(fmt, args...) SLOGW(fmt, ##args)
+#define _E(fmt, args...) SLOGE(fmt, ##args)
+#else
+#define _D(fmt, args...) do { } while(0)
+#define _I(fmt, args...) do { } while(0)
+#define _W(fmt, args...) do { } while(0)
+#define _E(fmt, args...) do { } while(0)
+#endif
+
+#endif /* __COMMON_H__ */
--- /dev/null
+/**
+ * MIT License
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <glib.h>
+
+#include "syscommon-plugin-common.h"
+
+#include "common.h"
+#include "syscommon-plugin-deviced-battery.h"
+#include "syscommon-plugin-deviced-battery-interface.h"
+
+#ifndef EXPORT
+#define EXPORT __attribute__((visibility("default")))
+#endif
+
+static syscommon_plugin_backend_deviced_battery_funcs *funcs = NULL;
+
+EXPORT
+int syscommon_plugin_deviced_battery_get_backend(void)
+{
+ int ret = 0;
+
+ if (funcs)
+ return 0;
+
+ ret = syscommon_plugin_common_get_backend(
+ SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY,
+ (void **)&funcs);
+ if (ret < 0) {
+ _E("Failed to get deviced_battery backend: %d", ret);
+ return ret;
+ }
+
+ _I("Success to get deviced_battery backend: %d", ret);
+
+ return 0;
+}
+
+EXPORT
+int syscommon_plugin_deviced_battery_put_backend(void)
+{
+ int ret = 0;
+
+ if (!funcs)
+ return 0;
+
+ ret = syscommon_plugin_common_put_backend(
+ SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY,
+ (void *)funcs);
+ if (ret < 0) {
+ _E("Failed to put deviced_battery backend: %d", ret);
+ return ret;
+ }
+ funcs = NULL;
+
+ _I("Success to put deviced_battery backend: %d", ret);
+
+ return 0;
+}
+
+EXPORT
+int syscommon_plugin_deviced_battery_is_possible_to_notify_battery_full(bool *possible_notify)
+{
+ int ret = 0;
+
+ if (!possible_notify)
+ return -EINVAL;
+
+ if (!funcs) {
+ ret = syscommon_plugin_deviced_battery_get_backend();
+ if (ret < 0)
+ return ret;
+ }
+
+ if (!funcs || !funcs->is_possible_to_notify_battery_full) {
+ _E("No backend or no \"is_possible_to_notify_battery_full\" function");
+ return -ENOTSUP;
+ }
+
+ *possible_notify = funcs->is_possible_to_notify_battery_full();
+ return 0;
+}