static void update_vital_state(struct input_event *pinput)
{
- int type;
-
/* Change vital state to SYSCOMMON_DEVICED_VITAL_EXIT only if vital mode is active */
if (!vital_mode())
return;
if (pinput->type == EV_ABS || (pinput->type == EV_KEY &&
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
- type = SYSCOMMON_DEVICED_VITAL_EXIT;
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_VITAL_STATE, &type);
+ syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_INT_VITAL_MODE, SYSCOMMON_DEVICED_VITAL_EXIT);
}
}
static void update_vital_state(struct input_event *pinput)
{
- int type;
-
/* Change vital state to SYSCOMMON_DEVICED_VITAL_EXIT only if vital mode is active */
if (!vital_mode())
return;
if (pinput->type == EV_ABS || (pinput->type == EV_KEY &&
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
- type = SYSCOMMON_DEVICED_VITAL_EXIT;
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_VITAL_STATE, &type);
+ syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_INT_VITAL_MODE, SYSCOMMON_DEVICED_VITAL_EXIT);
}
}
#include <vconf.h>
#include <sys/types.h>
#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
#include <libsyscommon/log.h>
#include <system/syscommon-plugin-deviced-common-interface.h>
#include <linux/input.h>
static void update_vital_state(struct input_event *pinput)
{
- int type;
-
/* Change vital state to SYSCOMMON_DEVICED_VITAL_EXIT only if vital mode is active */
if (!vital_mode())
return;
if (pinput->type == EV_ABS || (pinput->type == EV_KEY &&
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
- type = SYSCOMMON_DEVICED_VITAL_EXIT;
- syscommon_notifier_emit_notify(DEVICED_NOTIFIER_VITAL_STATE, &type);
+ syscommon_resman_set_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_POWER),
+ DEVICED_POWER_ATTR_INT_VITAL_MODE, SYSCOMMON_DEVICED_VITAL_EXIT);
}
}
if (timeout_enable)
display_initialize_display_state_timeout_from_setting();
- syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_VITAL_STATE, vital_state_changed);
-
_I("input init");
ret = input_init_handler();
pm_lock_detector_init();
if (!check_default(ops))
ops->start(NORMAL_MODE);
- syscommon_notifier_unsubscribe_notify(DEVICED_NOTIFIER_VITAL_STATE, vital_state_changed);
syscommon_notifier_unsubscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_done);
syscommon_notifier_unsubscribe_notify(DEVICED_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
syscommon_notifier_unsubscribe_notify(DEVICED_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
return ret;
}
-int vital_state_changed(void *data)
+int vital_state_changed(int mode)
{
- int type;
-
- assert(data);
-
- type = *(int *)data;
- if (type == SYSCOMMON_DEVICED_VITAL_EXIT)
+ if (mode == SYSCOMMON_DEVICED_VITAL_EXIT)
suspend_other_process(SYSCOMMON_DEVICED_VITAL_EXIT);
return 0;
void pm_history_print(int fd, int count);
#endif
bool vital_mode(void);
-int vital_state_changed(void *data);
+int vital_state_changed(int mode);
int power_init_autosleep(void);
int power_exit_autosleep(void);
int power_acquire_wakelock(void);
return 0;
}
+static int set_power_attr_data(int resource_id,
+ const struct syscommon_resman_resource_attribute *attr,
+ const void *data, int count)
+{
+ if (!data)
+ return -EINVAL;
+
+ switch (attr->id) {
+ case DEVICED_POWER_ATTR_INT_VITAL_MODE:
+ {
+ int mode = *(const int *) data;
+ vital_state_changed(mode);
+ }
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/**
* FIXME: After developing the power abstraction layer, this attribute should
* be fixed. Because the suspend-to-ram supports both echo-mem and wakelock
.flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
.ops = {
.get = get_power_attr_data,
+ .set = set_power_attr_data,
.is_supported = syscommon_resman_resource_attr_supported_always,
},
}, {