2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
22 #include "animation.h"
25 static struct animation {
28 Evas_Object *display_block;
35 .display_block = NULL,
41 static void __win_del_cb(void *data, Evas_Object * obj, void *event_info)
43 __D("Window delete event received");
47 static Evas_Object *__create_window(void)
53 win = elm_win_add(NULL, "BOOT_ANIMATION", ELM_WIN_NOTIFICATION);
55 __E("Failed to create a new window");
58 elm_win_aux_hint_add(win, "wm.comp.win.always.selective.mode", "1");
59 elm_win_role_set(win, "alert");
60 efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_HIGH);
61 evas_object_smart_callback_add(win, "delete-request", __win_del_cb, NULL);
63 elm_win_screen_size_get(win, NULL, NULL, &s_animation.win_w, &s_animation.win_h);
64 elm_win_borderless_set(win, EINA_TRUE);
65 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE);
66 evas_object_move(win, 0, 0);
67 evas_object_show(win);
72 static void __block_display(void)
74 Evas_Object *display_block = NULL;
75 display_block = evas_object_rectangle_add(evas_object_evas_get(s_animation.win));
76 elm_win_resize_object_add(s_animation.win, display_block);
77 evas_object_color_set(display_block, 0, 0, 0, 255);
78 evas_object_show(display_block);
80 s_animation.display_block = display_block;
83 static Eina_Bool __end_cb(void *data)
85 int type = (int) data;
87 if (type == TYPE_OFF) {
88 __D("EXIT on SHUTDOWN");
89 /* Delete Previous Layout */
90 if (s_animation.layout) {
91 evas_object_del(s_animation.layout);
92 s_animation.layout = NULL;
95 /* boot-animation do not terminate on shutdown, so flush log now */
101 __D("EXIT on BOOTING");
102 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) {
103 __E("Failed to set finished set");
107 return ECORE_CALLBACK_CANCEL;
110 static void __animation_finished_cb(void *d, Evas_Object * obj, const char *e, const char *s)
112 if (s_animation.animation_type == TYPE_OFF) {
114 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) {
115 __E("Failed to set finished set");
117 ecore_timer_add(1, __end_cb, (void *)TYPE_OFF);
120 __end_cb((void *)TYPE_ON);
124 static Evas_Object * __create_layout(Evas_Object *win, const char *file_name)
126 Evas_Object *layout = elm_layout_add(win);
128 __E("Failed to create layout");
131 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
132 elm_win_resize_object_add(s_animation.win, layout);
133 elm_layout_signal_callback_add(layout, "end", "animation", __animation_finished_cb, NULL);
135 if (!elm_layout_file_set(layout, file_name, GRP_ANIM)) {
136 __E("Failed to layout file set");
140 evas_object_show(layout);
145 static void __destroy_layout(void)
147 if (s_animation.display_block) {
148 evas_object_del(s_animation.display_block);
149 s_animation.display_block = NULL;
152 if (s_animation.layout) {
153 evas_object_del(s_animation.layout);
154 s_animation.layout = NULL;
158 static char * __get_layout_file_name(int animation_type, int w, int h)
160 char file_name[1024];
163 if (animation_type == TYPE_OFF) {
164 snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOff.edj", w, h);
166 snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", w, h);
168 __D("File name for Animation is: %s", file_name);
170 ret = access(file_name, 0);
173 __E("There's no Image same with [%s], So set Default[720x1280] image", file_name);
174 if (animation_type == TYPE_OFF) {
175 snprintf(file_name, sizeof(file_name), "%s", DEFAULT_OFF);
177 snprintf(file_name, sizeof(file_name), "%s", DEFAULT_ON);
180 ret = access(file_name, 0);
182 __E("There's no Image file[%s] on target", file_name);
187 return strdup(file_name);
190 static Eina_Bool __is_layout_file_exist(const char *file_name)
194 ret = access(file_name, 0);
202 int animation_init(int animation_type)
204 __D("Init animation");
206 s_animation.animation_type = animation_type;
208 s_animation.win = __create_window();
209 if (!s_animation.win) {
210 __E("Failed to create a new window");
214 char *layout_file_name = NULL;
215 layout_file_name = __get_layout_file_name(animation_type, s_animation.win_w, s_animation.win_h);
216 if (!layout_file_name) {
217 __E("Failed to get layout file name");
221 if (!__is_layout_file_exist(layout_file_name)) {
222 __E("This file is not exist");
223 free(layout_file_name);
227 s_animation.layout = __create_layout(s_animation.win, layout_file_name);
228 if (!s_animation.layout) {
229 __E("Failed to create layout");
230 free(layout_file_name);
231 evas_object_del(s_animation.win);
235 free(layout_file_name);
240 int animation_fini(void)
244 evas_object_del(s_animation.win);
252 Evas_Object *__t__get_window(void)
254 return s_animation.win;
257 Evas_Object *__t__get_layout(void)
259 return s_animation.layout;
262 Evas_Object *__t__get_display_block(void)
264 return s_animation.display_block;
267 Evas_Object * __t__animation_create_layout(Evas_Object *win, const char *file_name)
269 return __create_layout(win, file_name);
272 Evas_Object *__t__animation_create_window(void)
274 return __create_window();
277 char * __t__get_layout_file_name(int animation_type, int w, int h)
279 return __get_layout_file_name(animation_type, w, h);
282 Eina_Bool __t__is_layout_file_exist(const char *file_name)
284 return __is_layout_file_exist(file_name);