Plugin architecture - mobile profile 41/192141/3
authorHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 30 Oct 2018 12:50:36 +0000 (21:50 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 31 Oct 2018 01:01:55 +0000 (10:01 +0900)
Change-Id: I65811fb7958cb4865c5e5c616953ca9267bbfd76
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
40 files changed:
CMakeLists.txt
conf/profile-wearable.conf [moved from conf/display-profile-wearable.conf with 100% similarity]
packaging/deviced.spec
plugins/mobile/display/CMakeLists.txt [new file with mode: 0644]
plugins/mobile/display/ambient-mode.c [moved from src/display/ambient-mode.c with 93% similarity]
plugins/mobile/display/auto-brightness.c [moved from src/display/auto-brightness.c with 100% similarity]
plugins/mobile/display/core.c [moved from src/display/core.c with 98% similarity]
plugins/mobile/display/device-interface.c [moved from src/display/device-interface.c with 100% similarity]
plugins/mobile/display/display-actor.c [moved from src/display/display-actor.c with 100% similarity]
plugins/mobile/display/display-dbus.c [moved from src/display/display-dbus.c with 96% similarity]
plugins/mobile/display/display-ops.c [moved from src/display/display-ops.c with 100% similarity]
plugins/mobile/display/dpms-wayland-none.c [moved from src/display/dpms-wayland-none.c with 100% similarity]
plugins/mobile/display/input.c [moved from src/display/input.c with 100% similarity]
plugins/mobile/display/key-filter.c [moved from src/display/key-filter.c with 97% similarity]
plugins/mobile/display/lock-detector.c [moved from src/display/lock-detector.c with 100% similarity]
plugins/mobile/display/poll.c [moved from src/display/poll.c with 87% similarity]
plugins/mobile/display/setting.c [moved from src/display/setting.c with 91% similarity]
plugins/tv/display/CMakeLists.txt [moved from plugins/display/CMakeLists.txt with 100% similarity]
plugins/tv/display/state-tv.c [moved from plugins/display/state-tv.c with 99% similarity]
src/apps/apps.c
src/battery/battery-time.c
src/battery/battery.h
src/battery/lowbat-handler.c
src/battery/power-supply.c
src/core/main.c
src/display/core.h
src/display/display-ops.h
src/display/poll.h
src/display/setting.h
src/extcon/cradle.c
src/extcon/earjack.c
src/extcon/hdmi.c
src/led/touch-key.c
src/power/boot.c
src/power/power-handler.c
src/shared/plugin.c
src/shared/plugin.h
src/time/time-handler.c
src/usb/usb.c
src/usbhost/usb-host.c

index 4632a10..a59ca96 100755 (executable)
@@ -234,8 +234,8 @@ ENDIF()
 
 IF(DISPLAY_MODULE STREQUAL on)
        INSTALL_CONF(conf display)
-       INSTALL_CONF(conf display-profile-wearable)
        INSTALL_CONF(conf display-enable-timer)
+       INSTALL_CONF(conf profile-wearable)
 ENDIF()
 
 IF(POWER_MODULE STREQUAL on)
@@ -278,4 +278,5 @@ IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on)
        ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon)
 ENDIF()
 ADD_SUBDIRECTORY(src/auto-test)
-ADD_SUBDIRECTORY(plugins/display)
+ADD_SUBDIRECTORY(plugins/mobile/display)
+#ADD_SUBDIRECTORY(plugins/display/tv)
index 17848f2..c6e1f17 100755 (executable)
@@ -82,14 +82,6 @@ Group:      System/Utilities
 Deviced helper programs.
 This package can be installed optional for auto dbus test.
 
-%package config-profile-wearable
-Summary:    Configuration files for wearable profile
-Group:      System/Management
-BuildArch:  noarch
-
-%description config-profile-wearable
-This package is used for wearable profile
-
 %package config-enable-display-timer
 Summary:    Configuration files for display
 Group:      System/Management
@@ -98,13 +90,29 @@ BuildArch:  noarch
 %description config-enable-display-timer
 This package is used for enabling a display timer.
 
-%package plugin-profile-tv
-Summary:    Plugin libraries for TV profile
+%package plugin-profile-mobile
+Summary:    Plugin libraries for mobile devices
 Group:      System/Management
 Requires:   %{name} = %{version}-%{release}
 
-%description plugin-profile-tv
-Plugin libraries for TV profile
+%description plugin-profile-mobile
+Plugin libraries for mobile devices
+
+%package plugin-profile-wearable
+Summary:    Plugin libraries for wearable devices
+Group:      System/Management
+Requires:   %{name} = %{version}-%{release}
+
+%description plugin-profile-wearable
+Plugin libraries for wearable devices
+
+#%package plugin-display-tv
+#Summary:    Plugin libraries for TV display devices
+#Group:      System/Management
+#Requires:   %{name} = %{version}-%{release}
+
+#%description plugin-display-tv
+#Plugin libraries for TV display devices
 
 %prep
 %setup -q
@@ -187,19 +195,22 @@ fi
 
 %postun -n libdeviced -p /sbin/ldconfig
 
-%post config-profile-wearable
-cat %{_sysconfdir}/deviced/display-profile-wearable.conf >> %{_sysconfdir}/deviced/display.conf
-rm -rf %{_sysconfdir}/deviced/display-profile-wearable.conf
-
 %post config-enable-display-timer
 cat %{_sysconfdir}/deviced/display-enable-timer.conf >> %{_sysconfdir}/deviced/display.conf
 rm -rf %{_sysconfdir}/deviced/display-enable-timer.conf
 
-%post plugin-profile-tv
+%post plugin-profile-mobile
 mkdir -p %{_libdir}/deviced
-mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so
+mv %{_libdir}/mobile-display.so %{_libdir}/deviced/display.so
+
+%post plugin-profile-wearable
+cat %{_sysconfdir}/deviced/profile-wearable.conf >> %{_sysconfdir}/deviced/wearable.conf
+rm -rf %{_sysconfdir}/deviced/profile-wearable.conf
+#mv %{_libdir}/mobile-wearable.so %{_libdir}/deviced/display.so
 
-%postun plugin-profile-tv
+#%post plugin-display-tv
+#mkdir -p %{_libdir}/deviced
+#mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so
 
 %files
 %manifest %{name}.manifest
@@ -252,18 +263,30 @@ mv %{_libdir}/display-tv.so %{_libdir}/deviced/display.so
 %{_bindir}/deviced-auto-test
 %config %{_sysconfdir}/deviced/auto-test.conf
 
-%files config-profile-wearable
-%manifest deviced.manifest
-%license LICENSE.Apache-2.0
-%config %{_sysconfdir}/deviced/display-profile-wearable.conf
-
 %files config-enable-display-timer
 %manifest deviced.manifest
 %license LICENSE.Apache-2.0
 %config %{_sysconfdir}/deviced/display-enable-timer.conf
 
