[Non-ACR] check file availability 03/244903/2 accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.115351 accepted/tizen/6.0/unified/hotfix/20201103.003958 accepted/tizen/unified/20200927.212957 submit/tizen/20200927.121338 submit/tizen_6.0/20201029.205104 submit/tizen_6.0_hotfix/20201102.192504 submit/tizen_6.0_hotfix/20201103.114804 tizen_6.0.m2_release
authorAbhishek Vijay <abhishek.v@samsung.com>
Fri, 25 Sep 2020 13:55:10 +0000 (19:25 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Sun, 27 Sep 2020 12:11:19 +0000 (12:11 +0000)
Change-Id: Ibebb9f69e40ef63b62d34704a79998f5c2c5c166
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
include/bm_util.h
src/battery_dump/bm_listeners.c
src/bm_util.c

index 06d8aff..3349270 100644 (file)
@@ -61,7 +61,7 @@ GDBusConnection* bm_get_dbus_connection_obj(void);
 
 void bd_get_focussed_app_id(char **app_name);
 
-void bm_get_name_from_pid(pid_t pid, char **pname);
+void bm_get_name_for_pid(pid_t pid, char **pname);
 
 void bm_data_free(gpointer data);
 
index d390fe7..160b36b 100644 (file)
@@ -1714,21 +1714,29 @@ static void _bd_listener_create_lock_event(char *lock_type, pid_t pid)
        static int prev_lock = 0;
        char *pname = NULL;
 
+       _INFO("lock [%s], pid [%d]", lock_type, pid);
+
        if (g_strcmp0(lock_type, "lcdoff") == 0)
                val = 0;
        else if (g_strcmp0(lock_type, "lcddim") == 0)
                val = 1;
        else if (g_strcmp0(lock_type, "lcdon") == 0)
                val = 2;
-       else
+       else {
+               _DBG("different lock_type - [%s]", lock_type);
                return;
+       }
 
-       if (prev_lock == val)
+       if (prev_lock == val) {
+               _DBG("return due to same values");
                return;
-       else
+       } else {
                prev_lock = val;
+       }
+
+       bm_get_name_for_pid(pid, &pname);
 
-       bm_get_name_from_pid(pid, &pname);
+       _DBG("received process name - [%s]", pname);
 
        /* get event object */
        event_pool *event = bd_listener_get_event_obj(LISTEN_POWERLOCKUNLOCK_STATE, val, pname);
@@ -1749,9 +1757,11 @@ static void _bd_listener_powerlock_signal_cb(GDBusConnection *conn, const gchar
                        const gchar *iface, const gchar *signal, GVariant *params, gpointer user_data)
 {
        ENTER;
+
        pid_t pid;
        char *lock_type;
        unsigned int timeout;
+
        g_variant_get(params, "(&sii)", &lock_type, &pid, &timeout);
 
        _INFO(" powerlock value changed =%s Pid=%d, timeout=%d", lock_type, pid, timeout);
@@ -1766,6 +1776,7 @@ static void _bd_listener_powerunlock_signal_cb(GDBusConnection *conn, const gcha
                        const gchar *iface, const gchar *signal, GVariant *params, gpointer user_data)
 {
        ENTER;
+
        pid_t pid;
        char *lock_type;
        unsigned int timeout;
index 5665a51..49f397a 100644 (file)
@@ -369,7 +369,7 @@ void bd_get_focussed_app_id(char **app_name)
        return;
 }
 
-void bm_get_name_from_pid(pid_t pid, char **pname)
+void bm_get_name_for_pid(pid_t pid, char **pname)
 {
        _INFO("pid = [%d]", pid);
 
@@ -383,6 +383,11 @@ void bm_get_name_from_pid(pid_t pid, char **pname)
 
                snprintf(buf, PATH_MAX, "/proc/%d/cmdline", pid);
 
+               if (access(buf, F_OK) != 0) {
+                       _ERR("maybe pid no more exists");
+                       return;
+               }
+
                fd = open(buf, O_RDONLY);
                if (fd < 0) {
                        _ERR("process(%d) does not exist now.", pid);