#include "da_data.h"
#include "wsi.h"
#include "cpp/features/feature_manager_c.h"
+#include "cpp/auxd/auxd_client_c.h"
#include <sys/stat.h>
#include <fcntl.h>
pthread_mutex_unlock(&stop_all_mutex);
}
+static void terminate_web_app(const char *app_id)
+{
+ if (!auxd_client_tizen_app_terminate(manager.auxd_client, app_id))
+ LOGE("Cannot terminate app_id='%s'\n", app_id);
+}
+
static void stop_web_apps(void)
{
const struct app_info_t *app_info;
app_info = app_info_get_first(&app);
while (app_info) {
if (app_info->app_type == APP_TYPE_WEB)
- kill_app_web(app_info->app_id);
+ terminate_web_app(app_info->app_id);
app_info = app_info_get_next(&app);
}
}
return 0;
}
-int exec_with_user(const char *username, const char *path,
- char *const app_argv[])
-{
- int ret;
-
- if (username) {
- int myuid = getuid();
-
- if (myuid != 0) {
- LOGE("uid %d is not root\n", myuid);
- } else {
- ret = change_user(username);
- if (ret)
- LOGE("failed to set user \"%s\"\n", username);
- }
- }
-
- ret = execv(path, app_argv);
- if (ret < 0)
- LOGE("failed to exec \"%s\"(%d)\n", path, ret);
-
- _Exit(EXIT_FAILURE);
-}
-
-/* execute applcation with executable binary path */
-int exec_app_tizen(const char *app_id, const char *exec_path)
-{
- pid_t pid;
-
- LOGI("exec %s\n", exec_path);
-
- if (exec_path == NULL || !strlen(exec_path)) {
- LOGE("Executable path is not correct\n");
- return -1;
- }
- LOGI("launch app path is %s, executable path is %s\n"
- "launch app name (%s), app_id (%s)\n",
- LAUNCH_APP_PATH, exec_path, LAUNCH_APP_NAME, app_id);
-
- pid = fork();
- if (pid == -1)
- return -1;
-
- if (pid > 0) { /* parent */
- int status, ret;
- do
- ret = waitpid(pid, &status, 0);
- while (ret == -1 && errno == EINTR);
- return 0;
- } else { /* child */
- char *app_argv[] = {
- LAUNCH_APP_NAME,
- (char *)app_id,
- NULL
- };
-
- exec_with_user(EXEC_USER, LAUNCH_APP_PATH, app_argv);
- }
-
- return 0;
-}
-
-int exec_app_common(const char* exec_path)
-{
- pid_t pid;
-
- LOGI("exec %s\n", exec_path);
- if (exec_path == NULL || !strlen(exec_path)) {
- LOGE("Executable path is not correct\n");
- return -1;
- }
-
- pid = fork();
- if (pid == -1)
- return -1;
-
- if (pid > 0) { /* parent */
- return 0;
- } else { /* child */
- char command[PATH_MAX];
- char *app_argv[] = {
- SHELL_CMD,
- "-c",
- command,
- NULL
- };
-
- snprintf(command, sizeof(command), "%s", exec_path);
- LOGI("cmd: <%s>\n", command);
- exec_with_user(EXEC_USER, SHELL_CMD, app_argv);
- }
-
- return 0;
-}
-
-int exec_app_web(const char *app_id)
-{
- pid_t pid;
-
- LOGI("wrt-launcher path is %s,\n"
- "wrt-launcher name (%s), app_id (%s)\n",
- APP_LAUNCHER_PATH, APP_LAUNCHER_NAME, app_id);
-
- pid = fork();
- if (pid == -1)
- return -1;
-
- if (pid > 0) { /* parent */
- int status, ret;
- do
- ret = waitpid(pid, &status, 0);
- while (ret == -1 && errno == EINTR);
- return 0;
- } else { /* child */
- char *web_argv_with_profile[] = {
- APP_LAUNCHER_NAME,
- "-w"
- "-s",
- (char *)app_id,
- NULL
- };
- char *web_argv[] = {
- APP_LAUNCHER_NAME,
- "-s",
- (char *)app_id,
- NULL
- };
-
- if (is_feature_enabled(FL_WEB_PROFILING))
- exec_with_user(EXEC_USER, APP_LAUNCHER_PATH,
- web_argv_with_profile);
- else
- exec_with_user(EXEC_USER, APP_LAUNCHER_PATH, web_argv);
- }
-
- return 0;
-}
-
-void kill_app_web(const char *app_id)
-{
- pid_t pid;
-
- LOGI("wrt-launcher path is %s,\n"
- "wrt-launcher name (%s), app_id (%s)\n",
- APP_LAUNCHER_PATH, APP_LAUNCHER_NAME, app_id);
-
- pid = fork();
- if (pid == -1)
- return;
-
- if (pid > 0) { /* parent */
- int status, ret;
- do
- ret = waitpid(pid, &status, 0);
- while (ret == -1 && errno == EINTR);
- return;
- } else { /* child */
- char *web_argv[] = {
- APP_LAUNCHER_NAME,
- "-k",
- (char *)app_id,
- NULL
- };
-
- exec_with_user(EXEC_USER, APP_LAUNCHER_PATH, web_argv);
- /* FIXME: If code flows here, it deserves greater attention */
- LOGE("Cannot run exec!\n");
- _Exit(EXIT_FAILURE);
- }
-}
-
static char *dereference_tizen_exe_path(const char *path, char *resolved);
int is_same_app_process(char* appPath, int pid)