4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <Elementary.h>
21 #include <app_manager.h>
22 //#include <app_manager_extension.h>
23 #include <app_control.h>
31 extern Eina_Bool util_kill_app(const char *appid)
33 app_context_h context = NULL;
34 Eina_Bool ret = EINA_TRUE;
36 retv_if(!appid, EINA_FALSE);
38 ret = app_manager_get_app_context(appid, &context);
39 if (ret != APP_MANAGER_ERROR_NONE) {
40 _E("fail to app_manager_get_app_context(%d)", ret);
44 ret = app_manager_terminate_app(context);
45 app_context_destroy(context);
47 if (ret != APP_MANAGER_ERROR_NONE) {
48 _E("fail to terminate_app (%d)", ret);
52 _D("terminate app = %s", appid);
59 extern Eina_Bool util_launch_app(const char *appid)
64 if (!appid || strlen(appid) == 0) {
65 _E("Fail to launch, due to Null appid.");
68 _D("Launching: %s", appid);
69 ret = app_manager_is_running(appid, &running);
70 retv_if(APP_MANAGER_ERROR_NONE != ret, EINA_FALSE);
73 _D("THE APP IS RUNNING");
75 app_context_h context = NULL;
76 ret = app_manager_get_app_context(appid, &context);
77 if (ret != APP_MANAGER_ERROR_NONE) {
78 _E("fail to app_manager_get_app_context(%d)", ret);
82 ret = app_manager_resume_app(context);
83 app_context_destroy(context);
85 if (ret != APP_MANAGER_ERROR_NONE) {
86 _E("fail to app_manager_resume_app(%d)", ret);
91 _D("THE APP IS NOT RUNNING");
93 app_control_h service = NULL;
94 retv_if(APP_CONTROL_ERROR_NONE != app_control_create(&service), EINA_FALSE);
95 retv_if(!service, EINA_FALSE);
97 app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
98 app_control_set_app_id(service, appid);
100 ret = app_control_send_launch_request(service, NULL, NULL);
101 (void)app_control_destroy(service);
102 retv_if(APP_CONTROL_ERROR_NONE != ret, EINA_FALSE);