-%files plugin-profile-tv
+%files plugin-profile-mobile
 %manifest deviced.manifest
 %license LICENSE.Apache-2.0
 %defattr(-,root,root,-)
-%{_libdir}/display-tv.so
+%{_libdir}/mobile-display.so
+
+%files plugin-profile-wearable
+%manifest deviced.manifest
+%license LICENSE.Apache-2.0
+%config %{_sysconfdir}/deviced/profile-wearable.conf
+#%{_libdir}/mobile-wearable.so
+
+#%files plugin-profile-tv
+#%manifest deviced.manifest
+#%license LICENSE.Apache-2.0
+#%defattr(-,root,root,-)
+#%{_libdir}/display-tv.so
+
+#%files plugin-profile-iot
+#%manifest deviced.manifest
+#%license LICENSE.Apache-2.0
+#%defattr(-,root,root,-)
diff --git a/plugins/mobile/display/CMakeLists.txt b/plugins/mobile/display/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7aad0f4
--- /dev/null
@@ -0,0 +1,27 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(mobile-display C)
+
+FILE(GLOB ALL_SRCS "*.c")
+SET(SRCS ${ALL_SRCS})
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/display)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(libpkgs REQUIRED
+       dlog
+       glib-2.0
+       gio-2.0
+       gio-unix-2.0
+       libinput
+       capi-system-sensor)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+       SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME mobile-display)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
similarity index 93%
rename from src/display/ambient-mode.c
rename to plugins/mobile/display/ambient-mode.c
index a275500..7b0e399 100644 (file)
@@ -36,6 +36,7 @@
 #define TIMEOUT_NONE                   (-1)
 #define AMBIENT_CLOCK_WAITING_TIME     5000 /* ms */
 
+extern struct display_plugin disp_plgn;
 static int ambient_state;
 static pid_t ambient_pid;  /* Ambient Clock pid */
 static int ambient_condition;
@@ -133,8 +134,9 @@ static void start_clock(void)
            ambient_state == false)
                return;
 
-       pm_lock_internal(INTERNAL_LOCK_AMBIENT,
-           LCD_OFF, STAY_CUR_STATE, AMBIENT_CLOCK_WAITING_TIME);
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, STAY_CUR_STATE, 
+                       AMBIENT_CLOCK_WAITING_TIME);
 }
 
 static void end_clock(pid_t pid)
@@ -147,8 +149,8 @@ static void end_clock(pid_t pid)
        if (update_count == 0)
                broadcast_lcd_off_late(LCD_OFF_LATE_MODE);
 
-       pm_unlock_internal(INTERNAL_LOCK_AMBIENT,
-                       LCD_OFF, PM_SLEEP_MARGIN);
+       if (disp_plgn.pm_unlock_internal)
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_AMBIENT, LCD_OFF, PM_SLEEP_MARGIN);
 
        update_count++;
        if (update_count == UINT_MAX)
similarity index 98%
rename from src/display/core.c
rename to plugins/mobile/display/core.c
index 0c623d4..670a6bc 100755 (executable)
@@ -51,6 +51,7 @@
 #include "core/udev.h"
 #include "core/list.h"
 #include "core/common.h"
+#include "battery/battery.h"
 #include "shared/plugin.h"
 #include "core/config-parser.h"
 #include "core/launch.h"
@@ -79,6 +80,8 @@
 #define TIMEOUT_STR            "timeout"
 #define UNKNOWN_STR            "unknown"
 
+extern void init_pm_internal();
+extern struct display_plugin disp_plgn;
 unsigned int pm_status_flag;
 static int trans_condition;
 
@@ -88,7 +91,6 @@ static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
 int pm_cur_state;
 int pm_old_state;
 guint timeout_src_id;
-int system_wakeup_flag = false;
 static unsigned int custom_normal_timeout = 0;
 static unsigned int custom_dim_timeout = 0;
 static int custom_holdkey_block = false;
@@ -103,7 +105,6 @@ static int stay_touchscreen_off = false;
 static dd_list *lcdon_ops;
 static bool lcdon_broadcast = true;
 static bool touch_blocked = false;
-static void *plugin_handle;
 
 /* default transition, action fuctions */
 static int default_trans(int evt);
@@ -770,7 +771,7 @@ static void update_display_time(void)
        }
 
        /* third priority : lock state */
-       if ((get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
+       if ((__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) &&
            !get_lock_screen_bg_state()) {
                /* timeout is different according to key or event. */
                states[S_NORMAL].timeout = lock_screen_timeout;
@@ -830,7 +831,7 @@ void lcd_on_direct(enum device_flags flags)
 #else
        ret = vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
        if ((ret >= 0 && call_state != VCONFKEY_CALL_OFF) ||
-           (get_lock_screen_state() == VCONFKEY_IDLE_LOCK)) {
+           (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK)) {
                _D("LOCK state, lcd is on directly");
                lcd_on_procedure(LCD_NORMAL, flags);
        }
@@ -1323,7 +1324,7 @@ void save_display_log(void)
                        _E("write() failed (%d)", errno);
 
                snprintf(buf, sizeof(buf), "screen lock status : %d\n",
-                       get_lock_screen_state());
+                       __get_lock_screen_state());
                ret = write(fd, buf, strlen(buf));
                if (ret < 0)
                        _E("write() failed (%d)", errno);
@@ -1357,7 +1358,7 @@ int check_lcdoff_direct(void)
        if (pm_cur_state != S_LCDDIM)
                return false;
 
-       lock = get_lock_screen_state();
+       lock = __get_lock_screen_state();
        if (lock != VCONFKEY_IDLE_LOCK && hallic_open)
                return false;
 
@@ -1374,7 +1375,7 @@ int check_lcdoff_direct(void)
        return true;
 }
 
-int check_lcdoff_lock_state(void)
+static int __check_lcdoff_lock_state(void)
 {
        if (cond_head[S_LCDOFF] != NULL)
                return true;
@@ -1633,7 +1634,7 @@ go_suspend:
                }
 
                _I("system wakeup!!");
-               system_wakeup_flag = true;
+               disp_plgn.system_wakeup_flag = true;
                /* Resume !! */
                if (power_ops.check_wakeup_src() == EVENT_DEVICE)
                        /* system waked up by devices */
@@ -1844,6 +1845,12 @@ static int update_setting(int key_idx, int val)
        return 0;
 }
 
