2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Elementary.h>
26 #include <glib-object.h>
36 #include <heap-monitor.h>
37 #include <livebox-service.h>
42 #include "critical_log.h"
46 #include "update_monitor.h"
49 #include "so_handler.h"
56 extern void evas_common_font_flush(void);
57 extern int evas_common_font_cache_get(void);
58 extern void evas_common_font_cache_set(int size);
60 #define TEXT_CLASS "tizen"
61 #define TEXT_SIZE -100
64 Ecore_Event_Handler *property_handler;
67 .property_handler = NULL,
71 static Eina_Bool update_font_cb(void *data)
73 lb_system_event_all(LB_SYS_EVENT_FONT_CHANGED);
74 return ECORE_CALLBACK_CANCEL;
77 static Eina_Bool property_cb(void *data, int type, void *event)
79 Ecore_X_Event_Window_Property *info = (Ecore_X_Event_Window_Property *)event;
81 if (info->atom == ecore_x_atom_get("FONT_TYPE_change") || info->atom == ecore_x_atom_get("BADA_FONT_change")) {
87 font = vconf_get_str("db/setting/accessibility/font_name");
89 return ECORE_CALLBACK_PASS_ON;
91 cache = evas_common_font_cache_get();
92 evas_common_font_cache_set(0);
93 evas_common_font_flush();
95 list = edje_text_class_list();
96 EINA_LIST_FREE(list, text) {
97 if (!strncasecmp(text, TEXT_CLASS, strlen(TEXT_CLASS))) {
98 edje_text_class_del(text);
99 edje_text_class_set(text, font, TEXT_SIZE);
100 DbgPrint("Update text class %s (%s, %d)\n", text, font, TEXT_SIZE);
102 DbgPrint("Skip text class %s\n", text);
106 evas_common_font_cache_set(cache);
111 * Try to update all liveboxes
113 if (!ecore_timer_add(0.1f, update_font_cb, NULL)) {
114 ErrPrint("Failed to add timer for updating fonts\n");
115 lb_system_event_all(LB_SYS_EVENT_FONT_CHANGED);
119 return ECORE_CALLBACK_PASS_ON;
122 static void time_changed_cb(keynode_t *node, void *user_data)
124 if (vconf_keynode_get_int(node) != VCONFKEY_SYSMAN_STIME_CHANGED)
127 DbgPrint("Time is changed\n");
128 lb_system_event_all(LB_SYS_EVENT_TIME_CHANGED);
131 static bool app_create(void *data)
136 DbgPrint("Configureation manager is initiated: %d\n", ret);
137 DbgPrint("Scale factor: %lf\n", elm_config_scale_get());
140 setenv("PROVIDER_COM_CORE_THREAD", "true", 0);
142 setenv("PROVIDER_COM_CORE_THREAD", "false", 0);
144 s_info.property_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, property_cb, NULL);
145 if (!s_info.property_handler)
146 ErrPrint("Failed to add a property change event handler\n");
148 ret = livebox_service_init();
149 DbgPrint("Livebox service init: %d\n", ret);
153 * Slave is not able to initiate system, before
154 * receive its name from the master
156 * So create callback doesn't do anything.
159 DbgPrint("Crash recover is initiated: %d\n", ret);
160 ret = update_monitor_init();
161 DbgPrint("Content update monitor is initiated: %d\n", ret);
163 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_STIME, time_changed_cb, NULL);
164 DbgPrint("System time event callback added: %d\n", ret);
169 static void app_terminate(void *data)
173 ret = update_monitor_fini();
174 DbgPrint("Content update monitor is finalized: %d\n", ret);
176 DbgPrint("Crash recover is finalized: %d\n", ret);
179 DbgPrint("client finalized: %d\n", ret);
181 ret = livebox_service_fini();
182 DbgPrint("livebox service fini: %d\n", ret);
184 ecore_event_handler_del(s_info.property_handler);
185 s_info.property_handler = NULL;
190 static void app_pause(void *data)
192 /* Will not be invoked */
196 static void app_resume(void *data)
198 /* Will not be invoked */
202 static void app_region_changed(void *data)
204 lb_system_event_all(LB_SYS_EVENT_REGION_CHANGED);
207 static void app_language_changed(void *data)
209 lb_system_event_all(LB_SYS_EVENT_LANG_CHANGED);
212 static void app_service(service_h service, void *data)
217 static int initialized = 0;
220 ErrPrint("Already initialized\n");
224 ret = service_get_extra_data(service, "name", &name);
225 if (ret != SERVICE_ERROR_NONE) {
226 ErrPrint("Name is not valid\n");
230 ret = service_get_extra_data(service, "secured", &secured);
231 if (ret != SERVICE_ERROR_NONE) {
233 ErrPrint("Secured is not valid\n");
237 if (!!strcasecmp(secured, "true")) {
238 if (s_info.heap_monitor) {
239 heap_monitor_start();
241 // heap_monitor_add_target("/usr/apps/org.tizen."EXEC_NAME"/bin/"EXEC_NAME);
244 /* Don't use the update timer */
245 lb_turn_secured_on();
248 DbgPrint("Name assigned: %s\n", name);
249 DbgPrint("Secured: %s\n", secured);
250 ret = client_init(name);
257 void (*__malloc_initialize_hook)(void) = heap_monitor_init;
259 #if defined(_ENABLE_MCHECK)
260 static inline void mcheck_cb(enum mcheck_status status)
264 ptr = util_get_current_module(NULL);
267 case MCHECK_DISABLED:
268 ErrPrint("[DISABLED] Heap incosistency detected: %s\n", ptr);
271 ErrPrint("[OK] Heap incosistency detected: %s\n", ptr);
274 ErrPrint("[HEAD] Heap incosistency detected: %s\n", ptr);
277 ErrPrint("[TAIL] Heap incosistency detected: %s\n", ptr);
280 ErrPrint("[FREE] Heap incosistency detected: %s\n", ptr);
288 int main(int argc, char *argv[])
291 app_event_callback_s event_callback;
294 #if defined(_ENABLE_MCHECK)
297 option = getenv("PROVIDER_DISABLE_CALL_OPTION");
298 if (option && !strcasecmp(option, "true"))
299 fault_disable_call_option();
301 option = getenv("PROVIDER_HEAP_MONITOR_START");
302 if (option && !strcasecmp(option, "true"))
303 s_info.heap_monitor = 1;
305 setenv("BUFMGR_LOCK_TYPE", "once", 0);
306 setenv("BUFMGR_MAP_CACHE", "true", 0);
308 critical_log_init(util_basename(argv[0]));
309 event_callback.create = app_create;
310 event_callback.terminate = app_terminate;
311 event_callback.pause = app_pause;
312 event_callback.resume = app_resume;
313 event_callback.service = app_service;
314 event_callback.low_memory = NULL;
315 event_callback.low_battery = NULL;
316 event_callback.device_orientation = NULL;
317 event_callback.language_changed = app_language_changed;
318 event_callback.region_format_changed = app_region_changed;
319 ret = app_efl_main(&argc, &argv, &event_callback, NULL);
324 HAPI int main_heap_monitor_is_enabled(void)
326 return s_info.heap_monitor;