#include <vconf.h>
#include <sys/types.h>
#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
#include <linux/input.h>
#include "ambient-mode.h"
static inline int current_state_in_on(void)
{
- return ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) || (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON));
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return 0;
+
+ return ((current == DEVICED_DISPLAY_STATE_DIM) || (current == DEVICED_DISPLAY_STATE_ON));
}
static inline void restore_custom_brightness(void)
{
bool custom_status;
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return;
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) && custom_status)
+ if (current == DEVICED_DISPLAY_STATE_DIM && custom_status)
display_backlight_update_by_custom_brightness();
}
};
int ignore = true;
static int code, value;
+ int ret;
+ enum deviced_display_state current;
assert(pinput);
break;
case EV_REL:
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_OFF) && bezel_wakeup) {
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ break;
+
+ if (current == DEVICED_DISPLAY_STATE_OFF && bezel_wakeup) {
switch_on_lcd(LCD_ON_BY_BEZEL);
ignore = false;
- } else if (get_pm_cur_state() != DEVICED_DISPLAY_STATE_OFF)
+ } else if (current != DEVICED_DISPLAY_STATE_OFF)
ignore = false;
break;
case EV_ABS:
#include <vconf.h>
#include <sys/types.h>
#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
#include <linux/input.h>
#include "ambient-mode.h"
static inline int current_state_in_on(void)
{
- return ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) || (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON));
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return 0;
+
+ return ((current == DEVICED_DISPLAY_STATE_DIM) || (current == DEVICED_DISPLAY_STATE_ON));
}
static inline void restore_custom_brightness(void)
{
bool custom_status;
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return;
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) && custom_status)
+ if (current == DEVICED_DISPLAY_STATE_DIM && custom_status)
display_backlight_update_by_custom_brightness();
}
};
int ignore = true;
static int code, value;
+ int ret;
+ enum deviced_display_state current;
assert(pinput);
break;
case EV_REL:
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_OFF) && bezel_wakeup) {
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ break;
+
+ if (current == DEVICED_DISPLAY_STATE_OFF && bezel_wakeup) {
switch_on_lcd(LCD_ON_BY_BEZEL);
ignore = false;
- } else if (get_pm_cur_state() != DEVICED_DISPLAY_STATE_OFF)
+ } else if (current != DEVICED_DISPLAY_STATE_OFF)
ignore = false;
break;
case EV_ABS:
#include <vconf.h>
#include <sys/types.h>
#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
#include <linux/input.h>
#include "ambient-mode.h"
static inline int current_state_in_on(void)
{
- return ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) || (get_pm_cur_state() == DEVICED_DISPLAY_STATE_ON));
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return 0;
+
+ return ((current == DEVICED_DISPLAY_STATE_DIM) || (current == DEVICED_DISPLAY_STATE_ON));
}
static inline void restore_custom_brightness(void)
{
bool custom_status;
+ int ret;
+ enum deviced_display_state current;
+
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ return;
display_backlight_get_custom_status(&custom_status);
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_DIM) && custom_status)
+ if (current == DEVICED_DISPLAY_STATE_DIM && custom_status)
display_backlight_update_by_custom_brightness();
}
};
int ignore = true;
static int code, value;
+ int ret;
+ enum deviced_display_state current;
assert(pinput);
break;
case EV_REL:
- if ((get_pm_cur_state() == DEVICED_DISPLAY_STATE_OFF) && bezel_wakeup) {
+ ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+ DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE, (int32_t *) ¤t);
+ if (ret < 0)
+ break;
+
+ if (current == DEVICED_DISPLAY_STATE_OFF && bezel_wakeup) {
switch_on_lcd(LCD_ON_BY_BEZEL);
ignore = false;
- } else if (get_pm_cur_state() != DEVICED_DISPLAY_STATE_OFF)
+ } else if (current != DEVICED_DISPLAY_STATE_OFF)
ignore = false;
break;
case EV_ABS:
#include "display-state-transition.h"
#include "display-backlight.h"
-static int get_max_brightness(int resource_id,
+typedef union {
+ int32_t i32;
+ int64_t i64;
+ uint32_t u32;
+ uint64_t u64;
+ double d;
+ void* p;
+ bool b;
+} resource_attr_data_t;
+
+static int get_display_attr_data(int resource_id,
const struct syscommon_resman_resource_attribute *attr, void *data)
{
- int brightness = 0;
int ret = 0;
+ resource_attr_data_t attr_data = { 0, };
if (!data)
return -EINVAL;
- ret = display_backlight_get_max_brightness(&brightness);
+ switch (attr->id) {
+ case DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS:
+ ret = display_backlight_get_max_brightness(&attr_data.i32);
+ break;
+ case DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE:
+ ret = display_state_get_current((enum deviced_display_state *) &attr_data.i32);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
if (ret < 0)
return ret;
- *(int *) data = brightness;
+ switch (attr->type) {
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT:
+ *(int32_t *) data = attr_data.i32;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
+ *(int64_t *) data = attr_data.i64;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
+ *(uint32_t *) data = attr_data.u32;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
+ *(uint64_t *) data = attr_data.u64;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
+ *(double *) data = attr_data.d;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_PTR:
+ *(void **) data = attr_data.p;
+ break;
+ case SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN:
+ *(bool *) data = attr_data.b;
+ break;
+ default:
+ return -EINVAL;
+ }
return 0;
}
.type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
.flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
.ops = {
- .get = get_max_brightness,
- .is_supported = syscommon_resman_resource_attr_supported_always
+ .get = get_display_attr_data,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
+ },
+ }, {
+ .name = "DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE",
+ .id = DEVICED_DISPLAY_ATTR_INT_GET_CURRENT_STATE,
+ .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+ .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+ .ops = {
+ .get = get_display_attr_data,
+ .is_supported = syscommon_resman_resource_attr_supported_always,
},
},
};