+extern int get_charging_status(int *val);
+//static int get_charging_status(int *val)
+//{
+       //return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val);
+//}
+
 static void check_seed_status(void)
 {
        int ret = -1;
@@ -2016,8 +2023,10 @@ static int booting_done(void *data)
                return done;
 
        _I("booting done. Release display and power lock");
-       pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
-       pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN);
+       if (disp_plgn.pm_unlock_internal) {
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL, PM_SLEEP_MARGIN);
+       }
 
        return done;
 }
@@ -2174,16 +2183,6 @@ static void add_timer_for_wm_ready(void)
                _E("Failed to add wm_ready timeout");
 }
 
-static int display_plugin_load()
-{
-       return load_plugin("display", &plugin_handle);
-}
-
-static int display_plugin_unload()
-{
-       return unload_plugin(plugin_handle);
-}
-
 /**
  * Power manager Main
  *
@@ -2201,7 +2200,9 @@ static int display_probe(void *data)
        if (ret)
                return ret;
 
-       display_plugin_load();
+       /* display_plugin instance initialization */
+       init_pm_internal();
+       disp_plgn.check_lcdoff_lock_state = __check_lcdoff_lock_state;
 
        return 0;
 }
@@ -2229,7 +2230,6 @@ static void display_init(void *data)
        register_notifier(DEVICE_NOTIFIER_PROCESS_FOREGROUND, process_foreground);
        register_notifier(DEVICE_NOTIFIER_POWEROFF, device_poweroff);
 
-
        for (i = INIT_SETTING; i < INIT_END; i++) {
                switch (i) {
                case INIT_SETTING:
@@ -2303,10 +2303,12 @@ static void display_init(void *data)
                 * deviced guarantees all booting script is executing.
                 * Last script of booting unlocks this suspend blocking state.
                 */
-               pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
-                               STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
-               pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL,
-                               STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
+               if (disp_plgn.pm_lock_internal) {
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF,
+                                       STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_BOOTING, LCD_NORMAL,
+                                       STAY_CUR_STATE, BOOTING_DONE_WATING_TIME);
+               }
 
                if (display_conf.input_support)
                        if (CHECK_OPS(keyfilter_ops, init))
@@ -2318,8 +2320,6 @@ static void display_exit(void *data)
 {
        int i = INIT_END;
 
-       display_plugin_unload();
-
        status = DEVICE_OPS_STATUS_STOP;
 
        /* Set current state to S_NORMAL */
similarity index 96%
rename from src/display/display-dbus.c
rename to plugins/mobile/display/display-dbus.c
index 02bc8c4..be40ed8 100755 (executable)
@@ -60,6 +60,8 @@
                } \
        } while (0)
 
+extern struct display_plugin disp_plgn;
+
 GVariant *dbus_start(GDBusConnection *conn,
        const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
        GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
@@ -179,7 +181,8 @@ GVariant *dbus_lockstate(GDBusConnection *conn,
                flag |= STAY_CUR_STATE;
        }
 
-       ret = pm_lock_internal(pid, state, flag, timeout);
+       if (disp_plgn.pm_lock_internal)
+               ret = disp_plgn.pm_lock_internal(pid, state, flag, timeout);
 out:
        g_free(state_str);
        g_free(option1_str);
@@ -241,7 +244,8 @@ GVariant *dbus_unlockstate(GDBusConnection *conn,
                flag = PM_RESET_TIMER;
        }
 
-       ret = pm_unlock_internal(pid, state, flag);
+       if (disp_plgn.pm_unlock_internal)
+               ret = disp_plgn.pm_unlock_internal(pid, state, flag);
 out:
        g_free(state_str);
        g_free(option_str);
@@ -315,7 +319,8 @@ GVariant *dbus_changestate(GDBusConnection *conn,
                goto out;
        }
 
-       ret = pm_change_internal(pid, state);
+       if (disp_plgn.pm_change_internal)
+               ret = disp_plgn.pm_change_internal(pid, state);
 
        if (!ret && state == LCD_OFF)
                update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_TIMEOUT);
@@ -665,12 +670,15 @@ GVariant *dbus_lockscreenbgon(GDBusConnection *conn,
 
        g_variant_get(param, "(s)", &on);
 
-       if (!strcmp(on, "true"))
-               update_pm_setting(SETTING_LOCK_SCREEN_BG, true);
-       else if (!strcmp(on, "false"))
-               update_pm_setting(SETTING_LOCK_SCREEN_BG, false);
-       else
+       if (!strcmp(on, "true")) {
+               if (disp_plgn.update_pm_setting) 
+                       disp_plgn.update_pm_setting(SETTING_LOCK_SCREEN_BG, true);
+       } else if (!strcmp(on, "false")) {
+               if (disp_plgn.update_pm_setting) 
+                       disp_plgn.update_pm_setting(SETTING_LOCK_SCREEN_BG, false);
+       } else {
                ret = -EINVAL;
+       }
 
        g_free(on);
        return g_variant_new("(i)", ret);
@@ -687,14 +695,16 @@ GVariant *dbus_dumpmode(GDBusConnection *conn,
 
        g_variant_get(param, "(s)", &on);
 
-       if (!strcmp(on, "on"))
-               pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
-                   STAY_CUR_STATE, DUMP_MODE_WATING_TIME);
-       else if (!strcmp(on, "off"))
-               pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
-                   PM_SLEEP_MARGIN);
-       else
+       if (!strcmp(on, "on")) {
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF,
+                               STAY_CUR_STATE, DUMP_MODE_WATING_TIME);
+       } else if (!strcmp(on, "off")) {
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_DUMPMODE, LCD_OFF, PM_SLEEP_MARGIN);
+       } else {
                ret = -EINVAL;
+       }
 
        g_free(on);
        return g_variant_new("(i)", ret);
similarity index 97%
rename from src/display/key-filter.c
rename to plugins/mobile/display/key-filter.c
index 98904b6..5e7cde7 100644 (file)
@@ -32,6 +32,7 @@
 #include "poll.h"
 #include "device-node.h"
 #include "display-actor.h"
+#include "display-ops.h"
 #include "core/common.h"
 #include "core/devices.h"
 #include "core/device-notifier.h"
@@ -67,6 +68,8 @@
 
 #define GLOVE_MODE     1
 
+extern struct display_plugin disp_plgn;
+
 enum key_combination_flags {
        KEY_COMBINATION_STOP            = 0,
        KEY_COMBINATION_POWERKEY        = BIT(0),
@@ -138,7 +141,8 @@ static void longkey_pressed()
 
        if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
                /* change state - LCD on */
-               pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
+               if (disp_plgn.pm_change_internal)
+                       disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL);
                (*pm_callback)(INPUT_POLL_EVENT, NULL);
        }
 
@@ -359,7 +363,8 @@ static int lcdoff_powerkey(void)
                        delete_condition(S_NORMAL);
                        delete_condition(S_LCDDIM);
                        update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
