#include "application_manager_aul.h"
#include "service_common.h"
+#include <chrono>
+
#include <aul.h>
#include <aul_svc.h>
{
}
+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)
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());
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;
}