response);
}
- void LaunchCheckTerminate() {
- ScopeLogger();
- timeout_id_ = g_timeout_add(3000, CheckTerminate, this);
- LoggerD("END");
- }
-
private:
- static gboolean CheckTerminate(gpointer user_data) {
- ScopeLogger();
- TerminateHandler* that = static_cast<TerminateHandler*>(user_data);
- LoggerD("PID: %d", that->pid_);
-
- // we're canceling the callback by returning false, no need for Invoke() to do that again
- that->timeout_id_ = 0;
-
- char* app_id = nullptr;
- std::shared_ptr<picojson::value> response{new picojson::value(picojson::object())};
-
- LoggerD("checking if application is still alive");
- int ret = app_manager_get_app_id(that->pid_, &app_id);
- if (APP_MANAGER_ERROR_NONE == ret) {
- free(app_id);
- // context is still alive, report error
- LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to kill application."),
- &response->get<picojson::object>(), ("application is alive - failure"));
- } else {
- LoggerD("application is dead - success: %d (%s)", ret, get_error_message(ret));
- ReportSuccess(response->get<picojson::object>());
- }
-
- that->Invoke(response);
- delete that;
-
- return false;
- }
-
int callback_handle_;
pid_t pid_;
guint timeout_id_;
}
auto kill = [this, callback_id, context_id]() -> void {
- ScopeLogger("Kill async");
+ ScopeLogger("Kill");
std::shared_ptr<picojson::value> response =
std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
CHECK_RESULT(result, response, handler)
}
- LoggerD("Kill async, pid: %d", pid);
+ LoggerD("Kill, pid: %d", pid);
char* app_id = nullptr;
int ret = app_manager_get_app_id(pid, &app_id);
CHECK_RESULT(result, response, handler)
}
- LoggerD("Kill async, app ID: %s", app_id);
+ LoggerD("Kill, app ID: %s", app_id);
// acquire application context
app_context_h app_context = nullptr;
}
};
- LoggerD("Kill async, setting callback");
+ LoggerD("Kill, setting callback");
handler->set_pid(pid);
ret = app_manager_set_app_context_event_cb(terminate_callback, handler);
CHECK_RESULT(result, response, handler)
}
- // due to platform issue, sometimes termination event is not reported to callback
- // registered with app_manager_set_app_context_event_cb()
- // this is a workaround, it should be removed when issue is solved
- // handler->LaunchCheckTerminate();
-
- LoggerD("Kill async, KILL!!!!!!!!!");
+ LoggerD("Kill, calling native function");
// terminate application
ret = app_manager_terminate_app(app_context);
CHECK_RESULT(result, response, handler)
}
- LoggerD("Kill async, end, waiting for notification");
+ LoggerD("Kill, end, waiting for notification");
};
- TaskQueue::GetInstance().Queue(kill);
+ kill();
}
void ApplicationManager::Launch(const picojson::value& args) {
const std::string& id = app_id.get<std::string>();
auto launch = [id](const std::shared_ptr<picojson::value>& response) -> void {
- ScopeLogger("Entered into asynchronous function, launch");
+ ScopeLogger("launch");
PlatformResult result = PlatformResult(ErrorCode::NO_ERROR);
const char* app_id = id.c_str();
const int retry_count = 3;
}
};
- auto launch_response = [this](const std::shared_ptr<picojson::value>& response) -> void {
- Instance::PostMessage(&this->instance_, response->serialize().c_str());
- };
-
- TaskQueue::GetInstance().Queue<picojson::value>(launch, launch_response, response);
+ launch(response);
+ Instance::PostMessage(&this->instance_, response->serialize().c_str());
}
void ApplicationManager::LaunchAppControl(const picojson::value& args) {
ReportSuccess(response->get<picojson::object>());
};
- auto launch_response = [this](const std::shared_ptr<picojson::value>& response) -> void {
- ScopeLogger("launch_response");
-
- Instance::PostMessage(&this->instance_, response->serialize().c_str());
- };
-
- TaskQueue::GetInstance().Queue<picojson::value>(launch, launch_response, response);
+ launch(response);
+ Instance::PostMessage(&this->instance_, response->serialize().c_str());
}
// internal impl of app_control_foreach_app_matched() for handling APP_CONTROL_ERROR_APP_NOT_FOUND