-                       pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF);
+                       if (disp_plgn.pm_change_internal)
+                               disp_plgn.pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_OFF);
                }
        } else {
                ignore = false;
@@ -464,7 +469,8 @@ static int process_screenlock_key(struct input_event *pinput)
                update_lcdoff_source(VCONFKEY_PM_LCDOFF_BY_POWERKEY);
 
                /* LCD off forcly */
-               pm_change_internal(-1, LCD_OFF);
+               if (disp_plgn.pm_change_internal)
+                       disp_plgn.pm_change_internal(-1, LCD_OFF);
        }
 
        return true;
@@ -492,7 +498,7 @@ static void process_hardkey_backlight(struct input_event *pinput)
                        return;
                }
                /* Sound & Vibrate only in unlock state */
-               if (get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK
+               if (__get_lock_screen_state() == VCONFKEY_IDLE_UNLOCK
                    || get_lock_screen_bg_state())
                        sound_vibrate_hardkey();
 
@@ -502,7 +508,7 @@ static void process_hardkey_backlight(struct input_event *pinput)
                }
        } else if (pinput->value == KEY_RELEASED) {
                /* if lockscreen is idle lock */
-               if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
+               if (__get_lock_screen_state() == VCONFKEY_IDLE_LOCK) {
                        _D("Lock state, key backlight is off when phone is unlocked!");
                        return;
                }
similarity index 87%
rename from src/display/poll.c
rename to plugins/mobile/display/poll.c
index 1381f98..e5087dd 100644 (file)
@@ -27,6 +27,7 @@
 #include "util.h"
 #include "core.h"
 #include "poll.h"
+#include "display/display-ops.h"
 
 #define SHIFT_UNLOCK                    4
 #define SHIFT_UNLOCK_PARAMETER          12
@@ -37,6 +38,7 @@
 #define HOLDKEY_BLOCK_BIT               (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT)
 
 static PMMsg recv_data;
+extern struct display_plugin disp_plgn;
 
 int check_dimstay(int next_state, int flag)
 {
@@ -77,7 +79,7 @@ static bool state_supported(enum state_t st)
        return false;
 }
 
-int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout)
+static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout)
 {
        int cond;
 
@@ -109,7 +111,7 @@ int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout)
        return 0;
 }
 
-int pm_unlock_internal(pid_t pid, int s_bits, int flag)
+static int __pm_unlock_internal(pid_t pid, int s_bits, int flag)
 {
        int cond;
 
@@ -140,7 +142,7 @@ int pm_unlock_internal(pid_t pid, int s_bits, int flag)
        return 0;
 }
 
-int pm_change_internal(pid_t pid, int s_bits)
+static int __pm_change_internal(pid_t pid, int s_bits)
 {
        int cond;
 
@@ -164,3 +166,10 @@ int pm_change_internal(pid_t pid, int s_bits)
 
        return 0;
 }
+
+void init_pm_internal()
+{
+       disp_plgn.pm_lock_internal = __pm_lock_internal;
+       disp_plgn.pm_unlock_internal = __pm_unlock_internal;
+       disp_plgn.pm_change_internal = __pm_change_internal;
+}
similarity index 91%
rename from src/display/setting.c
rename to plugins/mobile/display/setting.c
index 10e3387..4a41250 100644 (file)
 #include "core.h"
 #include "util.h"
 #include "setting.h"
+#include "display-ops.h"
 
 #define LCD_DIM_RATIO          0.3
 #define LCD_MAX_DIM_TIMEOUT    7000
 #define LCD_MIN_DIM_TIMEOUT    500
 
+extern struct display_plugin disp_plgn;
 static const char *setting_keys[SETTING_GET_END] = {
        [SETTING_TO_NORMAL] = VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL,
        [SETTING_BRT_LEVEL] = VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
@@ -47,8 +49,6 @@ static int custom_on_timeout = 0;
 static int custom_normal_timeout = 0;
 static int custom_dim_timeout = 0;
 
-int (*update_pm_setting) (int key_idx, int val);
-
 static void display_state_send_system_event(int state)
 {
        bundle *b;
@@ -81,7 +81,7 @@ int set_force_lcdtimeout(int timeout)
        return 0;
 }
 
-int get_lock_screen_state(void)
+int __get_lock_screen_state(void)
 {
        return lock_screen_state;
 }
@@ -109,21 +109,6 @@ void set_lock_screen_bg_state(bool state)
        lock_screen_bg_state = state;
 }
 
-int get_charging_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val);
-}
-
-int get_lowbatt_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, val);
-}
-
-int get_usb_status(int *val)
-{
-       return vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, val);
-}
-
 int set_setting_pmstate(int val)
 {
        static int old = -1;
@@ -237,8 +222,8 @@ static int setting_cb(keynode_t *key_nodes, void *data)
                       vconf_keynode_get_name(tmp), index);
                return -1;
        }
-       if (update_pm_setting != NULL)
-               update_pm_setting(index, vconf_keynode_get_int(tmp));
+       if (disp_plgn.update_pm_setting)
+               disp_plgn.update_pm_setting(index, vconf_keynode_get_int(tmp));
 
        return 0;
 }
