Add CPU lock on pkgmgr-server 81/131681/7
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 30 May 2017 10:46:31 +0000 (19:46 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 8 Jun 2017 07:45:06 +0000 (16:45 +0900)
- Enable CPU lock on pkgmgr-server when backend doing
something which will take some time to let device not to
enter sleep

Change-Id: Ibecec1c1cb7eba85923e4dc95fee2fe5f47bdee4
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
CMakeLists.txt
packaging/pkgmgr-server.spec
src/pkgmgr-server.c

index 9612bd6..75e72a4 100644 (file)
@@ -25,7 +25,8 @@ INCLUDE(FindPkgConfig)
 SET(PKGMGR_SERVER "pkgmgr-server")
 AUX_SOURCE_DIRECTORY(src SRCS)
 
-SET(SERVER_CHECK_MODULES gio-2.0 glib-2.0 dlog pkgmgr-parser pkgmgr-info libtzplatform-config drm-service-core-tizen libgum sqlite3 pkgmgr pkgmgr-installer libsystemd aul minizip)
+SET(SERVER_CHECK_MODULES gio-2.0 glib-2.0 dlog pkgmgr-parser pkgmgr-info libtzplatform-config drm-service-core-tizen libgum sqlite3 pkgmgr pkgmgr-installer libsystemd aul
+minizip deviced)
 IF(TIZEN_FEATURE_CSR)
        SET(SERVER_CHECK_MODULES "${SERVER_CHECK_MODULES} csr")
 ENDIF(TIZEN_FEATURE_CSR)
index ddc871f..1b7f309 100644 (file)
@@ -24,6 +24,7 @@ BuildRequires:  pkgconfig(libgum)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  pkgconfig(minizip)
+BuildRequires:  pkgconfig(deviced)
 BuildRequires:  fdupes
 
 %if "%{?TIZEN_PROFILE_TV}" != "1"
index ff4e74b..0f349fe 100644 (file)
@@ -43,6 +43,7 @@
 #include <pkgmgr/pkgmgr_parser_db.h>
 #include <tzplatform_config.h>
 #include <drm-tizen-apps.h>
+#include <dd-display.h>
 #ifdef TIZEN_FEATURE_CSR
 #include <csr-content-screening.h>
 #endif
@@ -83,6 +84,7 @@ is dynamically determined.
 static char backend_busy = 0;
 extern int num_of_backends;
 bool is_drm_busy = false;
+static bool is_lock_set = false;
 
 static GIOChannel *sio;
 static guint swid;
@@ -113,6 +115,24 @@ static void __set_backend_free(int position)
        backend_busy = backend_busy & ~(1 << position);
 }
 
+static void __set_power_lock(void)
+{
+       if (is_lock_set)
+               return;
+
+       if (display_lock_state(LCD_OFF, STAY_CUR_STATE, 0) == 0)
+               is_lock_set = true;
+}
+
+static void __release_power_lock(void)
+{
+       if (!is_lock_set)
+               return;
+
+       if (display_unlock_state(LCD_OFF, PM_SLEEP_MARGIN) == 0)
+               is_lock_set = false;
+}
+
 static gboolean getsize_io_handler(GIOChannel *io, GIOCondition cond,
                gpointer data)
 {
@@ -308,6 +328,8 @@ gboolean exit_server(void *data)
        if (__check_backend_status_for_exit() &&
                        __check_queue_status_for_exit() && !is_drm_busy) {
                g_main_loop_quit(mainloop);
+               if (is_lock_set)
+                       __release_power_lock();
                return FALSE;
        }
        return TRUE;
@@ -1615,31 +1637,37 @@ gboolean queue_job(void *data)
        switch (job->req_type) {
        case REQUEST_TYPE_INSTALL:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_install(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_MOUNT_INSTALL:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_mount_install(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_REINSTALL:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_reinstall(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_UNINSTALL:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_uninstall(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_MOVE:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_move(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_ENABLE_PKG:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_enable_pkg(job);
                if (ret < 0)
                        _send_fail_signal(job);
@@ -1647,6 +1675,7 @@ gboolean queue_job(void *data)
                break;
        case REQUEST_TYPE_DISABLE_PKG:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_disable_pkg(job);
                if (ret < 0)
                        _send_fail_signal(job);
@@ -1687,11 +1716,13 @@ gboolean queue_job(void *data)
                break;
        case REQUEST_TYPE_CLEARDATA:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_cleardata(job);
                __post_process(ret, x, job);
                break;
        case REQUEST_TYPE_CLEARCACHE:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_clearcache(job);
                __post_process(ret, x, job);
                break;
@@ -1749,6 +1780,7 @@ gboolean queue_job(void *data)
                break;
        case REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE:
                __set_backend_busy(x);
+               __set_power_lock();
                ret = __process_migrate_external_image(job);
                __post_process(ret, x, job);
                break;