summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghyun Yeon <jungh.yeon@samsung.com>2017-05-30 19:46:31 +0900
committerJunghyun Yeon <jungh.yeon@samsung.com>2018-03-23 11:05:09 +0900
commit4ed919ed9b542c8a705397b230b895f3f293f2ac (patch)
treed57649c38e5f2560010cd7bba0086d0329f8b9a5
parent8b7e6a2cdf036ac53a85ba95f04dda577ff1bf0c (diff)
downloadpkgmgr-server-tizen_3.0.tar.gz
pkgmgr-server-tizen_3.0.tar.bz2
pkgmgr-server-tizen_3.0.zip
Add CPU lock on pkgmgr-servertizen_3.0
- 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> (cherry picked from commit ba30c52099d9617308b9c86597107cba24e050f0)
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/pkgmgr-server.c115
2 files changed, 117 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7bf90d..a9abfac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,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)
IF(TIZEN_FEATURE_CSR)
SET(SERVER_CHECK_MODULES "${SERVER_CHECK_MODULES} csr")
ENDIF(TIZEN_FEATURE_CSR)
diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c
index ff4e74b..a8f8720 100644
--- a/src/pkgmgr-server.c
+++ b/src/pkgmgr-server.c
@@ -83,11 +83,13 @@ 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;
static GHashTable *backend_info_table;
static GMainLoop *mainloop;
+static GDBusConnection *system_conn;
static int __check_backend_status_for_exit(void);
static int __check_queue_status_for_exit(void);
@@ -113,6 +115,107 @@ static void __set_backend_free(int position)
backend_busy = backend_busy & ~(1 << position);
}
+static GDBusConnection *_get_system_conn(void)
+{
+ GError *err = NULL;
+
+ if (system_conn)
+ return system_conn;
+
+ system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (system_conn == NULL) {
+ ERR("Failed to get system bus: %s", err->message);
+ g_error_free(err);
+ return NULL;
+ }
+
+ return system_conn;
+}
+
+#define DEVICED_DBUS_PATH "org.tizen.system.deviced"
+#define DEVICED_DBUS_OBJECT_PATH "/Org/Tizen/System/DeviceD/Display"
+#define DEVICED_DBUS_INTERFACE_NAME "org.tizen.system.deviced.display"
+
+static void __set_power_lock(void)
+{
+ GDBusConnection *conn;
+ GDBusMessage *msg;
+ GError *err = NULL;
+ int ret = 0;
+
+ if (is_lock_set)
+ return;
+
+ conn = _get_system_conn();
+ if (conn == NULL)
+ return;
+
+ msg = g_dbus_message_new_method_call(DEVICED_DBUS_PATH,
+ DEVICED_DBUS_OBJECT_PATH,
+ DEVICED_DBUS_INTERFACE_NAME,
+ "lockstate");
+ if (msg == NULL) {
+ ERR("g_dbus_message_new_method_call() has failed");
+ return;
+ }
+
+ g_dbus_message_set_body(msg, g_variant_new("(sssi)", "lcdoff",
+ "staycurstate", "NULL", 0));
+ if (!g_dbus_connection_send_message(conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &err)) {
+ ERR("Unable to send dbus message for acquring lock as %s",
+ err->message);
+ ret = -1;
+ }
+
+ if (ret == 0)
+ is_lock_set = true;
+ g_object_unref(msg);
+ g_dbus_connection_flush_sync(conn, NULL, NULL);
+ g_clear_error(&err);
+}
+
+static void __release_power_lock(void)
+{
+ GError *err = NULL;
+ GDBusConnection *conn;
+ GDBusMessage *msg;
+ int ret = 0;
+
+ if (!is_lock_set)
+ return;
+
+ conn = _get_system_conn();
+ if (conn == NULL)
+ return;
+
+ msg = g_dbus_message_new_method_call(DEVICED_DBUS_PATH,
+ DEVICED_DBUS_OBJECT_PATH,
+ DEVICED_DBUS_INTERFACE_NAME,
+ "unlockstate");
+ if (msg == NULL) {
+ ERR("g_dbus_message_new_method_call() is failed");
+ return;
+ }
+
+ g_dbus_message_set_body(msg, g_variant_new("(ss)", "lcdoff",
+ "sleepmargin"));
+ if (!g_dbus_connection_send_message(conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &err)) {
+ ERR("Unable to send dbus message for releasing lock as %s",
+ err->message);
+ ret = -1;
+ }
+
+ if (ret == 0)
+ is_lock_set = false;
+ g_object_unref(msg);
+ g_dbus_connection_flush_sync(conn, NULL, NULL);
+ g_clear_error(&err);
+
+ return;
+}
+
static gboolean getsize_io_handler(GIOChannel *io, GIOCondition cond,
gpointer data)
{
@@ -308,6 +411,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 +1720,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 +1758,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 +1799,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 +1863,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;