@@ -247,8 +232,9 @@ int init_setting(int (*func) (int key_idx, int val))
 {
        int i;
 
-       if (func != NULL)
-               update_pm_setting = func;
+       if (func != NULL) {
+               disp_plgn.update_pm_setting = func;
+       }
 
        for (i = SETTING_BEGIN; i < SETTING_GET_END; i++) {
                /*
@@ -260,6 +246,8 @@ int init_setting(int (*func) (int key_idx, int val))
                                         (void *)((intptr_t)i));
        }
 
+       disp_plgn.get_lock_screen_state = __get_lock_screen_state;
+
        return 0;
 }
 
similarity index 99%
rename from plugins/display/state-tv.c
rename to plugins/tv/display/state-tv.c
index 8c0d7f3..218c2e7 100644 (file)
@@ -307,7 +307,8 @@ static gboolean standby_go_next_state(void *data)
                standby_timer = 0;
        }
 
-       ret = pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND);
+       if (disp_ops.pm_change_internal)
+               ret = disp_ops.pm_change_internal(INTERNAL_LOCK_SUSPEND, SUSPEND);
        if (ret < 0) {
                _E("Failed to change state to S_SUSPEND. Now Power off !!");
                poweroff_trans(0);
index cf72e6c..240d97e 100755 (executable)
 #include <stdarg.h>
 #include "core/log.h"
 #include "core/common.h"
+#include "display/display-ops.h"
 #include "apps.h"
 
 #define POPUP_METHOD "PopupLaunch"
 #define BUFF_MAX        255
 
+extern struct display_plugin disp_plgn;
+
 static const struct app_dbus_match {
        const char *type;
        const char *bus;
@@ -93,7 +96,8 @@ int launch_system_app(char *type, int num, ...)
                NULL);
 
        va_end(args);
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
 
        return ret;
 }
@@ -110,7 +114,9 @@ int launch_message_post(char *type)
                        POPUP_INTERFACE_NOTI,
                        "MessagePostOn",
                        g_variant_new("(s)", type));
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
        return ret;
 }
 
index 989ad37..94a4202 100644 (file)
@@ -30,6 +30,7 @@
 #include "core/log.h"
 #include "core/udev.h"
 #include "display/setting.h"
+#include "display/display-ops.h"
 #include "power-supply.h"
 
 #define CHARGING_STATE(x)      ((x) & CHRGR_FLAG)
@@ -43,6 +44,8 @@
 #define SIGNAL_TIMETOFULL      "TimeToFull"
 #define SIGNAL_TIMETOEMPTY     "TimeToEmpty"
 
+extern struct display_plugin disp_plgn;
+
 enum state_b {
        B_UNCHARGING = 0,
        B_CHARGING = 1,
@@ -70,10 +73,14 @@ static int MAX_VALUE_COUNT[B_END] = {MAX_COUNT_UNCHARGING, MAX_COUNT_CHARGING};
 static double avg_factor[B_END] = {-1.0, -1.0};
 static int old_capacity;
 static int charging_state;
-extern int system_wakeup_flag;
 static int time_to_full = -1;
 static int time_to_empty = -1;
 
+int get_charging_status(int *val)
+{
+       return vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, val);
+}
+
 static int add_batt_node(enum state_b b_index, time_t clock, int capacity)
 {
        struct Batt_node *node = NULL;
@@ -280,9 +287,9 @@ static int battinfo_calculation(void)
                update_time(A_TIMETOFULL, estimated_time);
        } else {
                del_all_batt_node(B_CHARGING);
-               if (system_wakeup_flag == true) {
+               if (disp_plgn.system_wakeup_flag == true) {
                        del_all_batt_node(B_UNCHARGING);
-                       system_wakeup_flag = false;
+                       disp_plgn.system_wakeup_flag = false;
                }
                if (batt_head[B_UNCHARGING] == NULL) {
                        add_batt_node(B_UNCHARGING, clock, capacity);
index f1496bb..0b0f7b8 100644 (file)
@@ -41,4 +41,5 @@ struct battery_config_info {
 
 int battery_charge_err_low_act(void *data);
 int battery_charge_err_high_act(void *data);
+
 #endif /* __BATTERY_H__ */
index f944aa8..03d7c05 100755 (executable)
@@ -40,6 +40,7 @@
 #include "device-node.h"
 #include "display/setting.h"
 #include "display/poll.h"
+#include "display/display-ops.h"
 #include "power/power-handler.h"
 #include "apps/apps.h"
 #include "power-supply.h"
@@ -78,6 +79,8 @@
 
 #define VCONF_KEY_BATTERY_WARNING_LEVEL "db/sysman/battery_warning_level"
 
+extern struct display_plugin disp_plgn;
+
 enum low_battery_type {
        LOW_BATTERY,
        CRITICAL_BATTERY,
@@ -222,7 +225,8 @@ out:
 static void power_off_pm_lock(void)
 {
        if (power_off_lock == POWER_OFF_UNLOCK) {
-               pm_lock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, STAY_CUR_STATE, 0);
                power_off_lock = POWER_OFF_LOCK;
        }
 }
@@ -230,7 +234,8 @@ static void power_off_pm_lock(void)
 static void power_off_pm_unlock(void)
 {
        if (power_off_lock == POWER_OFF_LOCK) {
-               pm_unlock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, PM_SLEEP_MARGIN);
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_LOWBAT, LCD_OFF, PM_SLEEP_MARGIN);
                power_off_lock = POWER_OFF_UNLOCK;
        }
 }
@@ -419,10 +424,12 @@ direct_launch:
                r_block = vconf_get_bool("db/setting/blockmode_wearable", &s_block);
                if ((r_disturb != 0 && r_block != 0) ||
                    (s_disturb == 0 && s_block == 0) ||
-                   lowbat_popup_option == LOWBAT_OPT_CHARGEERR)
-                       pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL);
-               else
+                   lowbat_popup_option == LOWBAT_OPT_CHARGEERR) {
+                       if (disp_plgn.pm_change_internal)
+                               disp_plgn.pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL);
+               } else {
                        _I("block LCD");
+               }
 
                if (lowbat_popup_option == LOWBAT_OPT_CHECK ||
                        lowbat_popup_option == LOWBAT_OPT_WARNING) {
@@ -722,11 +729,12 @@ static int lowbat_process(int bat_percent, void *ad)
        }
 
        if (status != -1) {
-               lock = pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       lock = disp_plgn.pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0);
                ret = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, status);
                power_supply_broadcast(CHARGE_LEVEL_SIGNAL, status);
-               if (update_pm_setting)
-                       update_pm_setting(SETTING_LOW_BATT, status);
+               if (disp_plgn.update_pm_setting)
+                       disp_plgn.update_pm_setting(SETTING_LOW_BATT, status);
        }
 
        if (ret < 0) {
@@ -761,8 +769,10 @@ static int lowbat_process(int bat_percent, void *ad)
        if (result == 1)
                cur_bat_state = new_bat_state;
 exit:
-       if (lock == 0)
-               pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
+       if (lock == 0) {
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
+       }
 
        return result;
 }
index eee38bb..0116417 100755 (executable)
@@ -32,6 +32,7 @@
 #include "core/config-parser.h"
 #include "display/poll.h"
 #include "display/setting.h"
+#include "display/display-ops.h"
 #include "apps/apps.h"
 #include "power-supply.h"
 #include "battery.h"
@@ -62,6 +63,8 @@
 #define RETRY_MAX 5
 #define BATTERY_CHECK_TIMER_INTERVAL (0.5)
 
+extern struct display_plugin disp_plgn;
+
 enum power_supply_init_type {
        POWER_SUPPLY_NOT_READY   = 0,
        POWER_SUPPLY_INITIALIZED = 1,
@@ -91,7 +94,8 @@ static void pm_check_and_change(int bInserted)
        if (old == bInserted)
                return;
        old = bInserted;
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
 }
 
 static int changed_battery_cf(enum present_type status)
@@ -142,8 +146,10 @@ static gboolean health_timer_cb(void *data)
 
        _I("popup - Battery health status is not good");
        device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&value);
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
-       pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
        if (battery.temp == TEMP_LOW)
                battery_charge_err_low_act(NULL);
        else if (battery.temp == TEMP_HIGH)
