summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungjae Cho <y0.cho@samsung.com>2024-06-19 11:33:29 +0900
committerYoungjae Cho <y0.cho@samsung.com>2024-06-24 11:13:19 +0900
commit0046f8031a33bb8db173e78f3aa723b655970986 (patch)
tree0394a555fc56b7c410ee19db97e9d96ca1a3d8ac
parent7c29aa06a40b760251fcece34178efe55ff4e479 (diff)
downloadlibsyscommon-0046f8031a33bb8db173e78f3aa723b655970986.tar.gz
libsyscommon-0046f8031a33bb8db173e78f3aa723b655970986.tar.bz2
libsyscommon-0046f8031a33bb8db173e78f3aa723b655970986.zip
plugin-api: deviced: Add interface for changing display state
Change-Id: I43e1862b655695174f17be7280ac372650ae2f53 Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
-rw-r--r--src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h2
-rw-r--r--src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h8
-rw-r--r--src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c19
-rw-r--r--tests/plugin-api/deviced/test-plugin-display.c9
-rw-r--r--tests/plugin-api/deviced/test.c12
5 files changed, 50 insertions, 0 deletions
diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h
index dfc1c0c..fbea058 100644
--- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h
+++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h
@@ -26,6 +26,7 @@
#define __SYSCOMMON_PLUGIN_DEVICED_DISPLAY_INTERFACE_H__
#include <stdbool.h>
+#include <sys/types.h>
#include <glib.h>
#ifdef __cplusplus
@@ -158,6 +159,7 @@ typedef struct _syscommon_plugin_backend_deviced_display_funcs {
int (*set_powersaving_mode) (int enable);
int (*control_auto_brightness) (int mode, int brightness);
int (*set_auto_brightness_min) (int brightness, const char *name);
+ int (*proc_change_state) (unsigned int cond, pid_t pid);
} syscommon_plugin_backend_deviced_display_funcs;
#ifdef __cplusplus
diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h
index 97f543f..d8ef737 100644
--- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h
+++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h
@@ -156,6 +156,14 @@ int syscommon_plugin_deviced_display_control_auto_brightness(int mode, int brigh
*/
int syscommon_plugin_deviced_display_set_auto_brightness_min(int brightness, const char *name);
+/**
+ * @brief Plugin implementation for change state
+ * @param[in] cond Condition for change state
+ * @param[in] pid Pid of which process has requested
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int syscommon_plugin_deviced_display_proc_change_state(unsigned int cond, pid_t pid);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c
index 3f4c795..f92a180 100644
--- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c
+++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c
@@ -367,3 +367,22 @@ int syscommon_plugin_deviced_display_set_auto_brightness_min(int brightness, con
return g_display_funcs->set_auto_brightness_min(brightness, name);
}
+
+EXPORT
+int syscommon_plugin_deviced_display_proc_change_state(unsigned int cond, pid_t pid)
+{
+ int ret = 0;
+
+ if (!g_display_funcs) {
+ ret = syscommon_plugin_deviced_display_get_backend();
+ if (ret < 0)
+ return -ENOTSUP;
+ }
+
+ assert(g_display_funcs);
+
+ if (!g_display_funcs->proc_change_state)
+ return -EOPNOTSUPP;
+
+ return g_display_funcs->proc_change_state(cond, pid);
+}
diff --git a/tests/plugin-api/deviced/test-plugin-display.c b/tests/plugin-api/deviced/test-plugin-display.c
index 81b98b2..959b42d 100644
--- a/tests/plugin-api/deviced/test-plugin-display.c
+++ b/tests/plugin-api/deviced/test-plugin-display.c
@@ -137,6 +137,14 @@ static int set_auto_brightness_min(int brightness, const char *name)
return 0;
}
+static int proc_change_state(unsigned int cond, pid_t pid)
+{
+ check_expected(cond);
+ check_expected(pid);
+
+ return 0;
+}
+
static syscommon_plugin_backend_deviced_display_funcs g_display_funcs = {
.load_display_config = load_display_config,
.load_state_info = load_state_info,
@@ -153,6 +161,7 @@ static syscommon_plugin_backend_deviced_display_funcs g_display_funcs = {
.set_powersaving_mode = set_powersaving_mode,
.control_auto_brightness = control_auto_brightness,
.set_auto_brightness_min = set_auto_brightness_min,
+ .proc_change_state = proc_change_state,
};
static int deviced_display_init(void **data)
diff --git a/tests/plugin-api/deviced/test.c b/tests/plugin-api/deviced/test.c
index 480d14e..2c7209e 100644
--- a/tests/plugin-api/deviced/test.c
+++ b/tests/plugin-api/deviced/test.c
@@ -186,6 +186,17 @@ static void test_set_auto_brightness_min(void **state)
assert_int_equal(ret, 0);
}
+static void test_proc_change_state(void **state)
+{
+ int ret;
+
+ expect_value(proc_change_state, cond, 3);
+ expect_value(proc_change_state, pid, 495);
+
+ ret = syscommon_plugin_deviced_display_proc_change_state(3, 495);
+ assert_int_equal(ret, 0);
+}
+
static const struct CMUnitTest testsuite_plugin_api_deviced[] = {
cmocka_unit_test(test_load_state_info),
cmocka_unit_test(test_notify_setting_value_changed),
@@ -201,5 +212,6 @@ static const struct CMUnitTest testsuite_plugin_api_deviced[] = {
cmocka_unit_test(test_set_powersaving_mode),
cmocka_unit_test(test_control_auto_brightness),
cmocka_unit_test(test_set_auto_brightness_min),
+ cmocka_unit_test(test_proc_change_state),
};
TESTSUITE_FIXTURE(testsuite_plugin_api_deviced, setup_plugin_deviced, teardown_plugin_deviced)