4 * Copyright (c) 2016 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 "popup-common.h"
21 #include <pkgmgr-info.h>
25 static int appinfo_get_appname_func(pkgmgrinfo_appinfo_h handle, void *data)
31 _D("appinfo_get_appname_func() is entered");
33 return PMINFO_R_ERROR;
35 ret = pkgmgrinfo_appinfo_get_label(handle, &str);
36 if (ret != PMINFO_R_OK)
40 return PMINFO_R_ERROR;
44 return PMINFO_R_ERROR;
46 (*(char**)data) = label;
48 _D("appinfo_get_appname_func() is finished");
52 static int get_app_name(char *exepath, char *tname, unsigned int len)
54 pkgmgrinfo_appinfo_filter_h handle = NULL;
58 _D("get_app_name() is entered");
59 ret = pkgmgrinfo_appinfo_filter_create(&handle);
60 if (ret != PMINFO_R_OK)
63 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
64 PMINFO_APPINFO_PROP_APP_EXEC, exepath);
65 if (ret != PMINFO_R_OK)
68 ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
69 if (ret != PMINFO_R_OK)
75 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle,
76 appinfo_get_appname_func, &name);
77 if (ret != PMINFO_R_OK) {
84 pkgmgrinfo_appinfo_filter_destroy(handle);
88 snprintf(tname, len, "%s", name);
90 _D("get_app_name() is finished");
94 static int crash_get_content(const struct popup_ops *ops, char *content, unsigned int len)
98 struct object_ops *obj;
99 char *text, *name, *path;
102 if (!ops || !content)
105 ret = get_object_by_ops(ops, &obj);
107 _E("Failed to get object (%d)", ret);
111 name = (char *)bundle_get_val(obj->b, "_PROCESS_NAME_");
113 _E("Failed to get process name");
117 path = (char *)bundle_get_val(obj->b, "_EXEPATH_");
119 _E("Failed to get execution path");
124 ret = get_app_name(path, tname, l);
126 snprintf(tname, l, "%s", name);
128 _I("name(%s), path(%s), tname(%s)", name, path, tname);
130 text = _("WDS_TPLATFORM_BODY_PS_HAS_STOPPED");
131 snprintf(content, len, text, tname);
136 static const struct popup_ops crash_ops = {
138 .pattern = FEEDBACK_PATTERN_LOWBATT,
139 .show = load_simple_popup,
140 .title = "IDS_IDLE_HEADER_ERROR_OCCURRED",
141 .get_content = crash_get_content,
142 .left_text = "IDS_COM_SK_OK",
145 static __attribute__ ((constructor)) void crash_register_popup(void)
147 register_popup(&crash_ops);