@@ -354,11 +360,12 @@ static void noti_batt_full(void)
                bat_full_noti = 1;
                /* turn on LCD, if battery is full charged */
                noti = check_power_supply_noti();
-               if (noti)
-                       pm_change_internal(INTERNAL_LOCK_BATTERY_FULL,
-                               LCD_NORMAL);
-               else
+               if (noti) {
+                       if (disp_plgn.pm_change_internal)
+                               disp_plgn.pm_change_internal(INTERNAL_LOCK_BATTERY_FULL, LCD_NORMAL);
+               } else {
                        _I("block LCD");
+               }
                /* on the full charge state */
                device_notify(DEVICE_NOTIFIER_FULLBAT, (void *)&bat_full_noti);
        }
@@ -367,8 +374,8 @@ static void noti_batt_full(void)
 static void check_power_supply(int state)
 {
        pm_check_and_change(state);
-       if (update_pm_setting)
-               update_pm_setting(SETTING_CHARGING, state);
+       if (disp_plgn.update_pm_setting)
+               disp_plgn.update_pm_setting(SETTING_CHARGING, state);
 }
 
 static void charger_state_send_system_event(int state)
@@ -412,15 +419,18 @@ static void update_present(enum battery_noti_status status)
                return;
        _I("charge %d present %d", battery.charge_now, battery.present);
        old = status;
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
        if (status == DEVICE_NOTI_ON) {
                present = PRESENT_ABNORMAL;
                device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&present);
-               pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
        } else {
                present = PRESENT_NORMAL;
                device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&present);
-               pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
        }
        changed_battery_cf(present);
 }
@@ -435,16 +445,21 @@ static void update_health(enum battery_noti_status status)
        _I("charge %d health %d", battery.charge_now, battery.health);
        old = status;
 
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+
        if (status == DEVICE_NOTI_ON) {
                _I("popup - Battery health status is not good");
-               pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
+       
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
                if (battery.temp == TEMP_LOW)
                        battery_charge_err_low_act(NULL);
                else if (battery.temp == TEMP_HIGH)
                        battery_charge_err_high_act(NULL);
        } else {
-               pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
                abnormal_popup_timer_init();
                launch_system_app(APP_DEFAULT, 2, APP_KEY_TYPE, REMOVE_POPUP);
        }
@@ -460,7 +475,8 @@ static void update_ovp(enum battery_noti_status status)
                return;
        _I("charge %d ovp %d", battery.charge_now, battery.ovp);
        old = status;
-       pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
        if (status == DEVICE_NOTI_ON)
                value = OVP_ABNORMAL;
        else
@@ -1076,7 +1092,9 @@ static int display_changed(void *data)
                return 0;
        if (battery.health != HEALTH_BAD && battery.present != PRESENT_ABNORMAL)
                return 0;
-       pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
+
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
        return 0;
 }
 
index 0ce5b03..bf798f4 100755 (executable)
@@ -30,6 +30,7 @@
 #include "devices.h"
 #include "power/boot.h"
 #include "power/power-handler.h"
+#include "shared/plugin.h"
 #include "device-notifier.h"
 
 #define PIDFILE_PATH           "/var/run/.deviced.pid"
@@ -99,6 +100,8 @@ static int deviced_main(int argc, char **argv)
        if (!handle)
                _E("Fail to get dbus connection");
 
+       load_plugins();
+
        devices_init(NULL);
 
        ret = dbus_handle_request_bus_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL);
index 298a170..eb2b1b4 100644 (file)
@@ -167,8 +167,6 @@ void reset_lcd_timeout(GDBusConnection *conn,
                                                const gchar *unique_name,
                                                gpointer data);
 
-int check_lcdoff_lock_state(void);
-
 /* setting.c */
 int get_lock_screen_bg_state(void);
 int set_custom_lcdon_timeout(int timeout);
index 1c1102d..478cf30 100644 (file)
@@ -46,4 +46,13 @@ void add_display(const struct display_ops *disp);
 void remove_display(const struct display_ops *disp);
 const struct display_ops *find_display_feature(const char *name);
 
+struct display_plugin {
+       int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout);
+       int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag);
+       int (*pm_change_internal) (pid_t pid, int s_bits);
+       int (*check_lcdoff_lock_state) ();
+       int (*update_pm_setting) (int key_idx, int val);
+       int (*get_lock_screen_state) ();
+       bool system_wakeup_flag;
+};
 #endif
index a3e12a8..819ef97 100644 (file)
@@ -147,10 +147,6 @@ extern int (*pm_callback) (int, PMMsg *);
 int init_input(void);
 int exit_input(void);
 
-extern int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout);
-extern int pm_unlock_internal(pid_t pid, int s_bits, int flag);
-extern int pm_change_internal(pid_t pid, int s_bits);
-
 /**
  * @}
  */
index 9763c97..31dc03d 100644 (file)
@@ -47,8 +47,6 @@ enum {
        SETTING_END
 };
 
-extern int (*update_pm_setting) (int key_idx, int val);
-
 int get_setting_brightness(int *level);
 
 /*
@@ -98,25 +96,8 @@ extern int get_usb_status(int *val);
  */
 extern int set_setting_pmstate(int val);
 
