From 0160d97c32b1e6ac5bad8b1da0a37a7397a9a7c8 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 26 Jul 2023 17:00:43 +0900 Subject: [PATCH] shared: Replace device notifier with syscommon notifier 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 --- plugins/iot-headed/display/key-filter.c | 8 +- plugins/iot-headless/input/input-handler.c | 8 +- plugins/mobile/battery/battery-notification.c | 2 +- plugins/mobile/display/key-filter.c | 8 +- plugins/tv/display/key-filter.c | 8 +- .../wearable/display/auto-brightness-sensorhub.c | 8 +- plugins/wearable/display/auto-brightness.c | 8 +- plugins/wearable/display/bezel.c | 2 +- plugins/wearable/display/core.c | 8 +- plugins/wearable/display/device-interface.c | 2 +- plugins/wearable/display/display-handler.c | 4 +- plugins/wearable/display/enhance.c | 4 +- plugins/wearable/display/hbm.c | 4 +- plugins/wearable/display/key-filter.c | 8 +- plugins/wearable/display/lbm.c | 2 +- plugins/wearable/display/powersaver.c | 6 +- plugins/wearable/display/swim.c | 2 +- src/battery/lowbat-handler.c | 8 +- src/battery/power-supply.c | 36 +-- src/core/delayed-init-notifier.c | 4 +- src/core/event-handler.c | 4 +- src/core/main.c | 2 +- src/core/udev.c | 8 +- src/cpu/pmqos.c | 12 +- src/display/ambient-mode.c | 4 +- src/display/display-backlight.c | 2 +- src/display/display-dbus.c | 6 +- src/display/display-lock.c | 4 +- src/display/display-misc.c | 4 +- src/display/display-panel.c | 4 +- src/display/display-signal.c | 6 +- src/display/display-state-transition.c | 2 +- src/display/display.c | 28 +-- src/display/lock-detector.c | 2 +- src/extcon/cradle.c | 4 +- src/extcon/extcon.c | 6 +- src/led/touch-key.c | 4 +- src/power/power-boot.c | 2 +- src/power/power-doze.c | 4 +- src/power/power-event-lock.c | 4 +- src/power/power-off.c | 6 +- src/power/power-suspend.c | 2 +- src/power/power.c | 6 +- src/power/power.h | 2 +- src/shared/device-notifier.c | 275 --------------------- src/shared/device-notifier.h | 28 +-- src/shared/event.c | 4 +- src/thermal/thermal.c | 4 +- src/time/time-handler.c | 2 +- src/touchscreen/sensitivity.c | 4 +- src/touchscreen/touchscreen.c | 2 +- src/tzip/tzip.c | 8 +- src/usb-gadget/usb-debug.c | 6 +- src/usb-gadget/usb-tethering.c | 6 +- src/usb-host/usb-host.c | 4 +- tests/deviced-common-private-test/CMakeLists.txt | 1 - .../test-device-notifier.c | 254 ------------------- 57 files changed, 156 insertions(+), 710 deletions(-) delete mode 100644 src/shared/device-notifier.c delete mode 100644 tests/deviced-common-private-test/test-device-notifier.c diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 2cf5f3b..8585da3 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -149,7 +149,7 @@ static void longkey_pressed(void) 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; @@ -551,7 +551,7 @@ static void update_vital_state(struct input_event *pinput) 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); } } @@ -755,8 +755,8 @@ static void __CONSTRUCTOR__ initialize(void) 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); } diff --git a/plugins/iot-headless/input/input-handler.c b/plugins/iot-headless/input/input-handler.c index f5d5a21..5249314 100644 --- a/plugins/iot-headless/input/input-handler.c +++ b/plugins/iot-headless/input/input-handler.c @@ -55,7 +55,7 @@ static gboolean level_event_detected(gpointer data) 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; } @@ -76,7 +76,7 @@ static void edge_event_detected(struct input_event_unit *ieu) 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) @@ -138,7 +138,7 @@ static void input_handler_process_key(struct timeval time, unsigned short type, /* 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); @@ -149,7 +149,7 @@ static void input_handler_process_key(struct timeval time, unsigned short type, /* 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) diff --git a/plugins/mobile/battery/battery-notification.c b/plugins/mobile/battery/battery-notification.c index ba6361e..be771f6 100644 --- a/plugins/mobile/battery/battery-notification.c +++ b/plugins/mobile/battery/battery-notification.c @@ -326,7 +326,7 @@ static gboolean health_timer_cb(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); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 17092f2..0ab4bee 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -139,7 +139,7 @@ static void longkey_pressed(void) 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; @@ -583,7 +583,7 @@ static void update_vital_state(struct input_event *pinput) 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); } } @@ -781,8 +781,8 @@ static void __CONSTRUCTOR__ initialize(void) 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); } diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index 6b0b940..29c96fd 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -148,7 +148,7 @@ static void longkey_pressed(void) 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; @@ -550,7 +550,7 @@ static void update_vital_state(struct input_event *pinput) 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); } } @@ -748,8 +748,8 @@ static void __CONSTRUCTOR__ initialize(void) 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); } diff --git a/plugins/wearable/display/auto-brightness-sensorhub.c b/plugins/wearable/display/auto-brightness-sensorhub.c index 321c32e..d8d6b0e 100644 --- a/plugins/wearable/display/auto-brightness-sensorhub.c +++ b/plugins/wearable/display/auto-brightness-sensorhub.c @@ -358,8 +358,8 @@ int prepare_level_handler(void) 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; } @@ -370,8 +370,8 @@ void exit_level_handler(void) 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) diff --git a/plugins/wearable/display/auto-brightness.c b/plugins/wearable/display/auto-brightness.c index 58ebec4..f6e33de 100644 --- a/plugins/wearable/display/auto-brightness.c +++ b/plugins/wearable/display/auto-brightness.c @@ -664,16 +664,16 @@ static void auto_brightness_init(void *data) 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 = { diff --git a/plugins/wearable/display/bezel.c b/plugins/wearable/display/bezel.c index e206aa3..ce0a02d 100644 --- a/plugins/wearable/display/bezel.c +++ b/plugins/wearable/display/bezel.c @@ -62,7 +62,7 @@ static void bezel_changed_cb(keynode_t *key_nodes, void *data) _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) diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 53a183e..4f883c1 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -296,7 +296,7 @@ static void lcd_off_procedure(enum device_flags flag) /* 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); @@ -329,7 +329,7 @@ static void lcd_off_procedure(enum device_flags flag) 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(); @@ -703,7 +703,7 @@ static int default_action(int timeout) 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)) { @@ -980,7 +980,7 @@ static void display_init(void *data) 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); diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 5e99cdc..1128f10 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -98,7 +98,7 @@ static int set_brightness(int val) 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); } diff --git a/plugins/wearable/display/display-handler.c b/plugins/wearable/display/display-handler.c index df34a70..6cd031f 100644 --- a/plugins/wearable/display/display-handler.c +++ b/plugins/wearable/display/display-handler.c @@ -95,7 +95,7 @@ static GVariant *dbus_autobrightnesschanged(GDBusConnection *conn, 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 @@ -194,7 +194,7 @@ static void display_handler_init(void *data) 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, diff --git a/plugins/wearable/display/enhance.c b/plugins/wearable/display/enhance.c index 0b4644b..2e05e41 100644 --- a/plugins/wearable/display/enhance.c +++ b/plugins/wearable/display/enhance.c @@ -112,7 +112,7 @@ static void enhance_init(void *data) 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); @@ -154,7 +154,7 @@ static void enhance_init(void *data) 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); diff --git a/plugins/wearable/display/hbm.c b/plugins/wearable/display/hbm.c index 53c9abb..acfd006 100644 --- a/plugins/wearable/display/hbm.c +++ b/plugins/wearable/display/hbm.c @@ -405,7 +405,7 @@ static void hbm_init(void *data) _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); @@ -414,7 +414,7 @@ static void hbm_init(void *data) 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 diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index 13fd03e..53e84b0 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -138,7 +138,7 @@ static void longkey_pressed(void) 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; @@ -516,7 +516,7 @@ static void update_vital_state(struct input_event *pinput) 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); } } @@ -710,8 +710,8 @@ static void __CONSTRUCTOR__ initialize(void) 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); } diff --git a/plugins/wearable/display/lbm.c b/plugins/wearable/display/lbm.c index f15adbc..bb47be1 100644 --- a/plugins/wearable/display/lbm.c +++ b/plugins/wearable/display/lbm.c @@ -128,7 +128,7 @@ static int lbm_set_brightness(int val) 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); } diff --git a/plugins/wearable/display/powersaver.c b/plugins/wearable/display/powersaver.c index 18aa2ae..b6463bc 100644 --- a/plugins/wearable/display/powersaver.c +++ b/plugins/wearable/display/powersaver.c @@ -43,7 +43,7 @@ static int set_powersaver_mode(int mode) 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); @@ -127,7 +127,7 @@ static int delayed_init_done(void *data) } _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); @@ -137,7 +137,7 @@ out: 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) diff --git a/plugins/wearable/display/swim.c b/plugins/wearable/display/swim.c index f75756d..f5f3cd1 100644 --- a/plugins/wearable/display/swim.c +++ b/plugins/wearable/display/swim.c @@ -129,7 +129,7 @@ static void swim_init(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 = { diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 9010c68..dedc659 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -546,7 +546,7 @@ static int lowbat_process(int bat_percent, void *ad) 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; } @@ -612,7 +612,7 @@ static int lowbat_monitor_init(void *data) 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); @@ -686,8 +686,8 @@ static void lowbat_init(void *data) { 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) diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c index aa842eb..5c87a1c 100644 --- a/src/battery/power-supply.c +++ b/src/battery/power-supply.c @@ -360,7 +360,7 @@ static void noti_batt_full(void) 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); @@ -372,7 +372,7 @@ static void noti_batt_full(void) _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); } } @@ -414,11 +414,11 @@ static void update_present(enum battery_noti_status status) 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) @@ -432,7 +432,7 @@ static void launch_health_popup(void) 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); @@ -466,7 +466,7 @@ static void update_health(enum battery_noti_status status) 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(); @@ -528,7 +528,7 @@ static void check_abnormal_status(void) 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); @@ -542,7 +542,7 @@ static void check_abnormal_status(void) 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); @@ -721,12 +721,12 @@ static void process_power_supply(void *data) 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"); @@ -781,9 +781,9 @@ static void process_power_supply(void *data) 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; } @@ -1326,7 +1326,7 @@ static int delayed_init_done(void *data) 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; } @@ -1504,9 +1504,9 @@ static void power_supply_init(void *data) /* 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) @@ -1521,8 +1521,8 @@ static void power_supply_exit(void *data) { 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); diff --git a/src/core/delayed-init-notifier.c b/src/core/delayed-init-notifier.c index 0de44a3..92f5470 100644 --- a/src/core/delayed-init-notifier.c +++ b/src/core/delayed-init-notifier.c @@ -67,7 +67,7 @@ static gboolean delayed_init_timer_cb(void *data) _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; } @@ -81,7 +81,7 @@ static void delayed_init_done_notifier_init(void *data) _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); diff --git a/src/core/event-handler.c b/src/core/event-handler.c index 25219bd..cdd6bfc 100644 --- a/src/core/event-handler.c +++ b/src/core/event-handler.c @@ -35,7 +35,7 @@ static GVariant *dbus_start_event_handler(GDBusConnection *conn, 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); } @@ -47,7 +47,7 @@ static GVariant *dbus_stop_event_handler(GDBusConnection *conn, 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); } diff --git a/src/core/main.c b/src/core/main.c index fbd25e8..6c4a616 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -88,7 +88,7 @@ static void deviced_dbus_name_acquired(GDBusConnection *connection, const gchar 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)"); diff --git a/src/core/udev.c b/src/core/udev.c index 6f28bba..81f3da8 100644 --- a/src/core/udev.c +++ b/src/core/udev.c @@ -286,8 +286,8 @@ static int device_change_poweroff(void *data) 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."); @@ -298,8 +298,8 @@ static void udev_init(void *data) 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 = { diff --git a/src/cpu/pmqos.c b/src/cpu/pmqos.c index 1b36a77..c832ce7 100644 --- a/src/cpu/pmqos.c +++ b/src/cpu/pmqos.c @@ -217,8 +217,8 @@ static int delayed_init_done(void *data) _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; @@ -238,15 +238,15 @@ static void pmqos_init(void *data) 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 = { diff --git a/src/display/ambient-mode.c b/src/display/ambient-mode.c index 8c99049..8b6d8f0 100644 --- a/src/display/ambient-mode.c +++ b/src/display/ambient-mode.c @@ -98,7 +98,7 @@ static void ambient_set_condition(keynode_t *key_nodes, void *data) _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); } @@ -128,7 +128,7 @@ int ambient_set_state(int on) 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; } diff --git a/src/display/display-backlight.c b/src/display/display-backlight.c index 6146300..f42aedc 100644 --- a/src/display/display-backlight.c +++ b/src/display/display-backlight.c @@ -142,7 +142,7 @@ int display_backlight_set_brightness(int brightness) 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); } diff --git a/src/display/display-dbus.c b/src/display/display-dbus.c index 7ebab24..82ebc7e 100644 --- a/src/display/display-dbus.c +++ b/src/display/display-dbus.c @@ -1451,11 +1451,11 @@ static void changestate_signal_handler(GDBusConnection *conn, 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: @@ -1479,7 +1479,7 @@ static void app_terminate_signal_handler(GDBusConnection *conn, } set_app_state(pid, APPLICATION_TERMINATED); - device_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, &pid); + syscommon_notifier_emit_notify(DEVICE_NOTIFIER_APPLICATION_TERMINATED, &pid); } /* diff --git a/src/display/display-lock.c b/src/display/display-lock.c index 87bfae6..ed2a572 100644 --- a/src/display/display-lock.c +++ b/src/display/display-lock.c @@ -640,7 +640,7 @@ static void proc_condition_lock(PMMsg *data) _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) @@ -693,7 +693,7 @@ 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 */ diff --git a/src/display/display-misc.c b/src/display/display-misc.c index 8d812fe..6505db5 100644 --- a/src/display/display-misc.c +++ b/src/display/display-misc.c @@ -132,12 +132,12 @@ static int changed_battery_health(void *data) 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) diff --git a/src/display/display-panel.c b/src/display/display-panel.c index f0cc13d..583b86e 100644 --- a/src/display/display-panel.c +++ b/src/display/display-panel.c @@ -289,7 +289,7 @@ void display_panel_lcd_off_procedure(enum device_flags flag) /* 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); @@ -307,7 +307,7 @@ void display_panel_lcd_off_procedure(enum device_flags flag) 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(); } diff --git a/src/display/display-signal.c b/src/display/display-signal.c index 40b3134..78df910 100644 --- a/src/display/display-signal.c +++ b/src/display/display-signal.c @@ -100,7 +100,7 @@ void broadcast_lcd_off_late(enum device_flags flags) 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; } @@ -142,12 +142,12 @@ static int broadcast_brightness_changed(void *data) 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) diff --git a/src/display/display-state-transition.c b/src/display/display-state-transition.c index 5cd94c7..260e0ee 100644 --- a/src/display/display-state-transition.c +++ b/src/display/display-state-transition.c @@ -477,7 +477,7 @@ int display_state_transition_do_state_action(int timeout) 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)) { diff --git a/src/display/display.c b/src/display/display.c index 2b346af..94fe277 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -523,14 +523,14 @@ static void display_init(void *data) 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(); @@ -542,7 +542,7 @@ static void display_init(void *data) 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(); @@ -662,15 +662,15 @@ static void display_exit(void *data) 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(); diff --git a/src/display/lock-detector.c b/src/display/lock-detector.c index ab46b7d..673665e 100644 --- a/src/display/lock-detector.c +++ b/src/display/lock-detector.c @@ -370,5 +370,5 @@ void pm_lock_detector_init(void) return; } - register_notifier(DEVICE_NOTIFIER_POWEROFF, pmlock_detector_poweroff_cb); + syscommon_notifier_subscribe_notify(DEVICE_NOTIFIER_POWEROFF, pmlock_detector_poweroff_cb); } diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 93bc398..45730a1 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -123,7 +123,7 @@ static void cradle_init(void *data) { 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) @@ -132,7 +132,7 @@ static void cradle_init(void *data) 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 = { diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index 2da37b4..e3e8aac 100644 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -500,7 +500,7 @@ static void extcon_deferred_init(void) } 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; } @@ -531,7 +531,7 @@ static void extcon_init(void *data) 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) @@ -540,7 +540,7 @@ 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); diff --git a/src/led/touch-key.c b/src/led/touch-key.c index 0d9d893..799abb5 100644 --- a/src/led/touch-key.c +++ b/src/led/touch-key.c @@ -258,7 +258,7 @@ static void touchled_init(void *data) 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) @@ -268,7 +268,7 @@ static void touchled_init(void *data) 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); diff --git a/src/power/power-boot.c b/src/power/power-boot.c index c8a81d1..aa10f20 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -81,7 +81,7 @@ static void delayed_init_done_received(GDBusConnection *conn, 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) diff --git a/src/power/power-doze.c b/src/power/power-doze.c index 9d400c5..d8748fb 100644 --- a/src/power/power-doze.c +++ b/src/power/power-doze.c @@ -173,7 +173,7 @@ int doze_init(void) 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); @@ -185,7 +185,7 @@ int doze_exit(void) { doze_initialized = false; - unregister_notifier(DEVICE_NOTIFIER_LCD, display_changed_cb); + syscommon_notifier_unsubscribe_notify(DEVICE_NOTIFIER_LCD, display_changed_cb); return 0; } diff --git a/src/power/power-event-lock.c b/src/power/power-event-lock.c index 15beb06..8da70cb 100644 --- a/src/power/power-event-lock.c +++ b/src/power/power-event-lock.c @@ -124,9 +124,9 @@ static void register_power_event_lock_controller(enum eventlock_type type, * 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); } diff --git a/src/power/power-off.c b/src/power/power-off.c index 56369c6..355fb03 100644 --- a/src/power/power-off.c +++ b/src/power/power-off.c @@ -266,7 +266,7 @@ static gboolean __poweroff_main(gpointer data) - 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); @@ -313,7 +313,7 @@ void poweroff_prepare(uint64_t 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(); @@ -480,7 +480,7 @@ void power_off_init(void) 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) diff --git a/src/power/power-suspend.c b/src/power/power-suspend.c index d6e41e8..410c0fb 100644 --- a/src/power/power-suspend.c +++ b/src/power/power-suspend.c @@ -408,7 +408,7 @@ static void suspend_echo_mem(void) 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) diff --git a/src/power/power.c b/src/power/power.c index 2b00c67..b33538e 100644 --- a/src/power/power.c +++ b/src/power/power.c @@ -308,7 +308,7 @@ static void post_action_sleep(void *udata) 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); } @@ -813,8 +813,8 @@ void power_state_init(void *data) 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(); diff --git a/src/power/power.h b/src/power/power.h index ea5190c..4a8af3b 100644 --- a/src/power/power.h +++ b/src/power/power.h @@ -140,7 +140,7 @@ static inline void power_request_change_state_strict(uint64_t curr, uint64_t nex 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) diff --git a/src/shared/device-notifier.c b/src/shared/device-notifier.c deleted file mode 100644 index dc4da09..0000000 --- a/src/shared/device-notifier.c +++ /dev/null @@ -1,275 +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. - */ - - -#include -#include -#include "log.h" -#include "device-notifier.h" -#include "shared/common.h" -#include - -#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); -} diff --git a/src/shared/device-notifier.h b/src/shared/device-notifier.h index 3d3c5ec..66a31c0 100644 --- a/src/shared/device-notifier.h +++ b/src/shared/device-notifier.h @@ -20,6 +20,8 @@ #ifndef __DEVICE_NOTIFIER_H__ #define __DEVICE_NOTIFIER_H__ +#include + enum device_notifier_type { DEVICE_NOTIFIER_MIN, DEVICE_NOTIFIER_DAEMON_RESTARTED = DEVICE_NOTIFIER_MIN, @@ -81,30 +83,4 @@ typedef enum _device_notifier_state { /* 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__ */ diff --git a/src/shared/event.c b/src/shared/event.c index 4915f76..0eb03d3 100644 --- a/src/shared/event.c +++ b/src/shared/event.c @@ -33,7 +33,7 @@ static gboolean event_release_wakelock(gpointer data) _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; } @@ -49,5 +49,5 @@ void event_acquire_wakelock(int eventid, int timeout) 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); } diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 386d96b..7c3313c 100644 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -85,7 +85,7 @@ static void thermal_init(void *data) { 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."); @@ -98,7 +98,7 @@ static void thermal_exit(void *data) { 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."); diff --git a/src/time/time-handler.c b/src/time/time-handler.c index 977697d..786706f 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -390,7 +390,7 @@ static void time_init(void *data) 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 = { diff --git a/src/touchscreen/sensitivity.c b/src/touchscreen/sensitivity.c index 95ddab2..2d72637 100644 --- a/src/touchscreen/sensitivity.c +++ b/src/touchscreen/sensitivity.c @@ -158,7 +158,7 @@ static int delayed_init_done(void *data) } 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; } @@ -195,7 +195,7 @@ static void sensitivity_init(void *data) 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 = { diff --git a/src/touchscreen/touchscreen.c b/src/touchscreen/touchscreen.c index 90a34cc..1d645fa 100644 --- a/src/touchscreen/touchscreen.c +++ b/src/touchscreen/touchscreen.c @@ -333,7 +333,7 @@ static void touchscreen_init(void *data) 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 = { diff --git a/src/tzip/tzip.c b/src/tzip/tzip.c index 4f0602e..51aeb0a 100644 --- a/src/tzip/tzip.c +++ b/src/tzip/tzip.c @@ -1166,8 +1166,8 @@ static void tzip_init(void *data) 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) @@ -1182,8 +1182,8 @@ static void tzip_exit(void *data) { _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(); } diff --git a/src/usb-gadget/usb-debug.c b/src/usb-gadget/usb-debug.c index 7b88ea3..6611fdf 100644 --- a/src/usb-gadget/usb-debug.c +++ b/src/usb-gadget/usb-debug.c @@ -77,7 +77,7 @@ static void usb_debug_changed(keynode_t *key, void *data) _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) @@ -106,7 +106,7 @@ void add_usb_debug_handler(void) 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); @@ -117,5 +117,5 @@ void add_usb_debug_handler(void) 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); } diff --git a/src/usb-gadget/usb-tethering.c b/src/usb-gadget/usb-tethering.c index 1b952dd..ce1b3cc 100644 --- a/src/usb-gadget/usb-tethering.c +++ b/src/usb-gadget/usb-tethering.c @@ -49,7 +49,7 @@ static void usb_tethering_changed(keynode_t *key, void *data) _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) @@ -99,12 +99,12 @@ void add_usb_tethering_handler(void) 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); } diff --git a/src/usb-host/usb-host.c b/src/usb-host/usb-host.c index 15d29d1..d60813e 100644 --- a/src/usb-host/usb-host.c +++ b/src/usb-host/usb-host.c @@ -1123,7 +1123,7 @@ static int delayed_init_done(void *data) 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; } @@ -1146,7 +1146,7 @@ static void usbhost_init(void *data) _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) { diff --git a/tests/deviced-common-private-test/CMakeLists.txt b/tests/deviced-common-private-test/CMakeLists.txt index 6e69ca8..535c231 100644 --- a/tests/deviced-common-private-test/CMakeLists.txt +++ b/tests/deviced-common-private-test/CMakeLists.txt @@ -23,7 +23,6 @@ TARGET_LINK_LIBRARIES(test-shared ${ORIG_REQUIRED_PKGS_LDFLAGS}) 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}) diff --git a/tests/deviced-common-private-test/test-device-notifier.c b/tests/deviced-common-private-test/test-device-notifier.c deleted file mode 100644 index 050e814..0000000 --- a/tests/deviced-common-private-test/test-device-notifier.c +++ /dev/null @@ -1,254 +0,0 @@ -#include -#include -#include - -#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) -- 2.7.4