Naive implementation of launch/kill web app (type 4).
Change-Id: Id047a329199b15a7992b94e59d0cbcbc3d7c4e0b
Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
pthread_mutex_unlock(&stop_all_mutex);
}
+static void stop_web_apps(void)
+{
+ const struct app_info_t *app_info;
+ struct app_list_t *app = NULL;
+
+ 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);
+ app_info = app_info_get_next(&app);
+ }
+}
+
enum ErrorCode stop_all(void)
{
enum ErrorCode error_code = ERR_NO;
+ stop_web_apps();
+
pthread_mutex_lock(&stop_all_mutex);
error_code = stop_all_no_lock();
pthread_mutex_unlock(&stop_all_mutex);
APP_TYPE_TIZEN = 1,
APP_TYPE_RUNNING = 2,
APP_TYPE_COMMON = 3,
+ APP_TYPE_WEB = 4
};
struct app_info_t {
if (!res)
LOGE("wrong app id for APP_COMMON\n");
break;
+ case APP_TYPE_WEB:
+ res = 1;
+ break;
default :
LOGE("wrong app type\n");
return 0;
// Max values defines
#define APP_INFO_TYPE_MIN 0x0001
-#define APP_INFO_TYPE_MAX 0x0003
+#define APP_INFO_TYPE_MAX 0x0004
#define CONF_SYSTRACE_PERIOD_MIN 10
#define CONF_SYSTRACE_PERIOD_MAX 1000
return 0;
}
if (!parse_string(msg, &app_info->exe_path) ||
- !check_exec_path(app_info->exe_path))
+ ((app_info->app_type != APP_TYPE_WEB) &&
+ !check_exec_path(app_info->exe_path)))
{
LOGE("exec path parsing error\n");
return 0;
case APP_TYPE_COMMON:
res = kill_app(app_info->exe_path);
break;
+ case APP_TYPE_WEB:
+ /* do nothing (it is restarted by itself */
+ break;
default:
LOGE("Unknown app type %d\n", app_info->app_type);
res = -1;
inc_apps_to_run();
}
break;
+ case APP_TYPE_WEB:
+ if (exec_app_web(app_info->app_id)) {
+ LOGE("Cannot exec web app %s\n", app_info->app_id);
+ res = -1;
+ }
+ break;
default:
LOGE("Unknown app type %d\n", app_info->app_type);
res = -1;
}
}
+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",
+ WRT_LAUNCHER_PATH, WRT_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 */
+ execl(WRT_LAUNCHER_PATH,
+ WRT_LAUNCHER_NAME,
+ WRT_LAUNCHER_LAUNCH,
+ app_id,
+ NULL);
+ /* FIXME: If code flows here, it deserves greater attention */
+ LOGE("Cannot run exec!\n");
+ _Exit(EXIT_FAILURE);
+ }
+}
+
+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",
+ WRT_LAUNCHER_PATH, WRT_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 */
+ execl(WRT_LAUNCHER_PATH,
+ WRT_LAUNCHER_NAME,
+ WRT_LAUNCHER_KILL,
+ app_id,
+ NULL);
+ /* FIXME: If code flows here, it deserves greater attention */
+ LOGE("Cannot run exec!\n");
+ _Exit(EXIT_FAILURE);
+ }
+}
+
// find process id from executable binary path
pid_t find_pid_from_path(const char* path)
{
#define LAUNCH_APP_PATH "/usr/bin/launch_app"
#define KILL_APP_PATH "/usr/bin/pkill"
#define LAUNCH_APP_NAME "launch_app"
+#define WRT_LAUNCHER_PATH "/usr/bin/wrt-launcher"
+#define WRT_LAUNCHER_NAME "wrt-launcher"
+#define WRT_LAUNCHER_LAUNCH "-s"
+#define WRT_LAUNCHER_KILL "-k"
#define LAUNCH_APP_SDK "__AUL_SDK__"
#define DA_PRELOAD_EXEC "DYNAMIC_ANALYSIS"
#define DA_PRELOAD(AppType) AppType ? DA_PRELOAD_OSP : DA_PRELOAD_TIZEN
int exec_app_tizen(const char *app_id, const char *exec_path);
int exec_app_common(const char* exec_path);
+int exec_app_web(const char *app_id);
+void kill_app_web(const char *app_id);
char *dereference_tizen_exe_path(const char *path, char *resolved);
void fd_setup_smack_attributes(int fd);
float get_uptime(void);