-/*
- * get charging status at SLP-setting "memory/Battery/Charger"
- *
- * @internal
- * @param[in] val charging or not (1 or 0 respectively).
- * @return 0 : success, -1 : error
- */
-extern int get_charging_status(int *val);
-
-/*
- * get current battery low status at SLP-setting "memory/Battery/Status/Low"
- *
- * @internal
- * @param[in] val current low battery status
- * @return 0 : success, -1 : error
- */
-extern int get_lowbatt_status(int *val);
-
-int get_lock_screen_state(void);
+//FIXME
+int __get_lock_screen_state(void);
 
 /*
  * @}
index 26780e1..4e03793 100644 (file)
 #include "core/device-notifier.h"
 #include "core/udev.h"
 #include "display/core.h"
+#include "display/display-ops.h"
 #include "extcon/extcon.h"
 
 #define METHOD_GET_CRADLE      "GetCradle"
 #define SIGNAL_CRADLE_STATE    "ChangedCradle"
 
+extern struct display_plugin disp_plgn;
 static struct extcon_ops cradle_extcon_ops;
 
 static void cradle_send_broadcast(int status)
@@ -51,17 +53,21 @@ static void cradle_send_broadcast(int status)
 static int cradle_update(int status)
 {
        _I("jack - cradle changed %d", status);
-       pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL);
        cradle_send_broadcast(status);
        if (vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status) != 0) {
                _E("failed to set vconf status");
                return -EIO;
        }
 
-       if (status == DOCK_SOUND)
-               pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
-       else if (status == DOCK_NONE)
-               pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN);
+       if (status == DOCK_SOUND) {
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
+       } else if (status == DOCK_NONE) {
+               if (disp_plgn.pm_unlock_internal)
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN);
+       }
 
        return 0;
 }
@@ -80,7 +86,8 @@ static int display_changed(void *data)
 
        cradle = cradle_extcon_ops.status;
        if (cradle == DOCK_SOUND) {
-               pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
                _I("sound dock is connected! dim lock is on.");
        }
 
index 3ab2ede..90748ff 100644 (file)
 
 #include "core/log.h"
 #include "display/poll.h"
+#include "display/display-ops.h"
 #include "extcon/extcon.h"
 #include "extcon/extcon_count.h"
 
 #define SIGNAL_EARJACK_STATE   "ChangedEarjack"
 #define GET_EARJACK_STATE              "Earjack"
 
+extern struct display_plugin disp_plgn;
+
 static void earjack_send_broadcast(int status)
 {
        static int old = 0;
@@ -68,8 +71,10 @@ static int earjack_update(int status)
        vconf_set_int(VCONFKEY_SYSMAN_EARJACK, status);
        earjack_send_broadcast(status);
        earjack_send_system_event(status);
-       if (status != 0)
-               pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL);
+       if (status != 0) {
+               if (disp_plgn.pm_change_internal)
+                       disp_plgn.pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL);
+       }
 
        if (CONNECTED(status)) {
                extcon_get_count(EXTCON_EARJACK);
index 6f80bfc..0331a0d 100644 (file)
 #include "core/log.h"
 #include "core/device-notifier.h"
 #include "display/core.h"
+#include "display/display-ops.h"
 #include "extcon.h"
 
 #define METHOD_GET_HDMI                "GetHDMI"
 #define SIGNAL_HDMI_STATE      "ChangedHDMI"
 
+extern struct display_plugin disp_plgn;
 static struct extcon_ops hdmi_extcon_ops;
 
 static void hdmi_send_broadcast(int status)
@@ -48,14 +50,18 @@ static void hdmi_send_broadcast(int status)
 static int hdmi_update(int status)
 {
        _I("jack - hdmi changed %d", status);
-       pm_change_internal(INTERNAL_LOCK_HDMI, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_HDMI, LCD_NORMAL);
        vconf_set_int(VCONFKEY_SYSMAN_HDMI, status);
        hdmi_send_broadcast(status);
 
-       if (status == 1)
-               pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
-       else
-               pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN);
+       if (status == 1) {
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
+       } else {
+               if (disp_plgn.pm_unlock_internal) 
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, PM_SLEEP_MARGIN);
+       }
 
        return 0;
 }
@@ -74,7 +80,8 @@ static int display_changed(void *data)
 
        hdmi = hdmi_extcon_ops.status;
        if (hdmi == 0) {
-               pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_HDMI, LCD_DIM, STAY_CUR_STATE, 0);
                _I("hdmi is connected! dim lock is on.");
        }
        return 0;
index c38eb9b..312150e 100644 (file)
@@ -27,6 +27,7 @@
 #include "core/device-notifier.h"
 #include "display/core.h"
 #include "display/setting.h"
+#include "display/display-ops.h"
 #include "touch-key.h"
 
 #define KEYBACKLIGHT_TIME_90            90     /* 1.5 second */
@@ -43,6 +44,7 @@
 #define GET_BRIGHTNESS(val)     (((val) >> 24) & 0xFF)
 #define SET_BRIGHTNESS(val)     (((val) & 0xFF) << 24)
 
+extern struct display_plugin disp_plgn;
 struct led_device *touchled_dev;
 static guint hardkey_timeout_id;
 static int hardkey_duration;
@@ -136,7 +138,7 @@ static void process_touchkey_enable(bool enable)
                touchled_set_state(true);
 
                /* do not create turnoff timer in case of idle lock state */
-               if (get_lock_screen_state() == VCONFKEY_IDLE_LOCK)
+               if (disp_plgn.get_lock_screen_state && disp_plgn.get_lock_screen_state() == VCONFKEY_IDLE_LOCK)
                        return;
 
                /* start timer */
index a7e6638..fe51e28 100644 (file)
@@ -26,6 +26,7 @@
 #include "core/device-notifier.h"
 #include "core/common.h"
 #include "display/poll.h"
+#include "display/display-ops.h"
 #include "shared/deviced-systemd.h"
 
 #define SIGNAL_BOOTING_DONE            "BootingDone"
@@ -36,6 +37,8 @@
 #define SYSTEMD_STATE_RUNNING                "running"
 #define SYSTEMD_STATE_DEGRADED               "degraded"
 
+extern struct display_plugin disp_plgn;
+
 int booting_finished(void)
 {
        char *state = NULL;
@@ -115,7 +118,8 @@ static void booting_done_received(GDBusConnection  *conn,
        remove_booting_done_handler(NULL);
 
        _I("real booting done, unlock LCD_OFF");
-       pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
+       if (disp_plgn.pm_unlock_internal)
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_BOOTING, LCD_OFF, PM_SLEEP_MARGIN);
 
        _I("signal booting done");
 
index 661a845..76e04a7 100755 (executable)
@@ -50,6 +50,7 @@
 #include "display/poll.h"
 #include "display/setting.h"
 #include "display/core.h"
+#include "display/display-ops.h"
 #include "power-handler.h"
 #include "apps/apps.h"
 #include "shared/deviced-systemd.h"
@@ -71,6 +72,8 @@
 
 #define POWER_CONF_FILE                        "/etc/deviced/power.conf"
 
+extern struct display_plugin disp_plgn;
+
 struct power_flag {
        enum poweroff_type type;
        const char *path;
@@ -290,7 +293,8 @@ static void disable_display(void)
 {
        const struct device_ops *display_device_ops = NULL;
        FIND_DEVICE_VOID(display_device_ops, "display");
-       pm_change_internal(INTERNAL_LOCK_POWEROFF, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_POWEROFF, LCD_NORMAL);
        display_device_ops->exit(NULL);
 }
 
@@ -501,7 +505,8 @@ static gboolean poweroff_timeout_cb(void *data)
 
        make_power_flag(poweroff_opt.type, poweroff_opt.option);
 
-       pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0);
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_POWEROFF, LCD_OFF, STAY_CUR_STATE, 0);
 
        poweroff_fixed_flow(poweroff_opt.type);
 
@@ -513,8 +518,8 @@ static gboolean poweroff_timeout_cb(void *data)
                _E("Failed to %s (%d)", poweroff_opt.name, ret);
 
 out:
