Leave enum device_notifier_type and device_notifier_state_e for now.
It will be moved to plugin-api-interface to be used by both the deviced
and its plugin.
Change-Id: I11e6a275f60a0170e7854f9268459617ce563530
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
static gboolean longkey_restore_cb(void *data)
{
- device_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
longkey_restore_id = 0;
return G_SOURCE_REMOVE;
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
type = VITAL_EXIT;
- device_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
}
}
display_add_actor(&display_powerkey_actor);
display_add_actor(&display_menukey_actor);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
input_register_event_callback(check_key_filter, NULL, NULL, NULL);
}
event_acquire_wakelock(ieu->id, ieu->wakelock_duration);
if (ieu->notifier)
- device_notify(ieu->notifier, ieu->user_data);
+ syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
return G_SOURCE_REMOVE;
}
event_acquire_wakelock(ieu->id, ieu->wakelock_duration);
if (ieu->notifier)
- device_notify(ieu->notifier, ieu->user_data);
+ syscommon_notifier_emit_notify(ieu->notifier, ieu->user_data);
}
static void start_event_timer(struct input_config *ic)
/* acquire tmplock on pressing key */
if (keyvalue == KEY_PRESSED)
- device_notify(DEVICE_NOTIFIER_KEY_PRESS, (void *)(intptr_t) keycode);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_KEY_PRESS, (void *)(intptr_t) keycode);
/* process all registered event to the keycode */
ic = find_input_config(keycode);
/* release tmplock on releasing key */
if (keyvalue == KEY_RELEASED)
- device_notify(DEVICE_NOTIFIER_KEY_RELEASE, (void *)(intptr_t) keycode);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_KEY_RELEASE, (void *)(intptr_t) keycode);
}
static int input_handler_init(void *data)
return G_SOURCE_REMOVE;
CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery->health_s);
- device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery->health);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery->health);
battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
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);
static gboolean longkey_restore_cb(void *data)
{
- device_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
longkey_restore_id = 0;
return G_SOURCE_REMOVE;
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
type = VITAL_EXIT;
- device_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
}
}
display_add_actor(&display_powerkey_actor);
display_add_actor(&display_menukey_actor);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
input_register_event_callback(check_key_filter, NULL, NULL, NULL);
}
static gboolean longkey_restore_cb(void *data)
{
- device_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
longkey_restore_id = 0;
return G_SOURCE_REMOVE;
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
type = VITAL_EXIT;
- device_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
}
}
display_add_actor(&display_powerkey_actor);
display_add_actor(&display_menukey_actor);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
input_register_event_callback(check_key_filter, NULL, NULL, NULL);
}
vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
set_automatic_state_cb, NULL);
- register_notifier(DEVICE_NOTIFIER_LCD_OFF, display_off_changed);
- register_notifier(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, display_off_complete_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD_OFF, display_off_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, display_off_complete_changed);
return 0;
}
set_automatic_state_cb);
set_default_brightness();
- unregister_notifier(DEVICE_NOTIFIER_LCD_OFF, display_off_changed);
- unregister_notifier(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, display_off_complete_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD_OFF, display_off_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, display_off_complete_changed);
}
static void __CONSTRUCTOR__ initialize(void)
g_display_plugin.set_autobrightness_min = set_autobrightness_min;
g_display_plugin.reset_autobrightness_min = reset_autobrightness_min;
- register_notifier(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static void auto_brightness_exit(void *data)
{
exit_lsensor();
- unregister_notifier(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, lcd_changed_cb);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static const struct display_ops display_autobrightness_ops = {
_I("Bezel wakeup condition: %d", bezel_wakeup);
display_state_transition_request_state_transition_with_option(INTERNAL_LOCK_PM, LCD_NORMAL);
- device_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, (void *)((intptr_t)bezel_wakeup));
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, (void *)((intptr_t)bezel_wakeup));
}
static void theater_changed_cb(keynode_t *key_nodes, void *data)
/* notification */
- device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
if (lcdon_broadcast) {
broadcast_lcd_off(SIGNAL_PRE, flags);
broadcast_lcd_off_late(flags);
} else {
broadcast_lcd_off(SIGNAL_POST, flags);
- device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
}
enter_doze();
power_get_wakeup_reason(), NULL);
set_setting_pmstate(get_pm_cur_state());
pm_cur_state = get_pm_cur_state();
- device_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
}
if ((get_pm_old_state() == S_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
register_kernel_uevent_control(&sec_dsim_uevent_ops);
- register_notifier(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, display_auto_brightness_sensing);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, display_auto_brightness_sensing);
init_setting(update_setting);
init_sysfs(flags);
update_bds_brightness_record(val);
_I("set brightness %d (default:%d)", val, default_brightness);
- device_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&val);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&val);
return hal_device_display_set_brightness(val);
}
autobrt_timer = 0;
}
- device_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING, NULL);
/* When display state changes from AOD to LCDON, brightness change
* effect seems sluggish because of heavy load of jobs for turning on
int ret;
prepare_level_handler();
- register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, display_state_changed);
aod_clock_displayed = false;
ret = gdbus_signal_subscribe(NULL,
int state;
/* register notifier */
- register_notifier(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
ret = vconf_notify_key_changed(VCONF_HIGH_CONTRAST,
enhance_high_contrast_cb, NULL);
static void enhance_exit(void *data)
{
/* unregister notifier */
- unregister_notifier(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, enhance_lcd_state_changed);
vconf_ignore_key_changed(VCONF_HIGH_CONTRAST, enhance_high_contrast_cb);
vconf_ignore_key_changed(VCONF_GREYSCALE, enhance_greyscale_cb);
_E("Failed to register dbus object.");
/* register notifier */
- register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, display_state_changed);
/* double check to guarantee HBMOFF before DPMS OFF */
display_panel_register_dpms_checklist(DPMS_OFF, dpms_check_hbm_off);
static void hbm_exit(void *data)
{
/* unregister notifier */
- unregister_notifier(DEVICE_NOTIFIER_LCD, display_state_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, display_state_changed);
/*
* set default brightness
static gboolean longkey_restore_cb(void *data)
{
- device_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, (void *)NULL);
longkey_restore_id = 0;
return G_SOURCE_REMOVE;
pinput->value == KEY_RELEASED && pinput->code == KEY_MENU)) {
/* Enable all services upon receiving user input, else maintain same state */
type = VITAL_EXIT;
- device_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_VITAL_STATE, &type);
}
}
display_add_actor(&display_powerkey_actor);
display_add_actor(&display_menukey_actor);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
input_register_event_callback(check_key_filter, NULL, NULL, NULL);
}
system_brightness = val;
_I("Set brightness(LBM on) system=%d, real=%d.", val, brt);
- device_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&val);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&val);
return hal_device_display_set_brightness(brt);
}
if (mode == POWERSAVER_ENHANCED)
pmqos = true;
_D("Powersaver mode %d pmqos %d.", mode, pmqos);
- device_notify(DEVICE_NOTIFIER_ULTRAPOWERSAVING, (void *)&pmqos);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_ULTRAPOWERSAVING, (void *)&pmqos);
display_backlight_set_force_brightness(0);
set_force_lcdtimeout(0);
}
_D("Powersaver mode on, %d.", mode);
- device_notify(DEVICE_NOTIFIER_PMQOS_ULTRAPOWERSAVING, (void *)&pmqos);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_PMQOS_ULTRAPOWERSAVING, (void *)&pmqos);
ret = set_powersaver_mode(mode);
if (ret < 0)
_E("Failed to update powersaver state, %d.", ret);
static void powersaver_init(void *data)
{
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static void powersaver_exit(void *data)
if (ret <= 0)
_E("Failed to register signal handler: %d", ret);
- register_notifier(DEVICE_NOTIFIER_LONGKEY_RESTORE, swim_restore_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LONGKEY_RESTORE, swim_restore_cb);
}
static const struct device_ops swim_device_ops = {
low_bat = true;
if (low_bat_old != low_bat) {
- device_notify(DEVICE_NOTIFIER_LOWBAT, (void *)&low_bat);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LOWBAT, (void *)&low_bat);
low_bat_old = low_bat;
}
lowbat_initialized(&status);
/* it's called just this once. */
- unregister_notifier(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
/* load battery configuration file */
battery_parser_load_config(&battery_info);
{
int ret;
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWER_SUPPLY, lowbat_monitor_init);
ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret < 0)
power_supply_noti(DEVICE_NOTI_BATT_FULL, DEVICE_NOTI_OFF);
bat_full_noti = 0;
/* off the full charge state */
- device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti);
}
if (battery.charge_full && bat_full_noti == 0) {
power_supply_noti(DEVICE_NOTI_BATT_FULL, DEVICE_NOTI_ON);
_I("Block LCD.");
/* on the full charge state */
- device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti);
}
}
old_battery.present = battery.present;
if (status == DEVICE_NOTI_ON) {
battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
- device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
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);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
display_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
}
if (battery_plgn->changed_battery_cf)
launching_health_popup = true;
- device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
+ syscommon_notifier_emit_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_lock_request_unlock_with_option(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
abnormal_health_popup_timer = g_timeout_add_seconds(ABNORMAL_CHECK_TIMER_INTERVAL, health_popup_cb, NULL);
} else {
battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
- device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
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();
return;
notify_status = DEVICE_NOTI_ON;
- device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health);
if (battery_plgn->update_ovp)
battery_plgn->update_ovp(DEVICE_NOTI_ON);
return;
notify_status = DEVICE_NOTI_OFF;
- device_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_OVP, (void *)&battery.health);
if (battery_plgn->update_ovp)
battery_plgn->update_ovp(DEVICE_NOTI_OFF);
if (battery.charger_connected == 0) {
CRITICAL_LOG("Battery charger disconnected");
event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, EVT_VAL_BATTERY_CHARGER_CONNECTED);
- device_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED, NULL);
notify_charger_event(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED);
} else if (battery.charger_connected == 1) {
CRITICAL_LOG("Battery charger connected");
event_system_send(SYS_EVENT_BATTERY_CHARGER_STATUS, EVT_KEY_BATTERY_CHARGER_STATUS, EVT_VAL_BATTERY_CHARGER_DISCONNECTED);
- device_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED, NULL);
notify_charger_event(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED);
} else {
_E("Invalid charger connected");
check_abnormal_status();
- device_notify(DEVICE_NOTIFIER_POWER_SUPPLY, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_POWER_SUPPLY, NULL);
if (old_battery.charge_now != battery.charge_now) {
- device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, &battery.charge_now);
old_battery.charge_now = battery.charge_now;
}
CHARGE_MISC_EVENT_SIGNAL, battery.misc,
CHARGE_HEALTH_SIGNAL, battery.health, battery.health_s);
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
return done;
}
/* process check battery timer until booting done */
power_supply_timer_start();
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
- register_notifier(DEVICE_NOTIFIER_LCD, handle_display_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, handle_display_state_changed);
ret = gdbus_add_object(NULL, DEVICED_PATH_BATTERY, &dbus_interface);
if (ret < 0)
{
device_notifier_state_e state = DEVICE_NOTIFIER_STATE_STOP;
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- unregister_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
event_handler_state_changed((void *)&state);
_I("delayed init");
done = 1;
- device_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, (void *)&done);
+ syscommon_notifier_emit_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, (void *)&done);
return G_SOURCE_REMOVE;
}
_I("restart booting done");
return;
}
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
delayed_init_timer = g_timeout_add_seconds(DELAYED_INIT_WAIT_TIME,
delayed_init_timer_cb, NULL);
if (state != DEVICE_NOTIFIER_STATE_START) {
_D("Start event-handler.");
state = DEVICE_NOTIFIER_STATE_START;
- device_notify(DEVICE_NOTIFIER_EVENT_HANDLER, (void *)&state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_EVENT_HANDLER, (void *)&state);
}
return g_variant_new("(i)", 0);
}
if (state != DEVICE_NOTIFIER_STATE_STOP) {
_D("Stop event-handler.");
state = DEVICE_NOTIFIER_STATE_STOP;
- device_notify(DEVICE_NOTIFIER_EVENT_HANDLER, (void *)&state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_EVENT_HANDLER, (void *)&state);
}
return g_variant_new("(i)", 0);
}
if (ret == 1) {
/* Restarted: deviced was terminated */
_I("Notify relaunch.");
- device_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, &ret);
+ syscommon_notifier_emit_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, &ret);
}
_I("sd_notify(READY=1)");
static void udev_init(void *data)
{
- register_notifier(DEVICE_NOTIFIER_POWEROFF, device_change_poweroff);
- register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, device_event_handler);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWEROFF, device_change_poweroff);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, device_event_handler);
if (uevent_control_start(KERNEL, &kevent) != 0)
_E("Failed to init uevent kernel control.");
static void udev_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, device_event_handler);
- unregister_notifier(DEVICE_NOTIFIER_POWEROFF, device_change_poweroff);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, device_event_handler);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_POWEROFF, device_change_poweroff);
}
static const struct device_ops udev_device_ops = {
_I("Booting done.");
/* register notifier for each event */
- register_notifier(DEVICE_NOTIFIER_CPU_BOOST_LOWBAT, pmqos_lowbat);
- register_notifier(DEVICE_NOTIFIER_CPU_BOOST_POWEROFF, pmqos_poweroff);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_CPU_BOOST_LOWBAT, pmqos_lowbat);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_CPU_BOOST_POWEROFF, pmqos_poweroff);
out:
return done;
if (ret < 0)
_E("Failed to init dbus method: %d", ret);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static void pmqos_exit(void *data)
{
/* unregister notifier for each event */
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- unregister_notifier(DEVICE_NOTIFIER_CPU_BOOST_LOWBAT, pmqos_lowbat);
- unregister_notifier(DEVICE_NOTIFIER_CPU_BOOST_POWEROFF, pmqos_poweroff);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_CPU_BOOST_LOWBAT, pmqos_lowbat);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_CPU_BOOST_POWEROFF, pmqos_poweroff);
}
static const struct device_ops pmqos_device_ops = {
_I("Ambient mode condition is %d.", ambient_condition);
state = (ambient_condition == 0 ? 0 : 1);
- device_notify(DEVICE_NOTIFIER_DISPLAY_AMBIENT_CONDITION, (void *)&state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_AMBIENT_CONDITION, (void *)&state);
display_plugin_set_dim_state(state);
}
ambient_state = on;
- device_notify(DEVICE_NOTIFIER_DISPLAY_AMBIENT_STATE, (void *)&ambient_state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_AMBIENT_STATE, (void *)&ambient_state);
return 0;
}
brightness = brightness * max_brightness / 100;
_I("set brightness %d (default:%d)", brightness, default_brightness);
- device_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&brightness);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, (void *)&brightness);
return hal_device_display_set_brightness(brightness);
}
if (!strcmp(state, "bg")) {
_D("process(%d) was going background.", pid);
set_app_state(pid, APPLICATION_BACKGROUND);
- device_notify(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, &pid);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, &pid);
} else if (!strcmp(state, "fg")) {
_D("process(%d) was going foreground.", pid);
set_app_state(pid, APPLICATION_FOREGROUND);
- device_notify(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, &pid);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, &pid);
}
out:
}
set_app_state(pid, APPLICATION_TERMINATED);
- device_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, &pid);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, &pid);
}
/*
_SD("be requested LOCK info pname(%s), flags(%d)", pname, flags);
set_lock_time(pid, pname, state);
- device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
}
static void proc_condition_unlock(PMMsg *data)
_SD("be requested UNLOCK info pname(%s) flag(%d)", pname, flags);
set_unlock_time(pid, state);
- device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)&value);
}
/* FIXME: This function will be refactored or divided according to role */
void display_misc_register_battery_health_notifier(void)
{
- register_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, changed_battery_health);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, changed_battery_health);
}
void display_misc_unregister_battery_health_notifier(void)
{
- unregister_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, changed_battery_health);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, changed_battery_health);
}
static void print_info(int fd)
/* notification */
- device_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_OFF, NULL);
if (lcd_on_broadcasted) {
broadcast_lcd_off(SIGNAL_PRE, flags);
display_stop_dependent_device(flags);
broadcast_lcd_off(SIGNAL_POST, flags);
- device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
enter_doze();
}
if (flags & LCD_OFF_LATE_MODE) {
broadcast_lcd_off(SIGNAL_POST, late_flags);
- device_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD_OFF_COMPLETE, NULL);
} else {
late_flags = flags;
}
void display_signal_register_display_brightness_notifier(void)
{
- register_notifier(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, broadcast_brightness_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, broadcast_brightness_changed);
}
void display_signal_unregister_display_brightness_notifier(void)
{
- unregister_notifier(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, broadcast_brightness_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS, broadcast_brightness_changed);
}
static void __CONSTRUCTOR__ initialize(void)
power_get_wakeup_reason(), NULL);
set_setting_pmstate(get_pm_cur_state());
pm_cur_state = get_pm_cur_state();
- device_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_LCD, (void *)&pm_cur_state);
}
if ((get_pm_old_state() == S_NORMAL) && (get_pm_cur_state() != S_NORMAL)) {
register_kernel_uevent_control(&lcd_uevent_ops);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
- register_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
- register_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
display_signal_register_display_brightness_notifier();
display_misc_register_battery_health_notifier();
- register_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
- register_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
init_save_userlock();
if (timeout_enable)
display_initialize_display_state_timeout_from_setting();
- register_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed);
_I("input init");
ret = input_init_handler();
if (!check_default(ops))
ops->start(NORMAL_MODE);
- unregister_notifier(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed);
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- unregister_notifier(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
- unregister_notifier(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
- unregister_notifier(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_VITAL_STATE, vital_state_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_APPLICATION_BACKGROUND, display_app_background);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_APPLICATION_FOREGROUND, display_app_foreground);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, display_app_terminated);
display_misc_unregister_battery_health_notifier();
display_signal_unregister_display_brightness_notifier();
- unregister_notifier(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
- unregister_notifier(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, power_resume_from_echomem_callback);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, poweroff_triggered_callback);
display_unregister_dependent_device();
free_lock_info_list();
return;
}
- register_notifier(DEVICE_NOTIFIER_POWEROFF, pmlock_detector_poweroff_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWEROFF, pmlock_detector_poweroff_cb);
}
{
int ret;
- register_notifier(DEVICE_NOTIFIER_LCD, display_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, display_changed);
ret = gdbus_add_object(NULL, DEVICED_PATH_SYSNOTI, &dbus_interface);
if (ret < 0)
static void cradle_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, display_changed);
}
static struct extcon_ops cradle_extcon_ops = {
}
event_handler_state_changed((void *)&state);
- register_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
initialized = true;
}
if (retval < 0)
_E("Failed to init dbus method: %d", retval);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static void extcon_exit(void *data)
struct extcon_ops *dev;
device_notifier_state_e state = DEVICE_NOTIFIER_STATE_STOP;
- unregister_notifier(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_EVENT_HANDLER, event_handler_state_changed);
event_handler_state_changed((void *)&state);
vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, hardkey_duration_cb, NULL);
/* register notifier */
- register_notifier(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb);
/* update touchkey light duration right now */
if (hardkey_duration == KEYBACKLIGHT_TIME_ALWAYS_ON)
static void touchled_exit(void *data)
{
/* unregister notifier */
- unregister_notifier(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, hardkey_lcd_changed_cb);
vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, hardkey_duration_cb);
return;
}
CRITICAL_LOG("System session is ready.");
- device_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, &system_done);
+ syscommon_notifier_emit_notify_once(DEVICE_NOTIFIER_DELAYED_INIT, &system_done);
} else if (strcmp(name, SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED) == 0) {
if (user_done)
doze_level = DOZE_LEVEL_0;
- register_notifier(DEVICE_NOTIFIER_LCD, display_changed_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, display_changed_cb);
doze_initialized = true;
_D("Doze mode initialized. doze_mode: %d.", doze_mode);
{
doze_initialized = false;
- unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed_cb);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, display_changed_cb);
return 0;
}
* give a large enough number as priority to make it be at the head of notifier list.
* On the other hand, releasing lock must follow all the other notifiers, therefore
* give a small enough number as priority to make it be at the tail of notifier list. */
- notifier_id[type][0] = register_notifier_udata_priority(lock_notify,
+ notifier_id[type][0] = syscommon_notifier_subscribe_notify_udata_priority(lock_notify,
power_event_lock_callback, (void *)(intptr_t) type, NULL, 1000);
- notifier_id[type][1] = register_notifier_udata_priority(unlock_notify,
+ notifier_id[type][1] = syscommon_notifier_subscribe_notify_udata_priority(unlock_notify,
power_event_unlock_callback, (void *)(intptr_t) type, NULL, -1000);
}
- device_change_poweroff()
- uevent_control_stop()
*/
- device_notify_once(DEVICE_NOTIFIER_POWEROFF, data);
+ syscommon_notifier_emit_notify_once(DEVICE_NOTIFIER_POWEROFF, data);
poweroff_request_shutdown(state);
_W("Failed to set vconf value for power off status: %d", vconf_get_ext_errno());
power_exit_autosleep();
- device_notify_once(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, (void *)(intptr_t) vconf);
+ syscommon_notifier_emit_notify_once(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, (void *)(intptr_t) vconf);
/* Poweroff event broadcasting */
system_shutdown_send_system_event();
add_delayed_init_done_handler(NULL);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
ret_val = config_parse(POWER_CONF_FILE, load_config, NULL);
if (ret_val < 0)
static void resume_echo_mem(void)
{
- device_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM, NULL);
}
static void suspend_autosleep(void)
static void pre_action_poweroff(void *data)
{
// do not transition anymore after poweroff
- unregister_notifier(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
poweroff_prepare(current);
}
if (ret < 0)
_W("Failed to load '%s'(%d)", POWER_CONF_FILE, ret);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_callback);
- register_notifier(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_callback);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
power_dbus_init();
power_off_init();
struct trans_info ti = { curr, next, reason, udata };
GList l = { &ti, NULL, NULL };
- device_notify(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, &l);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, &l);
}
static inline void power_request_change_state(uint64_t next, int reason)
+++ /dev/null
-/*
- * 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.
- */
-
-
-#include <glib.h>
-#include <errno.h>
-#include "log.h"
-#include "device-notifier.h"
-#include "shared/common.h"
-#include <libsyscommon/list.h>
-
-#define __stringify_1(x...) #x
-#define __stringify(x...) __stringify_1(x)
-
-struct device_notifier {
- int id;
- int priority; /* descending order */
- bool deleted;
-
- enum device_notifier_type type;
- int (*func)(void *data);
-
- int (*func_udata)(void *data, void *user_data);
- void (*destroyer)(void *user_data);
- void *user_data;
-};
-
-static GList *device_notifier_list;
-static guint idl;
-
-#define FIND_NOTIFIER(a, b, d, e, f) \
- SYS_G_LIST_FOREACH(a, b, d) \
- if (e == d->e && f == (d->f) && !d->deleted)
-
-#define NOTIFY_STR(x) [(x)] = __stringify((x))
-
-static const char *device_notifier_type_str[DEVICE_NOTIFIER_MAX] = {
- NOTIFY_STR(DEVICE_NOTIFIER_DAEMON_RESTARTED),
- NOTIFY_STR(DEVICE_NOTIFIER_DELAYED_INIT),
- NOTIFY_STR(DEVICE_NOTIFIER_LCD),
- NOTIFY_STR(DEVICE_NOTIFIER_LCD_OFF),
- NOTIFY_STR(DEVICE_NOTIFIER_LCD_OFF_COMPLETE),
- NOTIFY_STR(DEVICE_NOTIFIER_LCD_AUTOBRT_SENSING),
- NOTIFY_STR(DEVICE_NOTIFIER_LOWBAT),
- NOTIFY_STR(DEVICE_NOTIFIER_FULLBAT),
- NOTIFY_STR(DEVICE_NOTIFIER_POWER_SUPPLY),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_HEALTH),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_PRESENT),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_OVP),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_CHARGING),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_CHARGER_CONNECTED),
- NOTIFY_STR(DEVICE_NOTIFIER_BATTERY_CHARGER_DISCONNECTED),
- NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_AMBIENT_CONDITION),
- NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_AMBIENT_STATE),
- NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_LOCK),
- NOTIFY_STR(DEVICE_NOTIFIER_POWER_RESUME_FROM_ECHO_MEM),
- NOTIFY_STR(DEVICE_NOTIFIER_POWEROFF_TRIGGERED),
- NOTIFY_STR(DEVICE_NOTIFIER_POWEROFF),
- NOTIFY_STR(DEVICE_NOTIFIER_APPLICATION_BACKGROUND),
- NOTIFY_STR(DEVICE_NOTIFIER_APPLICATION_FOREGROUND),
- NOTIFY_STR(DEVICE_NOTIFIER_APPLICATION_TERMINATED),
- NOTIFY_STR(DEVICE_NOTIFIER_USB_DEBUG_MODE),
- NOTIFY_STR(DEVICE_NOTIFIER_USB_TETHERING_MODE),
- NOTIFY_STR(DEVICE_NOTIFIER_EVENT_HANDLER),
- NOTIFY_STR(DEVICE_NOTIFIER_CPU_BOOST_LOWBAT),
- NOTIFY_STR(DEVICE_NOTIFIER_CPU_BOOST_POWEROFF),
- NOTIFY_STR(DEVICE_NOTIFIER_PMQOS),
- NOTIFY_STR(DEVICE_NOTIFIER_PMQOS_ULTRAPOWERSAVING),
- NOTIFY_STR(DEVICE_NOTIFIER_PMQOS_POWERSAVING),
- NOTIFY_STR(DEVICE_NOTIFIER_COOL_DOWN),
- NOTIFY_STR(DEVICE_NOTIFIER_VITAL_STATE),
- NOTIFY_STR(DEVICE_NOTIFIER_LONGKEY_RESTORE),
- NOTIFY_STR(DEVICE_NOTIFIER_UPSM),
- NOTIFY_STR(DEVICE_NOTIFIER_UPSM_OFF),
- NOTIFY_STR(DEVICE_NOTIFIER_BEZEL_WAKEUP),
- NOTIFY_STR(DEVICE_NOTIFIER_DISPLAY_BRIGHTNESS),
- NOTIFY_STR(DEVICE_NOTIFIER_ULTRAPOWERSAVING),
- NOTIFY_STR(DEVICE_NOTIFIER_KEY_PRESS),
- NOTIFY_STR(DEVICE_NOTIFIER_KEY_RELEASE),
- NOTIFY_STR(DEVICE_NOTIFIER_EVENT_ACQUIRE_WAKELOCK),
- NOTIFY_STR(DEVICE_NOTIFIER_EVENT_RELEASE_WAKELOCK),
-
- /* Purpose of calling methods of different modules
- * Use prefix DEVICE_NOTIFIER_REQUEST */
- NOTIFY_STR(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE),
-};
-
-static gint compare_priority(gconstpointer a, gconstpointer b)
-{
- /* descending order */
- return ((const struct device_notifier *)b)->priority - ((const struct device_notifier *)a)->priority + 1;
-}
-
-int __register_notifier(enum device_notifier_type type, notify_cb func, int priority, const char *caller)
-{
- GList *n;
- struct device_notifier *notifier;
-
- if (type < DEVICE_NOTIFIER_MIN || type >= DEVICE_NOTIFIER_MAX)
- return -EINVAL;
-
- _I("%s, %p by %s", device_notifier_type_str[type], func, caller);
-
- if (!func) {
- _E("invalid func address! by %s", caller);
- return -EINVAL;
- }
-
- FIND_NOTIFIER(device_notifier_list, n, notifier, type, func) {
- _E("function is already registered! [%s, %p] by %s",
- device_notifier_type_str[type], func, caller);
- return -EINVAL;
- }
-
- notifier = calloc(1, sizeof(struct device_notifier));
- if (!notifier) {
- _E("Fail to malloc for %s notifier! by %s", device_notifier_type_str[type], caller);
- return -ENOMEM;
- }
-
- notifier->type = type;
- notifier->priority = priority;
- notifier->func = func;
-
- device_notifier_list = g_list_insert_sorted(device_notifier_list, notifier, compare_priority);
-
- return 0;
-}
-
-int __register_notifier_udata(enum device_notifier_type type,
- notify_cb_udata func_udata, void *user_data,
- destroy_cb_udata func_destroy_udata, int priority, const char *caller)
-{
- struct device_notifier *notifier;
- static int id = 1;
-
- if (type < DEVICE_NOTIFIER_MIN || type >= DEVICE_NOTIFIER_MAX)
- return -EINVAL;
-
- _I("%s, %p by %s", device_notifier_type_str[type], func_udata, caller);
-
- if (!func_udata) {
- _E("invalid func address! by %s", caller);
- return -EINVAL;
- }
-
- notifier = calloc(1, sizeof(struct device_notifier));
- if (!notifier) {
- _E("Fail to malloc for %s notifier! by %s", device_notifier_type_str[type], caller);
- return -ENOMEM;
- }
-
- notifier->id = id;
- notifier->priority = priority;
- notifier->type = type;
- notifier->func_udata = func_udata;
- notifier->user_data = user_data;
- notifier->destroyer = func_destroy_udata;
-
- device_notifier_list = g_list_insert_sorted(device_notifier_list, notifier, compare_priority);
-
- ++id;
-
- return notifier->id;
-}
-
-int __unregister_notifier(enum device_notifier_type type, notify_cb func, const char *caller)
-{
- GList *n;
- struct device_notifier *notifier;
-
- if (type < DEVICE_NOTIFIER_MIN || type >= DEVICE_NOTIFIER_MAX)
- return -EINVAL;
-
- if (!func) {
- _E("invalid func address of %s! by %s", device_notifier_type_str[type], caller);
- return -EINVAL;
- }
-
- FIND_NOTIFIER(device_notifier_list, n, notifier, type, func) {
- _I("[%s, %p] by %s", device_notifier_type_str[type], func, caller);
- notifier->deleted = true;
- }
-
- return 0;
-}
-
-int __unregister_notifier_udata(int id, const char *caller)
-{
- GList *n;
- struct device_notifier *notifier;
-
- SYS_G_LIST_FOREACH(device_notifier_list, n, notifier) {
- if (notifier->id == id) {
- if (notifier->destroyer)
- notifier->destroyer(notifier->user_data);
- notifier->deleted = true;
- }
- }
-
- return 0;
-}
-
-static gboolean delete_unused_notifier_cb(void *data)
-{
- GList *n;
- GList *next;
- struct device_notifier *notifier;
-
- SYS_G_LIST_FOREACH_SAFE(device_notifier_list, n, next, notifier) {
- if (notifier->deleted) {
- SYS_G_LIST_REMOVE_LIST(device_notifier_list, n);
- free(notifier);
- }
- }
-
- idl = 0;
- return G_SOURCE_REMOVE;
-}
-
-void device_notify(enum device_notifier_type type, void *data)
-{
- GList *n;
- struct device_notifier *notifier;
-
- SYS_G_LIST_FOREACH(device_notifier_list, n, notifier) {
- if (!notifier->deleted && type == notifier->type) {
- if (notifier->func)
- notifier->func(data);
- else if (notifier->func_udata)
- notifier->func_udata(data, notifier->user_data);
- }
- }
-
- if (!idl)
- idl = g_idle_add(delete_unused_notifier_cb, NULL);
-}
-
-void device_notify_once(enum device_notifier_type type, void *data)
-{
- GList *n;
- struct device_notifier *notifier;
-
- SYS_G_LIST_FOREACH(device_notifier_list, n, notifier) {
- if (!notifier->deleted && type == notifier->type) {
- if (notifier->func) {
- notifier->func(data);
- } else if (notifier->func_udata) {
- notifier->func_udata(data, notifier->user_data);
- if (notifier->destroyer)
- notifier->destroyer(notifier->user_data);
- }
-
- notifier->deleted = true;
- }
- }
-
- if (!idl)
- idl = g_idle_add(delete_unused_notifier_cb, NULL);
-}
#ifndef __DEVICE_NOTIFIER_H__
#define __DEVICE_NOTIFIER_H__
+#include <libsyscommon/notifier.h>
+
enum device_notifier_type {
DEVICE_NOTIFIER_MIN,
DEVICE_NOTIFIER_DAEMON_RESTARTED = DEVICE_NOTIFIER_MIN,
/* add more states here */
} device_notifier_state_e;
-typedef int (*notify_cb)(void *data);
-typedef int (*notify_cb_udata)(void *data, void *user_data);
-typedef void (*destroy_cb_udata)(void *user_data);
-/*
- * This is for internal callback method.
- */
-int __register_notifier(enum device_notifier_type type, notify_cb func, int priority, const char *caller);
-#define register_notifier(type, func) __register_notifier(type, func, 0, __func__)
-#define register_notifier_priority(type, func, prio) __register_notifier(type, func, prio, __func__)
-
-int __unregister_notifier(enum device_notifier_type type, notify_cb func, const char *caller);
-#define unregister_notifier(type, func) __unregister_notifier(type, func, __func__)
-
-int __register_notifier_udata(enum device_notifier_type type, notify_cb_udata func,
- void *user_data, destroy_cb_udata func_destroy, int priority, const char *caller);
-#define register_notifier_udata(type, func, user_data, func_destroy) \
- __register_notifier_udata(type, func, user_data, func_destroy, 0, __func__)
-#define register_notifier_udata_priority(type, func, user_data, func_destroy, prio) \
- __register_notifier_udata(type, func, user_data, func_destroy, prio, __func__)
-
-int __unregister_notifier_udata(int id, const char *caller);
-#define unregister_notifier_udata(id) __unregister_notifier_udata(id, __func__)
-
-void device_notify(enum device_notifier_type type, void *value);
-void device_notify_once(enum device_notifier_type status, void *data);
-
#endif /* __DEVICE_NOTIFIER_H__ */
_D("Decreased counter=%d, eventid=%d", wakelock_counter, eventid);
if (wakelock_counter == 0)
- device_notify(DEVICE_NOTIFIER_EVENT_RELEASE_WAKELOCK, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_EVENT_RELEASE_WAKELOCK, NULL);
return G_SOURCE_REMOVE;
}
g_timeout_add_seconds(timeout, event_release_wakelock, (gpointer)(intptr_t) eventid);
if (wakelock_counter == 1)
- device_notify(DEVICE_NOTIFIER_EVENT_ACQUIRE_WAKELOCK, NULL);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_EVENT_ACQUIRE_WAKELOCK, NULL);
}
{
int ret;
- ret = register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ ret = syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
if (ret < 0)
_E("Failed to register booting done notifier.");
{
int ret;
- ret = unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ ret = syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
if (ret < 0)
_E("Failed to unregister booting done notifier.");
if (timerfd_check_start() == -1)
_E("Failed system time change detector init.");
- register_notifier(DEVICE_NOTIFIER_LCD, time_lcd_changed_cb);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_LCD, time_lcd_changed_cb);
}
static const struct device_ops time_device_ops = {
}
ret = hal_device_touchscreen_glove_mode_set_state(TOUCHSENSITIVITY_GLOVE_MODE_ON);
_I("Change auto touch sensitivity enable: %s", ret ? "fail" : "set");
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
out:
return done;
}
if (ret <= 0)
_E("Failed to register signal handler: %d", ret);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static const struct device_ops sensitivity_device_ops = {
if (ret < 0)
_E("Failed to init dbus method. (%d)", ret);
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
}
static const struct device_ops touchscreen_device_ops = {
tzip_lock_init();
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- register_notifier(DEVICE_NOTIFIER_POWEROFF, tzip_poweroff);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWEROFF, tzip_poweroff);
ret = gdbus_add_object(NULL, DEVICED_PATH_TZIP, &dbus_interface);
if (ret < 0)
{
_D("tzip_exit");
tzip_server_exit();
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
- unregister_notifier(DEVICE_NOTIFIER_POWEROFF, tzip_poweroff);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_POWEROFF, tzip_poweroff);
tzip_lock_deinit();
}
_I("USB debug mode is changed to %s.", mode ? "ON" : "OFF");
- device_notify(DEVICE_NOTIFIER_USB_DEBUG_MODE, (void *)(intptr_t) mode);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_USB_DEBUG_MODE, (void *)(intptr_t) mode);
}
static int usb_debug_mode_changed(void *on)
usb_debug_changed, NULL) != VCONF_OK)
_E("Failed to add USB debug handler.");
- register_notifier(DEVICE_NOTIFIER_USB_DEBUG_MODE, usb_debug_mode_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_USB_DEBUG_MODE, usb_debug_mode_changed);
if (vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &state) == VCONF_OK)
debug_state = (state == 0 ? false : true);
void remove_usb_debug_handler(void)
{
vconf_ignore_key_changed(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, usb_debug_changed);
- unregister_notifier(DEVICE_NOTIFIER_USB_DEBUG_MODE, usb_debug_mode_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_USB_DEBUG_MODE, usb_debug_mode_changed);
}
_I("USB tethering mode is changed to %s.", curr ? "ON" : "OFF");
- device_notify(DEVICE_NOTIFIER_USB_TETHERING_MODE, (void *)curr);
+ syscommon_notifier_emit_notify(DEVICE_NOTIFIER_USB_TETHERING_MODE, (void *)curr);
}
static int usb_tethering_mode_changed(void *on)
if (vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, usb_tethering_changed, NULL) != VCONF_OK)
_E("Failed to add USB tethering handler.");
- register_notifier(DEVICE_NOTIFIER_USB_TETHERING_MODE, usb_tethering_mode_changed);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_USB_TETHERING_MODE, usb_tethering_mode_changed);
}
void remove_usb_tethering_handler(void)
{
vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, usb_tethering_changed);
- unregister_notifier(DEVICE_NOTIFIER_USB_TETHERING_MODE, usb_tethering_mode_changed);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_USB_TETHERING_MODE, usb_tethering_mode_changed);
}
usbhost_init_from_udev_enumerate();
/* unregister booting done notifier */
- unregister_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
return 0;
}
_E("Failed to register dbus interface and method: %d", ret);
/* register notifier */
- register_notifier(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
+ syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_DELAYED_INIT, delayed_init_done);
ret = asprintf(&POLICY_FILEPATH, "%s/%s", ROOTPATH, POLICY_FILENAME);
if (ret < 0) {
PKG_CHECK_MODULES(TEST_REQUIRED_PKGS REQUIRED cmocka)
-LIST(APPEND TEST_DRIVERS test-device-notifier.c)
LIST(APPEND TEST_DRIVERS test-plugin.c)
ADD_EXECUTABLE(test-main test-main.c test-mock.c ${TEST_DRIVERS})
+++ /dev/null
-#include <stdint.h>
-#include <errno.h>
-#include <shared/device-notifier.h>
-
-#include "test-main.h"
-
-#define INT_MAX ((~0) >> 1)
-
-static int notify_callback(void *data)
-{
- check_expected(data);
-
- return 0;
-}
-
-static int notify_callback_udata(void *data, void *udata)
-{
- check_expected(data);
- check_expected(udata);
-
- return 0;
-}
-
-static void destroy_callback_udata(void *udata)
-{
- check_expected(udata);
-}
-
-static void test_device_notify_n(void **state)
-{
- int retval;
-
- retval = register_notifier(DEVICE_NOTIFIER_MAX, NULL);
- assert_int_equal(retval, -EINVAL);
-
- retval = register_notifier_udata(DEVICE_NOTIFIER_MAX, NULL, NULL, NULL);
- assert_int_equal(retval, -EINVAL);
-}
-
-static void test_device_notify_p1(void **state)
-{
- int retval;
-
- retval = register_notifier(DEVICE_NOTIFIER_LCD, notify_callback);
- assert_int_equal(retval, 0);
- expect_value(notify_callback, data, (void *)(intptr_t) 0x3f3f3f3f);
-
- device_notify(DEVICE_NOTIFIER_LCD, (void *)(intptr_t) 0x3f3f3f3f);
-}
-
-static void test_device_notify_p2(void **state)
-{
- int retval;
- int notify_data;
- const int udata2 = 0xaeaeaeae;
- const int udata3 = 0x99997777;
-
- notify_data = 0x12456321;
-
- /* 1st notifier */
- retval = register_notifier(DEVICE_NOTIFIER_PMQOS, notify_callback);
- assert_int_equal(retval, 0);
-
- /* 2nd notifier */
- retval = register_notifier_udata(DEVICE_NOTIFIER_PMQOS, notify_callback_udata, (void *)(intptr_t) udata2, NULL);
- assert_in_range(retval, 1, INT_MAX);
-
- /* expect invocation of 1st callback and check parameter */
- expect_value(notify_callback, data, (void *)(intptr_t) notify_data);
- /* expect invocation of 2nd callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata,(void *)(intptr_t) udata2);
-
- device_notify(DEVICE_NOTIFIER_PMQOS, (void *)(intptr_t) notify_data);
-
- notify_data = 0x888899dd;
-
- /* 3rd notifier */
- retval = register_notifier_udata(DEVICE_NOTIFIER_PMQOS, notify_callback_udata, (void *)(intptr_t) udata3, NULL);
- assert_in_range(retval, 1, INT_MAX);
-
- /* expect invocation of 1st callback and check parameter */
- expect_value(notify_callback, data, (void *)(intptr_t) notify_data);
- /* expect invocation of 2nd callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2);
- /* expect invocation of 3rd callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata3);
-
- device_notify(DEVICE_NOTIFIER_PMQOS, (void *)(intptr_t) notify_data);
-}
-
-static void test_device_notify_p3(void **state)
-{
- int notify_data;
- int id1, id2;
- const int udata1 = 0x41a41a41;
- const int udata2 = 0x77777777;
-
- /* first run */
- notify_data = 0x8575ddff;
-
- /* 1st notifier */
- id1 = register_notifier_udata(DEVICE_NOTIFIER_POWEROFF, notify_callback_udata, (void *)(intptr_t) udata1, NULL);
- assert_in_range(id1, 1, INT_MAX);
-
- /* 2nd notifier */
- id2 = register_notifier_udata(DEVICE_NOTIFIER_POWEROFF, notify_callback_udata, (void *)(intptr_t) udata2, NULL);
- assert_in_range(id2, 1, INT_MAX);
-
- /* expect invocation of 1st callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata1);
- /* expect invocation of 2nd callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2);
-
- device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)(intptr_t) notify_data);
-
- /* second run. at this time device_notify() after unregistering 1st notifier */
- notify_data = 0x345;
-
- unregister_notifier_udata(id1);
-
- /* only expect invocation of 2nd callback and check parameter */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2);
-
- device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)(intptr_t) notify_data);
-}
-
-static void test_device_notify_once_p(void **state)
-{
- int retval;
-
- retval = register_notifier(DEVICE_NOTIFIER_LCD_OFF, notify_callback);
- assert_int_equal(retval, 0);
-
- expect_value(notify_callback, data, (void *)(intptr_t) 0xabcdabcd);
- device_notify_once(DEVICE_NOTIFIER_LCD_OFF, (void *)(intptr_t) 0xabcdabcd);
-
- /* Don't add expect_value() for callback at this time.
- * Therefore if the callback is invoked, check_expected() returns error */
- device_notify(DEVICE_NOTIFIER_LCD_OFF, (void *)(intptr_t) 0xabcdabcd);
-
- retval = register_notifier_udata(DEVICE_NOTIFIER_BATTERY_CHARGING, notify_callback_udata, (void *)(intptr_t) 0xfefefefe, NULL);
- assert_in_range(retval, 1, INT_MAX);
-
- expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x34343434);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0xfefefefe);
- device_notify_once(DEVICE_NOTIFIER_BATTERY_CHARGING, (void *)(intptr_t) 0x34343434);
-
- /* Don't add expect_value() for callback at this time.
- * Therefore if the callback is invoked, check_expected() returns error */
- device_notify(DEVICE_NOTIFIER_BATTERY_CHARGING, (void *)(intptr_t) 0x34343434);
-}
-
-static void test_destroy_callback_p1(void **state)
-{
- int id;
-
- id = register_notifier_udata(DEVICE_NOTIFIER_LOWBAT, notify_callback_udata,
- (void *)(intptr_t) 0x4848, destroy_callback_udata);
- assert_in_range(id, 1, INT_MAX);
-
- expect_value(destroy_callback_udata, udata, (void *)(intptr_t) 0x4848);
-
- unregister_notifier_udata(id);
-}
-
-static void test_destroy_callback_p2(void **state)
-{
- int id;
-
- id = register_notifier_udata(DEVICE_NOTIFIER_LOWBAT, notify_callback_udata,
- (void *)(intptr_t) 0x1177, destroy_callback_udata);
- assert_in_range(id, 1, INT_MAX);
-
- expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x9a9a9a9a);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x1177);
- expect_value(destroy_callback_udata, udata, (void *)(intptr_t) 0x1177);
-
- device_notify_once(DEVICE_NOTIFIER_LOWBAT, (void *)(intptr_t) 0x9a9a9a9a);
-}
-
-static void test_destroy_callback_p3(void **state)
-{
- int retval;
-
- retval = register_notifier(DEVICE_NOTIFIER_UPSM, notify_callback);
- assert_int_equal(retval, 0);
- expect_value(notify_callback, data, (void *)(intptr_t) 0x3f3f3f3f);
- device_notify(DEVICE_NOTIFIER_UPSM, (void *)(intptr_t) 0x3f3f3f3f);
-
- /* notify_callback() should not be invoked */
- unregister_notifier(DEVICE_NOTIFIER_UPSM, notify_callback);
- device_notify(DEVICE_NOTIFIER_UPSM, (void *)(intptr_t) 0x34ab34ab);
-
- /* if a notifier have successfully been deleted,
- * re-registering the notifier must be successful */
- retval = register_notifier(DEVICE_NOTIFIER_UPSM, notify_callback);
- assert_int_equal(retval, 0);
-
- expect_value(notify_callback, data, (void *)(intptr_t) 0x7878444);
- device_notify(DEVICE_NOTIFIER_UPSM, (void *)(intptr_t) 0x7878444);
-}
-
-static void test_device_notify_priority_p1(void **state)
-{
- int id1, id2, id3;
-
- id1 = register_notifier_udata_priority(DEVICE_NOTIFIER_DISPLAY_LOCK, notify_callback_udata,
- (void *)(intptr_t) 0x11111111, NULL, -300);
- assert_in_range(id1, 1, INT_MAX);
-
- id2 = register_notifier_udata_priority(DEVICE_NOTIFIER_DISPLAY_LOCK, notify_callback_udata,
- (void *)(intptr_t) 0x22222222, NULL, 500);
- assert_in_range(id2, 1, INT_MAX);
-
- id3 = register_notifier_udata_priority(DEVICE_NOTIFIER_DISPLAY_LOCK, notify_callback_udata,
- (void *)(intptr_t) 0x33333333, NULL, -300);
- assert_in_range(id3, 1, INT_MAX);
-
- /* id2 will be invoked first */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x22222222);
- /* id1, id3 invocation follows it,
- * and those are invoked in the order in which they were registered */
- expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x11111111);
- expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234);
- expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x33333333);
-
- device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)(intptr_t)0x1234);
-}
-
-static int run_device_notifier_test(void)
-{
- static const struct CMUnitTest testsuite[] = {
- cmocka_unit_test(test_device_notify_n),
- cmocka_unit_test(test_device_notify_p1),
- cmocka_unit_test(test_device_notify_p2),
- cmocka_unit_test(test_device_notify_p3),
- cmocka_unit_test(test_device_notify_once_p),
- cmocka_unit_test(test_destroy_callback_p1),
- cmocka_unit_test(test_destroy_callback_p2),
- cmocka_unit_test(test_destroy_callback_p3),
- cmocka_unit_test(test_device_notify_priority_p1),
- };
-
- return cmocka_run_group_tests(testsuite, NULL, NULL);
-}
-ADD_TEST_FUNCTION(run_device_notifier_test)