Skip application running check when acquiring PID or AppID 08/283308/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 24 Oct 2022 02:31:38 +0000 (11:31 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 24 Oct 2022 02:31:40 +0000 (11:31 +0900)
Since the application running check is already performed
when wakeup event gets processed, there is no need to
check the running status every time PID or AppID is acquired.

Change-Id: If93f64f67cfde458123fca6c16f18713fd5118e8

src/application_manager_aul.cpp
src/client_manager.cpp

index 782448b..e2e293e 100644 (file)
@@ -17,6 +17,8 @@
 #include "application_manager_aul.h"
 #include "service_common.h"
 
+#include <chrono>
+
 #include <aul.h>
 #include <aul_svc.h>
 
@@ -28,19 +30,38 @@ CApplicationManagerAul::~CApplicationManagerAul()
 {
 }
 
+static void print_duration(std::string func, std::chrono::time_point<std::chrono::steady_clock> started)
+{
+       const std::chrono::milliseconds threshold(100);
+       auto finished = std::chrono::steady_clock::now();
+       auto interval = finished - started;
+       if (interval > threshold) {
+               long long int count = static_cast<long long int>(
+                       std::chrono::duration_cast<std::chrono::milliseconds>(interval).count());
+               MAS_LOGE("%s %lld", func.c_str(), count);
+       }
+}
+
 bool CApplicationManagerAul::is_application_running(pid_t pid)
 {
+       auto started = std::chrono::steady_clock::now();
+
        int status = aul_app_get_status_bypid(pid);
        if (0 > status) {
                MAS_LOGE("The process %d does not exist : %d", pid, status);
+               print_duration(__func__, started);
                return false;
        }
+       print_duration(__func__, started);
        return true;
 }
 
 bool CApplicationManagerAul::is_application_running(const std::string& appid)
 {
-       return (!!aul_app_is_running(appid.c_str()));
+       auto started = std::chrono::steady_clock::now();
+       bool ret = (!!aul_app_is_running(appid.c_str()));
+       print_duration(__func__, started);
+       return ret;
 }
 
 bool CApplicationManagerAul::bring_app_to_foreground(const std::string& appid)
index 458c384..9bd575b 100644 (file)
@@ -149,13 +149,7 @@ pid_t CClientManager::find_client_pid_by_appid(std::string appid)
 
        ma_client_s* client = find_client_by_appid(appid);
        if (client) {
-               bool running = mApplicationManager->is_application_running(client->pid);
-               if (false == running) {
-                       MAS_LOGE("The PID for %s was %d, but it seems to be terminated",
-                               appid.c_str(), client->pid);
-               } else {
-                       pid = client->pid;
-               }
+               pid = client->pid;
        }
        if (-1 == pid) {
                MAS_LOGE("PID lookup failed for : %s", appid.c_str());
@@ -174,13 +168,7 @@ std::string CClientManager::find_client_appid_by_pid(pid_t pid)
 
        ma_client_s* client = find_client_by_pid(pid);
        if (client) {
-               bool running = mApplicationManager->is_application_running(pid);
-               if (false == running) {
-                       MAS_LOGE("The appid for %d was %s, but it seems to be terminated",
-                               pid, client->appid.c_str());
-               } else {
-                       appid = client->appid;
-               }
+               appid = client->appid;
        }
        return appid;
 }