-       if (update_pm_setting)
-               update_pm_setting(SETTING_POWEROFF, poweroff_opt.type);
+       if (disp_plgn.update_pm_setting)
+               disp_plgn.update_pm_setting(SETTING_POWEROFF, poweroff_opt.type);
        during_poweroff = false;
        return G_SOURCE_REMOVE;
 }
index 034aac3..ba96073 100644 (file)
 
 #define _GNU_SOURCE
 
+#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
+#include <fcntl.h>
 #include <gio/gio.h>
 #include <dlfcn.h>
+#include <sys/types.h>
+#include <stdbool.h>
 
+#include "display/display-ops.h"
 #include "common.h"
 #include "core/log.h"
 
 #endif
 #define MODULE_PATH            LIBPATH"/deviced"
 
+struct display_plugin disp_plgn;
+
 int load_plugin(const char *id, void **h)
 {
        char path[PATH_MAX];
        void *handle;
 
-       if (!id || !h)
+       if (!id)
                return -EINVAL;
 
        /* Find matched module path */
@@ -50,19 +57,18 @@ int load_plugin(const char *id, void **h)
        }
 
        /* Load module */
-       handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
-       //handle = dlopen(path, RTLD_NOW|RTLD_GLOBAL);
+       handle = dlopen(path, RTLD_NOW|RTLD_GLOBAL);
        if (!handle) {
                _E("fail to open module : %s", dlerror());
                return -ENOENT;
        }
 
-       *h = handle;
+       if (h)
+               *h = handle;
 
        return 0;
 }
 
-
 int unload_plugin(void *h)
 {
        if (!h)
@@ -70,3 +76,10 @@ int unload_plugin(void *h)
        else
                return dlclose(h);
 }
+
+void load_plugins()
+{
+       load_plugin("display", NULL);
+
+       return;
+}
index fefaef4..ba9c633 100755 (executable)
@@ -21,5 +21,6 @@
 
 int load_plugin(const char *id, void **h);
 int unload_plugin(void *h);
+void load_plugins();
 
 #endif                         /* __DD_PLUGIN_H__ */
index e078439..e2f7db2 100644 (file)
@@ -36,6 +36,7 @@
 #include "core/devices.h"
 #include "display/poll.h"
 #include "display/core.h"
+#include "display/display-ops.h"
 #include "core/common.h"
 #include "core/device-notifier.h"
 
@@ -63,6 +64,7 @@
 
 #define TIME_CHANGE_SIGNAL     "STimeChanged"
 
+extern struct display_plugin disp_plgn;
 static const time_t default_time = 2147483645; /* max(32bit) -3sec */
 static guint tfdh; /* tfd change noti */
 int tfd = -1;
@@ -179,9 +181,14 @@ int set_datetime_action(int argc, char **argv)
        else
                pm_state = 0x4;
 
-       pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+
        ret = handle_date(argv[0]);
-       pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+       
+       if (disp_plgn.pm_unlock_internal)
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+
        return ret;
 }
 
@@ -200,9 +207,14 @@ int set_timezone_action(int argc, char **argv)
        else
                pm_state = 0x4;
 
-       pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+
        ret = handle_timezone(argv[0]);
-       pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+
+       if (disp_plgn.pm_unlock_internal)
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+
        return ret;
 }
 
@@ -338,7 +350,9 @@ static int time_lcd_changed_cb(void *data)
        if (lcd_state < S_LCDOFF)
                goto restart;
 
-       lcd_state = check_lcdoff_lock_state();
+       if (disp_plgn.check_lcdoff_lock_state)
+               lcd_state = disp_plgn.check_lcdoff_lock_state();
+
        if (lcd_state || !tfdh || tfd == -1)
                goto out;
 
index db380f5..f6cb515 100644 (file)
 #include "core/common.h"
 #include "core/device-notifier.h"
 #include "display/poll.h"
+#include "display/display-ops.h"
 #include "extcon/extcon.h"
 #include "apps/apps.h"
 #include "usb.h"
 #include "usb-tethering.h"
 #include "usb-debug.h"
 
+extern struct display_plugin disp_plgn;
 static struct usb_gadget_translator *gadget_translator;
 static struct usb_client *usb_client;
 
@@ -280,8 +282,9 @@ static int usb_enable(unsigned int mode)
        }
 
        usb_state_update_state(USB_CONNECTED, mode);
-       pm_lock_internal(INTERNAL_LOCK_USB,
-                       LCD_OFF, STAY_CUR_STATE, 0);
+       
+       if (disp_plgn.pm_lock_internal)
+               disp_plgn.pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
 
        return 0;
 }
@@ -303,8 +306,8 @@ static int usb_disable(void)
                        _E("Failed to disable usb config (%d)", ret);
        }
 
-       pm_unlock_internal(INTERNAL_LOCK_USB,
-                       LCD_OFF, STAY_CUR_STATE);
+       if (disp_plgn.pm_unlock_internal)
+               disp_plgn.pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
 
        return 0;
 }
index 074bab0..06b0d14 100755 (executable)
@@ -32,6 +32,7 @@
 #include "core/device-idler.h"
 #include "apps/apps.h"
 #include "extcon/extcon.h"
+#include "display/display-ops.h"
 
 #define USB_INTERFACE_CLASS     "bInterfaceClass"
 #define USB_INTERFACE_SUBCLASS  "bInterfaceSubClass"
@@ -50,6 +51,7 @@
 #define ROOTPATH tzplatform_getenv(TZ_SYS_VAR)
 #define POLICY_FILENAME "usbhost-policy"
 
+extern struct display_plugin disp_plgn;
 char *POLICY_FILEPATH;
 
 /**
@@ -250,7 +252,8 @@ static int add_usbhost_list(struct udev_device *dev, const char *devpath)
 
        broadcast_usbhost_signal(USB_HOST_ADDED, usbhost);
 
-       pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL);
 
        /* for debugging */
        _I("USB HOST Added");
@@ -278,7 +281,8 @@ static int remove_usbhost_list(const char *devpath)
 
        broadcast_usbhost_signal(USB_HOST_REMOVED, usbhost);
 
-       pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL);
+       if (disp_plgn.pm_change_internal)
+               disp_plgn.pm_change_internal(INTERNAL_LOCK_USB, LCD_NORMAL);
 
        /* for debugging */
        _I("USB HOST Removed");
@@ -1179,10 +1183,12 @@ static int extcon_usbhost_state_changed(int status)
 {
        if (status == 0) {
                _I("USB host connector disconnected");
-               pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
+               if (disp_plgn.pm_unlock_internal) 
+                       disp_plgn.pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
        } else {
                _I("USB host connector connected");
-               pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
+               if (disp_plgn.pm_lock_internal)
+                       disp_plgn.pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
        }
        return 0;
 }