From 16eace6d221065b66951c59bf73a0083874d4808 Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Wed, 12 Jul 2023 19:06:31 +0900 Subject: [PATCH] display: Remove poll.c poll.c file has legacy functions pm_change_internal/pm_lock_internal/pm_unlock_internal() These functions are usually called from external requests like key-event, dbus method, etc. pm_lock_internal/pm_unlock_internal() gets specific display state lock/unlock. pm_change_internal() requests state transition according to specific condition. This file has to be erased, and then inner functions are relocated. These are new functions to be added. display-lock - int display_lock_request_lock_with_option(pid_t pid, int s_bits, int flag, int timeout); - int display_lock_request_unlock_with_option(pid_t pid, int s_bits, int flag); -> These replace pm_lock_internal/pm_unlock_intenral(). display-state-transition - int display_state_transition_request_state_transition_with_option(pid_t pid, int s_bits); -> This replaces pm_change_internal(). display-util - int display_util_get_display_state(int s_bits); -> This extracts display state from s_bits. Change-Id: Ied90f5a7f132f3bfcba1ecf1eef8faa02c728e31 Signed-off-by: Yunhee Seo --- plugins/iot-headed/display/core.c | 9 +- plugins/iot-headed/display/key-filter.c | 9 +- plugins/mobile/battery/battery-notification.c | 14 +- plugins/mobile/display/core.c | 9 +- plugins/mobile/display/key-filter.c | 9 +- plugins/tv/display/core.c | 9 +- plugins/tv/display/key-filter.c | 9 +- plugins/wearable/display/bezel.c | 8 +- plugins/wearable/display/core.c | 9 +- plugins/wearable/display/key-filter.c | 9 +- plugins/wearable/display/swim.c | 7 +- src/battery/lowbat-handler.c | 10 +- src/battery/power-supply.c | 24 ++-- src/display/ambient-mode.c | 19 +-- src/display/core.h | 3 - src/display/display-dbus.c | 33 +++-- src/display/display-lock.c | 57 ++++++++ src/display/display-lock.h | 2 + src/display/display-misc.c | 2 +- src/display/display-panel.c | 2 +- src/display/display-plugin.c | 24 ---- src/display/display-plugin.h | 6 - src/display/display-state-transition.c | 31 +++++ src/display/display-state-transition.h | 3 + src/display/display-util.c | 18 +++ src/display/display-util.h | 1 + src/display/display.c | 5 +- src/display/poll.c | 160 ----------------------- src/display/poll.h | 2 - src/extcon/cradle.c | 10 +- src/extcon/earjack.c | 3 +- src/shared/apps.c | 5 +- src/time/time-handler.c | 8 +- src/usb-gadget/usb-gadget.c | 7 +- src/usb-host/usb-host.c | 5 +- tests/deviced-common-private-test/CMakeLists.txt | 2 +- tests/deviced-common-private-test/test-mock.c | 3 +- 37 files changed, 222 insertions(+), 324 deletions(-) delete mode 100644 src/display/poll.c diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 2c41ed9..f1607e6 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -223,9 +223,6 @@ static int display_probe(void *data) if (ret) return ret; - /* display_plugin instance initialization */ - init_pm_internal(data); - return 0; } @@ -328,8 +325,7 @@ static void display_init(void *data) * deviced guarantees all booting script is executing. * Last script of booting unlocks this suspend blocking state. */ - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); /* Initial display state right after the booting done */ @@ -348,8 +344,7 @@ static void display_init(void *data) if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, STAY_CUR_STATE, timeout); } diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index fec11d9..2cf5f3b 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -135,8 +135,7 @@ static void longkey_pressed(void) if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { /* change state - LCD on */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); display_state_transition_do_state_transition_by_input_poll_event(); } @@ -391,8 +390,7 @@ static int lcdoff_powerkey(void) display_lock_release_lock_all(S_NORMAL); display_lock_release_lock_all(S_LCDDIM); display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_OFF); } else { ignore = false; skip_combination = false; @@ -502,8 +500,7 @@ static int process_screenlock_key(struct input_event *pinput) display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(-1, LCD_OFF); + display_state_transition_request_state_transition_with_option(-1, LCD_OFF); return true; } diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index b815542..ba6361e 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -28,7 +28,9 @@ #include "lowbat-handler.h" #include "battery-ops.h" #include "core.h" +#include "display-lock.h" #include "display-ops.h" +#include "display-state-transition.h" #include "poll.h" #include "shared/eventsystem.h" #include "shared/plugin.h" @@ -160,8 +162,7 @@ static int launch_lowbat_noti(int capacity, int option) noti_type = METHOD_LOW_NOTI_UPDATE; else { noti_type = METHOD_LOW_NOTI_ON; - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); } prev_level = battery_info.warning; if (battery->charge_now) @@ -201,8 +202,7 @@ static int launch_lowbat_noti(int capacity, int option) noti_type = METHOD_CRITICAL_NOTI_UPDATE; else { noti_type = METHOD_CRITICAL_NOTI_ON; - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); } prev_level = battery_info.critical; if (battery->charge_now) @@ -328,10 +328,8 @@ static gboolean health_timer_cb(void *data) CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery->health_s); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery->health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_lock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); if (battery->health == HEALTH_LOW) battery_charge_err_low_act(NULL); else if (battery->health == HEALTH_HIGH) diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index 30cd412..197a39d 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -272,9 +272,6 @@ static int display_probe(void *data) if (ret) return ret; - /* display_plugin instance initialization */ - init_pm_internal(data); - return 0; } @@ -378,8 +375,7 @@ static void display_init(void *data) * deviced guarantees all booting script is executing. * Last script of booting unlocks this suspend blocking state. */ - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); /* Initial display state right after the booting done */ @@ -398,8 +394,7 @@ static void display_init(void *data) if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, STAY_CUR_STATE, timeout); } diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 735b30c..17092f2 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -127,8 +127,7 @@ static void longkey_pressed(void) if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { /* change state - LCD on */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); display_state_transition_do_state_transition_by_input_poll_event(); } @@ -381,8 +380,7 @@ static int lcdoff_powerkey(void) display_lock_release_lock_all(S_NORMAL); display_lock_release_lock_all(S_LCDDIM); display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_OFF); } else { ignore = false; skip_combination = false; @@ -534,8 +532,7 @@ static int process_screenlock_key(struct input_event *pinput) display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(-1, LCD_OFF); + display_state_transition_request_state_transition_with_option(-1, LCD_OFF); return true; } diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 16341ec..ba2a191 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -220,9 +220,6 @@ static int display_probe(void *data) if (ret) return ret; - /* display_plugin instance initialization */ - init_pm_internal(data); - return 0; } @@ -325,8 +322,7 @@ static void display_init(void *data) * deviced guarantees all booting script is executing. * Last script of booting unlocks this suspend blocking state. */ - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); /* Initial display state right after the booting done */ @@ -345,8 +341,7 @@ static void display_init(void *data) if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, STAY_CUR_STATE, timeout); } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index e699c1c..6b0b940 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -134,8 +134,7 @@ static void longkey_pressed(void) if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { /* change state - LCD on */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); display_state_transition_do_state_transition_by_input_poll_event(); } @@ -390,8 +389,7 @@ static int lcdoff_powerkey(void) display_lock_release_lock_all(S_NORMAL); display_lock_release_lock_all(S_LCDDIM); display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_OFF); } else { ignore = false; skip_combination = false; @@ -501,8 +499,7 @@ static int process_screenlock_key(struct input_event *pinput) display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(-1, LCD_OFF); + display_state_transition_request_state_transition_with_option(-1, LCD_OFF); return true; } diff --git a/plugins/wearable/display/bezel.c b/plugins/wearable/display/bezel.c index 3f03460..e206aa3 100644 --- a/plugins/wearable/display/bezel.c +++ b/plugins/wearable/display/bezel.c @@ -24,7 +24,9 @@ #include "shared/device-notifier.h" #include "poll.h" #include "core.h" +#include "display-lock.h" #include "display-ops.h" +#include "display-state-transition.h" #include "shared/log.h" #include "shared/plugin.h" @@ -58,8 +60,7 @@ static void bezel_changed_cb(keynode_t *key_nodes, void *data) bezel_wakeup = vconf_keynode_get_bool(key_nodes); _I("Bezel wakeup condition: %d", bezel_wakeup); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); device_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, (void *)((intptr_t)bezel_wakeup)); } @@ -121,8 +122,7 @@ static void bezel_rotary_event_cb(keynode_t *key_nodes, void *data) ret = hal_device_bezel_set_sw_state(bezel_state); if (ret == 0) { _I("Bezel rotary event condition is %d", bezel_state); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); } else { _E("Failed to set bezel rotary event condition."); } diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 86be20d..082e87b 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -977,9 +977,6 @@ static int display_probe(void *data) if (ret) return ret; - /* display_plugin instance initialization */ - init_pm_internal(data); - return 0; } @@ -1117,8 +1114,7 @@ static void display_init(void *data) * deviced guarantees all booting script is executing. * Last script of booting unlocks this suspend blocking state. */ - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, STAY_CUR_STATE, DELAYED_INIT_WATING_TIME); /* Initial display state right after the booting done */ @@ -1137,8 +1133,7 @@ static void display_init(void *data) if (timeout < SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT)) timeout = SEC_TO_MSEC(DEFAULT_NORMAL_TIMEOUT); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, + display_lock_request_lock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, STAY_CUR_STATE, timeout); } diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 55c1f8e..13fd03e 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -126,8 +126,7 @@ static void longkey_pressed(void) if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) { /* change state - LCD on */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); display_state_transition_do_state_transition_by_input_poll_event(); } @@ -389,8 +388,7 @@ static int lcdoff_powerkey(void) display_lock_release_lock_all(S_NORMAL); display_lock_release_lock_all(S_LCDDIM); display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POWERKEY, LCD_OFF); } else { ignore = false; skip_combination = false; @@ -500,8 +498,7 @@ static int process_screenlock_key(struct input_event *pinput) display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_POWERKEY); /* LCD off forcly */ - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(-1, LCD_OFF); + display_state_transition_request_state_transition_with_option(-1, LCD_OFF); return true; } diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index 25ad0fa..f75756d 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -24,6 +24,7 @@ #include "device-interface.h" #include "display-ops.h" #include "display-panel.h" +#include "display-state-transition.h" #include "shared/plugin.h" #include "shared/log.h" @@ -94,16 +95,14 @@ static void swimmode_signal_handler(GDBusConnection *conn, _I("Request swim mode state %d by %d", val, pid); if (display_panel_get_dpms_cached_state() != DPMS_ON) { - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_SWIM, S_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_SWIM, S_NORMAL); lcd_state = true; } swim_execute((void *)((intptr_t)val)); if (lcd_state) { - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_SWIM, S_LCDOFF); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_SWIM, S_LCDOFF); } } diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index b67e6dd..0e2bec2 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -41,8 +41,10 @@ #include "shared/plugin.h" #include "setting.h" #include "poll.h" +#include "display-lock.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-state-transition.h" #include "power/power.h" #include "power/power-off.h" #include "power-supply.h" @@ -253,9 +255,9 @@ direct_launch: if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW || lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH || lowbat_popup_option == BAT_OPT_ERR_CF_OPEN) { - display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_DIM); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_LOWBAT, LCD_DIM); } else { - display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_LOWBAT, LCD_NORMAL); } if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW || lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH || @@ -301,14 +303,14 @@ int battery_charge_err_cf_act(void *data) int battery_charge_err_low_act(void *data) { - display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000); + display_lock_request_lock_with_option(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000); return lowbat_popup(BAT_OPT_ERR_TEMP_LOW); } int battery_charge_err_high_act(void *data) { - display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000); + display_lock_request_lock_with_option(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000); return lowbat_popup(BAT_OPT_ERR_TEMP_HIGH); } diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index c9c4c21..aa842eb 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -37,7 +37,9 @@ #include "shared/apps.h" #include "shared/event.h" #include "core.h" +#include "display-lock.h" #include "display-ops.h" +#include "display-state-transition.h" #include "power-supply.h" #include "battery.h" #include "battery-ops.h" @@ -413,11 +415,11 @@ static void update_present(enum battery_noti_status status) if (status == DEVICE_NOTI_ON) { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present); - display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0); } else { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); } if (battery_plgn->changed_battery_cf) battery_plgn->changed_battery_cf(battery.present); @@ -433,8 +435,8 @@ static void launch_health_popup(void) device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_lock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); else if (battery.health == HEALTH_HIGH) @@ -465,8 +467,8 @@ static void update_health(enum battery_noti_status status) } else { battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); health_status_broadcast(); if (abnormal_health_popup_timer) { CRITICAL_LOG("Battery health returned to normal. Stop abnormal popup."); @@ -488,8 +490,8 @@ void relaunch_health_popup(void) if (abnormal_health_popup_timer) g_source_remove(abnormal_health_popup_timer); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); - display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); + display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_lock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH); if (battery.health == HEALTH_LOW) battery_charge_err_low_act(NULL); else if (battery.health == HEALTH_HIGH) @@ -674,7 +676,7 @@ static void process_power_supply(void *data) int ret_lock = -1; int ret_val; - ret_lock = display_plugin_pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); + ret_lock = display_lock_request_lock_with_option(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0); if (old_battery.charge_now != battery.charge_now || battery.charge_now == CHARGER_ABNORMAL) { ret_val = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now); @@ -786,7 +788,7 @@ static void process_power_supply(void *data) } if (ret_lock == 0) { - display_plugin_pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN); } } @@ -1378,7 +1380,7 @@ int battery_pm_change_internal(int pid, int s_bits) if (battery_do_not_disturb()) return 0; - display_plugin_pm_change_internal(pid, s_bits); + display_state_transition_request_state_transition_with_option(pid, s_bits); return 0; } diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index 139b6c7..7c56b8a 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -23,6 +23,7 @@ #include "core.h" #include "display.h" +#include "display-lock.h" #include "display-ops.h" #include "display-panel.h" #include "display-plugin.h" @@ -89,8 +90,7 @@ static void ambient_set_condition(keynode_t *key_nodes, void *data) val = vconf_keynode_get_bool(key_nodes); if (val != ambient_condition) { if (display_panel_get_dpms_cached_state() != DPMS_ON) - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); } ambient_condition = val; @@ -118,8 +118,7 @@ int ambient_set_state(int on) * So at that time deviced should turn off display to match the pair. */ if (on) { - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_AMBIENT, + display_lock_request_lock_with_option(INTERNAL_LOCK_AMBIENT, LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME); } else ambient_pid = 0; @@ -168,8 +167,7 @@ static void ambient_start_clock(void) (ambient_state == false)) return; - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, STAY_CUR_STATE, + display_lock_request_lock_with_option(INTERNAL_LOCK_AMBIENT, LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME); } @@ -185,8 +183,7 @@ static void ambient_end_clock(pid_t pid) display_panel_set_panel_state_by_off_state(NORMAL_MODE); broadcast_lcd_off_late(LCD_OFF_LATE_MODE); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); } update_count++; @@ -245,8 +242,7 @@ static void ambient_lcdoff_signal_handler(GDBusConnection *conn, return; } - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, GOTO_STATE_NOW, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_AMBIENT, LCD_OFF, GOTO_STATE_NOW, 0); _I("Display off in suspend state."); @@ -254,8 +250,7 @@ static void ambient_lcdoff_signal_handler(GDBusConnection *conn, lcd_direct_control(DPMS_OFF, NORMAL_MODE); broadcast_lcd_off_late(LCD_OFF_LATE_MODE); - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN); } static void ambient_init(void *data) diff --git a/src/display/core.h b/src/display/core.h index 468fdb1..5b71967 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -109,9 +109,6 @@ void broadcast_lcd_off_late(enum device_flags flags); /* auto-brightness.c */ void set_brightness_changed_state(void); -/* poll.c */ -int check_dimstay(int next_state, int flag); - /* display-dbus.c */ int init_pm_dbus(void); diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 8f37f24..05c9a9d 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -50,6 +50,7 @@ //#include "display/display.h" #include "display-backlight.h" #include "display-misc.h" +#include "display-util.h" #define AUL_APPSTATUS_PATH "/Org/Tizen/Aul/AppStatus" #define AUL_APPSTATUS_INTERFACE "org.tizen.aul.AppStatus" @@ -101,14 +102,27 @@ static GVariant *dbus_stop(GDBusConnection *conn, if (NOT_SUPPORT_OPS(display_device_ops)) goto out; - if (disp_plgn->pm_change_internal) - disp_plgn->pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); display_device_ops->stop(CORE_LOGIC_MODE); out: return gdbus_new_g_variant_tuple(); } +static int check_dimstay(int next_state, int flag) +{ + if (next_state != LCD_OFF) + return false; + + if (!(flag & GOTO_STATE_NOW)) + return false; + + if (!(get_pm_status_flag() & DIMSTAY_FLAG)) + return false; + + return true; +} + static GVariant *dbus_lockstate(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) @@ -192,8 +206,7 @@ static GVariant *dbus_lockstate(GDBusConnection *conn, flag |= STAY_CUR_STATE; } - if (disp_plgn->pm_lock_internal) - ret = disp_plgn->pm_lock_internal(pid, state, flag, timeout); + display_lock_request_lock_with_option(pid, state, flag, timeout); out: g_free(state_str); g_free(option1_str); @@ -260,8 +273,7 @@ static GVariant *dbus_unlockstate(GDBusConnection *conn, flag = PM_RESET_TIMER; } - if (disp_plgn->pm_unlock_internal) - ret = disp_plgn->pm_unlock_internal(pid, state, flag); + display_lock_request_unlock_with_option(pid, state, flag); out: g_free(state_str); g_free(option_str); @@ -355,8 +367,7 @@ static GVariant *dbus_changestate(GDBusConnection *conn, goto out; } - if (disp_plgn->pm_change_internal) - ret = disp_plgn->pm_change_internal(pid, state); + display_state_transition_request_state_transition_with_option(pid, state); if (!ret && state == LCD_OFF) display_state_transition_update_lcdoff_reason(VCONFKEY_PM_LCDOFF_BY_TIMEOUT); @@ -848,13 +859,11 @@ static GVariant *dbus_dumpmode(GDBusConnection *conn, if (!strcmp(on, "on")) { pm_save_logdump(); - if (disp_plgn->pm_lock_internal) - disp_plgn->pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, + display_lock_request_lock_with_option(INTERNAL_LOCK_DUMPMODE, LCD_OFF, STAY_CUR_STATE, DUMP_MODE_WATING_TIME); display_backlight_unset_blink(); } else if (!strcmp(on, "off")) { - if (disp_plgn->pm_unlock_internal) - disp_plgn->pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_DUMPMODE, LCD_OFF, PM_SLEEP_MARGIN); display_backlight_set_blink(0); } else if (!strcmp(on, "blink")) { display_backlight_set_blink(500); diff --git a/src/display/display-lock.c b/src/display/display-lock.c index 85d731e..fe24f75 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -34,6 +34,7 @@ #include "display-config.h" #include "display-misc.h" #include "display-state-transition.h" +#include "display-util.h" #include "shared/log.h" #include "shared/log-macro.h" #include "shared/apps.h" @@ -728,4 +729,60 @@ int display_lock_proc_condition(PMMsg *data) display_state_transition_do_state_transition(get_pm_cur_state(), EVENT_TIMEOUT); return 0; +} + +int display_lock_request_lock_with_option(pid_t pid, int s_bits, int flag, int timeout) +{ + int cond; + PMMsg recv_data; + + cond = display_util_get_display_state(s_bits); + if (cond < 0) + return cond; + + if (!display_state_transition_is_display_state_support_transition(cond)) + return -ENOTSUP; + + cond = SET_COND_REQUEST(cond, PM_REQUEST_LOCK); + + if (flag & GOTO_STATE_NOW) + /* if the flag is true, go to the locking state directly */ + cond = SET_COND_FLAG(cond, PM_REQUEST_CHANGE); + + recv_data.pid = pid; + recv_data.cond = cond; + recv_data.timeout = timeout; + + display_state_transition_do_state_transition_by_pm_control_event(&recv_data); + + return 0; +} + +int display_lock_request_unlock_with_option(pid_t pid, int s_bits, int flag) +{ + int cond; + PMMsg recv_data; + + cond = display_util_get_display_state(s_bits); + if (cond < 0) + return cond; + + if (!display_state_transition_is_display_state_support_transition(cond)) + return -ENOTSUP; + + cond = SET_COND_REQUEST(cond, PM_REQUEST_UNLOCK); + + if (flag & PM_KEEP_TIMER) + cond = SET_COND_FLAG(cond, PM_FLAG_KEEP_TIMER); + + if (flag & PM_RESET_TIMER) + cond = SET_COND_FLAG(cond, PM_FLAG_RESET_TIMER); + + recv_data.pid = pid; + recv_data.cond = cond; + recv_data.timeout = 0; + + display_state_transition_do_state_transition_by_pm_control_event(&recv_data); + + return 0; } \ No newline at end of file diff --git a/src/display/display-lock.h b/src/display/display-lock.h index 7f2679a..ab07a24 100644 --- a/src/display/display-lock.h +++ b/src/display/display-lock.h @@ -42,5 +42,7 @@ int display_lock_is_state_locked(enum state_t state); int display_lock_print_lock_info(int fd); int display_lock_proc_condition(PMMsg *data); +int display_lock_request_lock_with_option(pid_t pid, int s_bits, int flag, int timeout); +int display_lock_request_unlock_with_option(pid_t pid, int s_bits, int flag); #endif /* __DISPLAY_LOCK_H__ */ diff --git a/src/display/display-misc.c b/src/display/display-misc.c index e7ed556..8d812fe 100644 --- a/src/display/display-misc.c +++ b/src/display/display-misc.c @@ -85,7 +85,7 @@ void display_misc_set_stay_touchscreen_off(bool on) _I("Stay touch screen off: %d", on); stay_touchscreen_off = on; - display_plugin_pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); } void display_misc_get_stay_touchscreen_off(bool *on) diff --git a/src/display/display-panel.c b/src/display/display-panel.c index ec6706c..aa3df63 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -202,7 +202,7 @@ void display_panel_set_lcd_paneloff_mode(bool on) _I("Lcd paneloff mode: %d", on); lcd_paneloff_mode = on; - display_plugin_pm_change_internal(INTERNAL_LOCK_PM, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL); } /* FIXME: This function is temporary, it can be redefined or not */ diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c index 1328593..3380401 100644 --- a/src/display/display-plugin.c +++ b/src/display/display-plugin.c @@ -27,30 +27,6 @@ void* display_plugin_handle(void) return g_display_plugin.handle; } -int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout) -{ - if (g_display_plugin.pm_lock_internal) - return g_display_plugin.pm_lock_internal(pid, s_bits, flags, timeout); - - return 0; -} - -int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags) -{ - if (g_display_plugin.pm_unlock_internal) - return g_display_plugin.pm_unlock_internal(pid, s_bits, flags); - - return 0; -} - -int display_plugin_pm_change_internal(pid_t pid, int s_bits) -{ - if (g_display_plugin.pm_change_internal) - return g_display_plugin.pm_change_internal(pid, s_bits); - - return 0; -} - int display_plugin_update_pm_setting(int key_idx, int val) { if (g_display_plugin.update_pm_setting) diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h index f6d9949..159f956 100644 --- a/src/display/display-plugin.h +++ b/src/display/display-plugin.h @@ -56,9 +56,6 @@ enum brightness_request_e { struct display_plugin { void *handle; - int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout); - int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag); - int (*pm_change_internal) (pid_t pid, int s_bits); int (*update_pm_setting) (int key_idx, int val); int (*get_lock_screen_state) (void); bool system_wakeup_flag; @@ -86,9 +83,6 @@ struct display_plugin { extern struct display_plugin g_display_plugin; void* display_plugin_handle(void); -int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout); -int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags); -int display_plugin_pm_change_internal(pid_t pid, int s_bits); int display_plugin_update_pm_setting(int key_idx, int val); bool display_plugin_is_there_update_pm_setting(void); int display_plugin_get_lock_screen_state(void); diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index cfab4fc..83a4c26 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -28,6 +28,7 @@ #include "display-lock.h" #include "display-plugin.h" #include "display-signal.h" +#include "display-util.h" #include "extcon/extcon.h" #include "power/power.h" #include "power/power-suspend.h" @@ -633,3 +634,33 @@ int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid) return 0; } + +int display_state_transition_request_state_transition_with_option(pid_t pid, int s_bits) +{ + int cond, ret; + PMMsg recv_data; + const int display_on = (LCD_NORMAL | LCD_DIM); + + cond = display_util_get_display_state(s_bits); + if (cond < 0) + return cond; + + ret = display_plugin_is_lcd_on_blocked(); + if (ret != LCDON_BLOCK_NONE && (cond & display_on)) { + _W("LCDON is blocked, %d.", ret); + return -ENOTSUP; + } + + if (!display_state_transition_is_display_state_support_transition(cond)) + return -ENOTSUP; + + cond = SET_COND_REQUEST(cond, PM_REQUEST_CHANGE); + + recv_data.pid = pid; + recv_data.cond = cond; + recv_data.timeout = 0; + + display_state_transition_do_state_transition_by_pm_control_event(&recv_data); + + return 0; +} \ No newline at end of file diff --git a/src/display/display-state-transition.h b/src/display/display-state-transition.h index a7d4dd9..9ef1708 100644 --- a/src/display/display-state-transition.h +++ b/src/display/display-state-transition.h @@ -24,6 +24,8 @@ #ifndef __DISPLAY_STATE_TRANSITION_H__ #define __DISPLAY_STATE_TRANSITION_H__ +#include + #include "core.h" #define LOCK_SCREEN_INPUT_TIMEOUT 10000 @@ -48,5 +50,6 @@ int display_state_transition_do_state_transition_by_pm_control_event(PMMsg *data int display_state_transition_do_state_action(int timeout); void display_state_transition_do_proc_change_state_action(enum state_t next, int timeout); int display_state_transition_do_proc_change_state(unsigned int cond, pid_t pid); +int display_state_transition_request_state_transition_with_option(pid_t pid, int s_bits); #endif /* __DISPLAY_STATE_TRANSITION_H__ */ \ No newline at end of file diff --git a/src/display/display-util.c b/src/display/display-util.c index eb9556a..ef7db97 100644 --- a/src/display/display-util.c +++ b/src/display/display-util.c @@ -73,3 +73,21 @@ int display_util_get_device_flags(unsigned long *device_flags) return 0; } + +int display_util_get_display_state(int s_bits) +{ + switch (s_bits) { + case LCD_NORMAL: + return S_NORMAL; + case LCD_DIM: + return S_LCDDIM; + case LCD_OFF: + return S_LCDOFF; + case STANDBY: + return S_STANDBY; + case SUSPEND: + return S_SLEEP; + default: + return -EINVAL; + } +} \ No newline at end of file diff --git a/src/display/display-util.h b/src/display/display-util.h index 39f7e71..9be17f1 100644 --- a/src/display/display-util.h +++ b/src/display/display-util.h @@ -27,5 +27,6 @@ int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name); int display_util_get_device_flags(unsigned long *device_flags); +int display_util_get_display_state(int s_bits); #endif /* __DISPLAY_UTIL_H__ */ \ No newline at end of file diff --git a/src/display/display.c b/src/display/display.c index 7b06647..97e4f27 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -26,6 +26,7 @@ #include "shared/log.h" #include "device-interface.h" #include "display.h" +#include "display-lock.h" #include "display-plugin.h" #include "display-config.h" #include "display-misc.h" @@ -430,8 +431,8 @@ static int delayed_init_done(void *data) return done; _I("Booting done, release booting lock."); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN); return done; } diff --git a/src/display/poll.c b/src/display/poll.c deleted file mode 100644 index 8a09447..0000000 --- a/src/display/poll.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * deviced - * - * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * @file poll.c - * @brief Power Manager poll implementation - * - */ - -#include -#include "core.h" -#include "device-interface.h" -#include "poll.h" -#include "display-ops.h" -#include "display-plugin.h" -#include "display-state-transition.h" -#include "shared/log.h" -#include "shared/plugin.h" - -static PMMsg recv_data; - -int check_dimstay(int next_state, int flag) -{ - if (next_state != LCD_OFF) - return false; - - if (!(flag & GOTO_STATE_NOW)) - return false; - - if (!(get_pm_status_flag() & DIMSTAY_FLAG)) - return false; - - return true; -} - -static enum state_t get_state(int s_bits) -{ - switch (s_bits) { - case LCD_NORMAL: - return S_NORMAL; - case LCD_DIM: - return S_LCDDIM; - case LCD_OFF: - return S_LCDOFF; - case STANDBY: - return S_STANDBY; - case SUSPEND: - return S_SLEEP; - default: - return -EINVAL; - } -} - -static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) -{ - int cond; - - cond = get_state(s_bits); - if (cond < 0) - return cond; - - if (!display_state_transition_is_display_state_support_transition(cond)) - return -ENOTSUP; - - cond = SET_COND_REQUEST(cond, PM_REQUEST_LOCK); - - if (flag & GOTO_STATE_NOW) - /* if the flag is true, go to the locking state directly */ - cond = SET_COND_FLAG(cond, PM_REQUEST_CHANGE); - - recv_data.pid = pid; - recv_data.cond = cond; - recv_data.timeout = timeout; - - display_state_transition_do_state_transition_by_pm_control_event(&recv_data); - - return 0; -} - -static int __pm_unlock_internal(pid_t pid, int s_bits, int flag) -{ - int cond; - - cond = get_state(s_bits); - if (cond < 0) - return cond; - - if (!display_state_transition_is_display_state_support_transition(cond)) - return -ENOTSUP; - - cond = SET_COND_REQUEST(cond, PM_REQUEST_UNLOCK); - - if (flag & PM_KEEP_TIMER) - cond = SET_COND_FLAG(cond, PM_FLAG_KEEP_TIMER); - - if (flag & PM_RESET_TIMER) - cond = SET_COND_FLAG(cond, PM_FLAG_RESET_TIMER); - - recv_data.pid = pid; - recv_data.cond = cond; - recv_data.timeout = 0; - - display_state_transition_do_state_transition_by_pm_control_event(&recv_data); - - return 0; -} - -static int __pm_change_internal(pid_t pid, int s_bits) -{ - int cond, ret; - const int display_on = LCD_NORMAL | LCD_DIM; - - cond = get_state(s_bits); - if (cond < 0) - return cond; - - ret = display_plugin_is_lcd_on_blocked(); - if (ret != LCDON_BLOCK_NONE && (cond & display_on)) { - _W("LCDON is blocked, %d.", ret); - return -ENOTSUP; - } - - if (!display_state_transition_is_display_state_support_transition(cond)) - return -ENOTSUP; - - cond = SET_COND_REQUEST(cond, PM_REQUEST_CHANGE); - - recv_data.pid = pid; - recv_data.cond = cond; - recv_data.timeout = 0; - - display_state_transition_do_state_transition_by_pm_control_event(&recv_data); - - return 0; -} - -void init_pm_internal(void *data) -{ - struct display_plugin *dp = (struct display_plugin *) data; - - dp->pm_lock_internal = __pm_lock_internal; - dp->pm_unlock_internal = __pm_unlock_internal; - dp->pm_change_internal = __pm_change_internal; -} diff --git a/src/display/poll.h b/src/display/poll.h index 086f875..262e224 100644 --- a/src/display/poll.h +++ b/src/display/poll.h @@ -134,8 +134,6 @@ enum cond_flags_e { #define RESET_TIMER_STR "resettimer" #define KEEP_TIMER_STR "keeptimer" -void init_pm_internal(void *data); - /** * @} */ diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index ee1c5f4..93bc398 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -25,8 +25,10 @@ #include "shared/device-notifier.h" #include "core/udev.h" #include "core.h" +#include "display-lock.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-state-transition.h" #include "extcon/extcon.h" #include "shared/plugin.h" @@ -60,7 +62,7 @@ static int cradle_update(const char *index, int status) int ret; _I("Cradle changed. status=%d", status); - display_plugin_pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_CRADLE, LCD_NORMAL); cradle_send_broadcast(status); ret = vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status); if (ret < 0) { @@ -69,9 +71,9 @@ static int cradle_update(const char *index, int status) } if (status == DOCK_SOUND) { - display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); } else if (status == DOCK_NONE) { - display_plugin_pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); + display_lock_request_unlock_with_option(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN); } return 0; @@ -91,7 +93,7 @@ static int display_changed(void *data) cradle = cradle_extcon_ops.status; if (cradle == DOCK_SOUND) { - display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0); _I("Sound dock is connected. Dim lock is on."); } diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index 87fcc57..ae9f96d 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -26,6 +26,7 @@ #include "poll.h" #include "display-ops.h" #include "display-plugin.h" +#include "display-state-transition.h" #include "extcon/extcon.h" #include "shared/plugin.h" @@ -96,7 +97,7 @@ static int earjack_update(const char *index, int status) earjack_send_broadcast(status); earjack_send_system_event(status); if (status != EARJACK_DISCONNECTED) { - display_plugin_pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_EARJACK, LCD_NORMAL); } old_status = status; diff --git a/src/shared/apps.c b/src/shared/apps.c index caa6155..bb3a9c9 100644 --- a/src/shared/apps.c +++ b/src/shared/apps.c @@ -23,6 +23,7 @@ #include "shared/common.h" #include "apps.h" #include "display-plugin.h" +#include "display-state-transition.h" #include "shared/bitmap.h" #define POPUP_METHOD "PopupLaunch" @@ -103,7 +104,7 @@ int launch_system_app(char *type, int num, ...) va_end(args); - display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POPUP, LCD_NORMAL); return ret; } @@ -122,7 +123,7 @@ int launch_message_post(char *type) g_variant_new("(s)", type), __cb, -1, NULL); - display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_POPUP, LCD_NORMAL); return ret; } diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 1d4c377..977697d 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -191,11 +191,11 @@ int set_datetime_action(int argc, char **argv) else pm_state = 0x4; - display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); ret = handle_date(argv[0]); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + display_lock_request_unlock_with_option(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); return ret; } @@ -218,11 +218,11 @@ int set_timezone_action(int argc, char **argv) else pm_state = 0x4; - display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0); ret = handle_timezone(argv[0]); - display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); + display_lock_request_unlock_with_option(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE); return ret; } diff --git a/src/usb-gadget/usb-gadget.c b/src/usb-gadget/usb-gadget.c index 009fa59..0ccfb25 100644 --- a/src/usb-gadget/usb-gadget.c +++ b/src/usb-gadget/usb-gadget.c @@ -23,6 +23,7 @@ #include "core/log.h" #include "core/udev.h" #include "poll.h" +#include "display-lock.h" #include "display-ops.h" #include "display-plugin.h" #include "shared/plugin.h" @@ -104,7 +105,7 @@ static int usb_connected(void) int ret; unsigned int mode = usb_state_get_selected_mode(); - display_plugin_pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); + display_lock_request_lock_with_option(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0); usb_state_set_connection(USB_CONNECTED); send_usb_state_changed_event(VCONFKEY_SYSMAN_USB_CONNECTED); @@ -129,10 +130,10 @@ static int usb_disconnected(void) ret = usb_disable(); if(ret < 0) { _E("Failed to disable USB gadget: %d", ret); - /* Important: You have to keep going to unlock display_plugin_pm_unlock_internal */ + /* Important: You have to keep going to unlock display_lock_request_unlock_with_option */ } - display_plugin_pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); + display_lock_request_unlock_with_option(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE); return ret; } diff --git a/src/usb-host/usb-host.c b/src/usb-host/usb-host.c index 68a5b8c..15d29d1 100644 --- a/src/usb-host/usb-host.c +++ b/src/usb-host/usb-host.c @@ -34,6 +34,7 @@ #include "display-ops.h" #include "display-plugin.h" #include "display-config.h" +#include "display-state-transition.h" #include "core.h" #include "dd-usbhost.h" #include "shared/plugin.h" @@ -244,7 +245,7 @@ static int add_usbhost_list(struct udev_device *dev, const char *devpath) broadcast_usbhost_signal(USB_HOST_ADDED, usbhost); if (display_on_usb_conn_changed) - display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); /* for debugging */ _I("USB HOST Added."); @@ -273,7 +274,7 @@ static int remove_usbhost_list(const char *devpath) broadcast_usbhost_signal(USB_HOST_REMOVED, usbhost); if (display_on_usb_conn_changed) - display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); + display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_USB_HOST, LCD_NORMAL); /* for debugging */ _I("USB HOST Removed."); diff --git a/tests/deviced-common-private-test/CMakeLists.txt b/tests/deviced-common-private-test/CMakeLists.txt index 212a7f3..c4262d7 100644 --- a/tests/deviced-common-private-test/CMakeLists.txt +++ b/tests/deviced-common-private-test/CMakeLists.txt @@ -14,7 +14,7 @@ PKG_CHECK_MODULES(ORIG_REQUIRED_PKGS REQUIRED SET(WRAP_FLAGS "-Wl,--wrap=dlopen") SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=access") -SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=display_plugin_pm_change_internal") +SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=display_state_transition_request_state_transition_with_option") FILE(GLOB ORIG_SRCS "${CMAKE_SOURCE_DIR}/src/shared/*.c") ADD_LIBRARY(test-shared SHARED ${ORIG_SRCS}) diff --git a/tests/deviced-common-private-test/test-mock.c b/tests/deviced-common-private-test/test-mock.c index c3eba7e..df9d7fe 100644 --- a/tests/deviced-common-private-test/test-mock.c +++ b/tests/deviced-common-private-test/test-mock.c @@ -4,6 +4,7 @@ /* FIXME: This would be replaced to plugin-api-deviced */ #include "display-plugin.h" +#include "display-state-transition.h" #include "test-main.h" #include "test-mock.h" @@ -26,7 +27,7 @@ void *__wrap_dlopen(const char *filename, int flags) return ret; } -int __wrap_display_plugin_pm_change_internal(pid_t pid, int s_bits) +int __wrap_display_state_transition_request_state_transition_with_option(pid_t pid, int s_bits) { return 0; } -- 2.7.4