From 65571ab8e74036f3470137582d574e48620fc6e5 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 24 Oct 2022 11:31:38 +0900 Subject: [PATCH] Skip application running check when acquiring PID or AppID 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 | 23 ++++++++++++++++++++++- src/client_manager.cpp | 16 ++-------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/application_manager_aul.cpp b/src/application_manager_aul.cpp index 782448b..e2e293e 100644 --- a/src/application_manager_aul.cpp +++ b/src/application_manager_aul.cpp @@ -17,6 +17,8 @@ #include "application_manager_aul.h" #include "service_common.h" +#include + #include #include @@ -28,19 +30,38 @@ CApplicationManagerAul::~CApplicationManagerAul() { } +static void print_duration(std::string func, std::chrono::time_point 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( + std::chrono::duration_cast(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) diff --git a/src/client_manager.cpp b/src/client_manager.cpp index 458c384..9bd575b 100644 --- a/src/client_manager.cpp +++ b/src/client_manager.cpp @@ -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; } -- 2.7.4