/*
- * boot-animation
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <dirent.h>
-
#include <vconf.h>
+#include <efl_util.h>
-#include <Elementary.h>
-
-#include <boot.h>
-#include <animation.h>
-
-#include "log.h"
-
-#define OVER_COUNT 19
+#include "boot.h"
+#include "animation.h"
+#include "app_log.h"
static struct animation {
Evas_Object *win;
- Evas_Coord w;
- Evas_Coord h;
- int t;
- Evas *evas;
- Ecore_Evas *ee;
Evas_Object *layout;
- int state;
- Evas_Object *txt;
+ Evas_Object *display_block;
+ Evas_Coord win_w;
+ Evas_Coord win_h;
+ int animation_type;
} s_animation = {
- .txt = NULL,};
-
-static void win_del(void *data, Evas_Object * obj, void *event_info)
+ .win = NULL,
+ .layout = NULL,
+ .display_block = NULL,
+ .win_w = 0,
+ .win_h = 0,
+ .animation_type = 0,
+};
+
+static void __win_del_cb(void *data, Evas_Object * obj, void *event_info)
{
- _D("Window delete event received");
+ __D("Window delete event received");
elm_exit();
}
-static Eina_Bool _end_cb(void *data)
+static Evas_Object *__create_window(void)
{
- _D("_end_cb is invoked");
- printf("_end_cb is invoked\n");
- if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
- _E("Failed to set finished set");
- elm_exit();
- return ECORE_CALLBACK_CANCEL;
+ __D("Create Window");
+
+ Evas_Object *win;
+
+ win = elm_win_add(NULL, "BOOT_ANIMATION", ELM_WIN_NOTIFICATION);
+ if (!win) {
+ __E("Failed to create a new window");
+ return NULL;
+ }
+ elm_win_aux_hint_add(win, "wm.comp.win.always.selective.mode", "1");
+ elm_win_role_set(win, "alert");
+ efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_HIGH);
+ evas_object_smart_callback_add(win, "delete-request", __win_del_cb, NULL);
+
+ elm_win_screen_size_get(win, NULL, NULL, &s_animation.win_w, &s_animation.win_h);
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE);
+ evas_object_move(win, 0, 0);
+ evas_object_show(win);
+
+ return win;
}
-static void _edje_cb(void *d, Evas_Object * obj, const char *e, const char *s)
+static void __block_display(void)
{
- _D("edje callback is invoked");
+ Evas_Object *display_block = NULL;
+ display_block = evas_object_rectangle_add(evas_object_evas_get(s_animation.win));
+ elm_win_resize_object_add(s_animation.win, display_block);
+ evas_object_color_set(display_block, 0, 0, 0, 255);
+ evas_object_show(display_block);
- if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) {
- _D("TYPE OFF");
- if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
- _E("Failed to set finished set");
- if (s_animation.txt) {
- Evas_Coord w;
- Evas_Coord h;
-
- evas_object_size_hint_weight_set(s_animation.txt,
- EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(s_animation.txt,
- EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- evas_object_resize(s_animation.txt, s_animation.w,
- s_animation.h);
- evas_object_color_set(s_animation.txt, 255, 255, 255,
- 255);
- evas_object_text_font_set(s_animation.txt,
- "SLP:style=medium", 30);
- evas_object_geometry_get(s_animation.txt, NULL, NULL,
- &w, &h);
- evas_object_move(s_animation.txt,
- (s_animation.w - w) >> 1,
- (s_animation.h - h) >> 1);
- evas_object_show(s_animation.txt);
- }
- ecore_timer_add(1, _end_cb, NULL);
- } else
- _D("TYPE_ON");
- _end_cb(NULL);
+ s_animation.display_block = display_block;
}
-#define DEFAULT_W 480
-static void layout_file_set(int state)
+static Eina_Bool __end_cb(void *data)
{
- _D("Layout file set according to resolution");
- _D("Screen Width: %d, DEFAULT_WIDTH: %d", s_animation.w, DEFAULT_W);
-
- if (s_animation.w < DEFAULT_W) {
- if (state == TYPE_ON) {
- _D("Set file: %s", WEARABLE_EDJ_ON);
- elm_layout_file_set(s_animation.layout, WEARABLE_EDJ_ON, GRP_ON);
- } else {
- _D("Set file: %s", WEARABLE_EDJ_OFF);
- elm_layout_file_set(s_animation.layout, WEARABLE_EDJ_OFF, GRP_OFF);
- }
- } else if (s_animation.w > DEFAULT_W) {
- if (state == TYPE_ON) {
- _D("Set file: %s", MOBILE_EDJ_ON);
- elm_layout_file_set(s_animation.layout, MOBILE_EDJ_ON, GRP_ON);
- } else {
- _D("Set file: %s", MOBILE_EDJ_OFF);
- elm_layout_file_set(s_animation.layout, MOBILE_EDJ_OFF, GRP_OFF);
+ int type = (int) data;
+
+ if (type == TYPE_OFF) {
+ __D("EXIT on SHUTDOWN");
+ /* Delete Previous Layout */
+ if (s_animation.layout) {
+ evas_object_del(s_animation.layout);
+ s_animation.layout = NULL;
}
+
+ /* boot-animation do not terminate on shutdown, so flush log now */
+ fflush(stdout);
+ close(1);
+
+ __block_display();
} else {
- if (state == TYPE_ON) {
- _D("Set file: %s", DEFAULT_EDJ_ON);
- elm_layout_file_set(s_animation.layout, DEFAULT_EDJ_ON, GRP_ON);
- } else {
- _D("Set file: %s", DEFAULT_EDJ_OFF);
- elm_layout_file_set(s_animation.layout, DEFAULT_EDJ_OFF, GRP_OFF);
- }
+ __D("EXIT on BOOTING");
+ if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
+ __E("Failed to set finished set");
+
+ boot_exit();
}
+ return ECORE_CALLBACK_CANCEL;
}
-static int init_layout(const char *msg)
+static void __animation_finished_cb(void *d, Evas_Object * obj, const char *e, const char *s)
{
- s_animation.layout = elm_layout_add(s_animation.win);
- if (!s_animation.layout) {
- _E("Failed to create layout");
- return EXIT_FAILURE;
+ if (s_animation.animation_type == TYPE_OFF) {
+ __D("TYPE OFF");
+ if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
+ __E("Failed to set finished set");
+
+ ecore_timer_add(1, __end_cb, (void *)TYPE_OFF);
+ } else {
+ __D("TYPE_ON");
+ __end_cb((void *)TYPE_ON);
}
+}
- layout_file_set(s_animation.state);
-
- evas_object_size_hint_weight_set(s_animation.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- _D("[Boot-ani] Start animation: %d mode", s_animation.state);
- elm_win_resize_object_add(s_animation.win, s_animation.layout);
- edje_object_signal_callback_add(elm_layout_edje_get(s_animation.layout), "end", "animation", _edje_cb, NULL);
- evas_object_show(s_animation.layout);
-
- if (msg) {
- if (!s_animation.txt) {
- s_animation.txt = evas_object_text_add(s_animation.evas);
- if (!s_animation.txt) {
- _E("Failed to add text");
- evas_object_del(s_animation.layout);
- return EXIT_FAILURE;
- }
- }
+static Evas_Object * __create_layout(Evas_Object *win, const char *file_name)
+{
+ Evas_Object *layout = elm_layout_add(win);
+ if (!layout) {
+ __E("Failed to create layout");
+ return NULL;
+ }
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(s_animation.win, layout);
+ elm_layout_signal_callback_add(layout, "end", "animation", __animation_finished_cb, NULL);
- evas_object_text_text_set(s_animation.txt, msg);
- evas_object_hide(s_animation.txt);
+ if (!elm_layout_file_set(layout, file_name, GRP_ANIM)) {
+ __E("Failed to layout file set");
+ return NULL;
}
- return EXIT_SUCCESS;
+ evas_object_show(layout);
+
+ return layout;
}
-static void fini_layout(void)
+static void __destroy_layout(void)
{
+ if (s_animation.display_block) {
+ evas_object_del(s_animation.display_block);
+ s_animation.display_block = NULL;
+ }
+
if (s_animation.layout) {
evas_object_del(s_animation.layout);
+ s_animation.layout = NULL;
}
+}
- if (s_animation.txt) {
- evas_object_del(s_animation.txt);
- s_animation.txt = NULL;
+static char * __get_layout_file_name(int animation_type, int w, int h)
+{
+ char file_name[1024];
+ int ret = 0;
+
+ if (animation_type == TYPE_OFF)
+ snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOff.edj", w, h);
+ else
+ snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", w, h);
+
+ __D("File name for Animation is: %s", file_name);
+
+ ret = access(file_name, 0);
+ if (ret != 0) {
+ __E("There's no Image same with [%s], So set Default[720x1280] image", file_name);
+ __D("There's no Image same with [%s], So set Default[720x1280] image", file_name);
+ if (animation_type == TYPE_OFF)
+ snprintf(file_name, sizeof(file_name), "%s", DEFAULT_OFF);
+ else
+ snprintf(file_name, sizeof(file_name), "%s", DEFAULT_ON);
+
+ ret = access(file_name, 0);
+ if (ret) {
+ __E("There's no Image file[%s] on target", file_name);
+ __D("There's no Image file[%s] on target", file_name);
+ return NULL;
+ }
}
+
+ return strdup(file_name);
}
-static int create_window(void)
+static Eina_Bool __is_layout_file_exist(const char *file_name)
{
- _D("Create Window");
- printf("Create Window\n");
+ int ret = 0;
- int x, y = 0;
+ ret = access(file_name, 0);
+ if (ret == 0)
+ return EINA_TRUE;
+ else
+ return EINA_FALSE;
+}
+
+int animation_init(int animation_type)
+{
+ __D("Init animation");
- s_animation.win = elm_win_add(NULL, "BOOT_ANIMATION", ELM_WIN_NOTIFICATION);
- elm_win_role_set(s_animation.win, "alert");
+ s_animation.animation_type = animation_type;
+
+ s_animation.win = __create_window();
if (!s_animation.win) {
- _E("Failed to create a new window");
- printf("Failed to create a new window\n");
+ __E("Failed to create a new window");
return EXIT_FAILURE;
}
- if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) {
- _D("We are turning off the Tizen");
- elm_win_alpha_set(s_animation.win, EINA_TRUE);
- }
- evas_object_smart_callback_add(s_animation.win, "delete-request", win_del, NULL);
- s_animation.evas = evas_object_evas_get(s_animation.win);
- if (!s_animation.evas) {
- evas_object_del(s_animation.win);
- _E("Failed to get the evas object");
+ char *layout_file_name = NULL;
+ layout_file_name = __get_layout_file_name(animation_type, s_animation.win_w, s_animation.win_h);
+ if (!layout_file_name) {
+ __E("Failed to get layout file name");
return EXIT_FAILURE;
}
- elm_win_screen_size_get(s_animation.win, &x, &y, &s_animation.w, &s_animation.h);
- _D("Window size is x: %d, y: %d, w: %d, h: %d", x, y, s_animation.w, s_animation.h);
- elm_win_borderless_set(s_animation.win, 1);
- elm_win_indicator_mode_set(s_animation.win, ELM_WIN_INDICATOR_HIDE);
- evas_object_move(s_animation.win, 0, 0);
-
- if (s_animation.w > s_animation.h) {
- int t;
- elm_win_rotation_with_resize_set(s_animation.win, 90);
- /* Update geometry infomration */
- t = s_animation.w;
- s_animation.w = s_animation.h;
- s_animation.h = t;
- }
- evas_object_show(s_animation.win);
+ if (!__is_layout_file_exist(layout_file_name)) {
+ __E("This file is not exist");
+ free(layout_file_name);
+ return EXIT_FAILURE;
+ }
- s_animation.ee = ecore_evas_ecore_evas_get(s_animation.evas);
- if (!s_animation.ee) {
+ s_animation.layout = __create_layout(s_animation.win, layout_file_name);
+ if (!s_animation.layout) {
+ __E("Failed to create layout");
+ free(layout_file_name);
evas_object_del(s_animation.win);
- _E("Failed to get the ecore evas object");
return EXIT_FAILURE;
}
+ free(layout_file_name);
+
return EXIT_SUCCESS;
}
-int init_animation(int state, const char *msg)
+int animation_fini(void)
{
- _D("Init animation");
- printf("Init animation\n");
+ __destroy_layout();
- Ecore_Timer *timer = NULL;
+ evas_object_del(s_animation.win);
+ fflush(stdout);
+ close(1);
+ return EXIT_SUCCESS;
+}
- s_animation.state = state;
+#include "test.h"
+#if TEST_MODE
+Evas_Object *__t__get_window(void)
+{
+ return s_animation.win;
+}
- if (create_window() == EXIT_FAILURE) {
- _E("Failed to create a new window");
- printf("Failed to create a new window\n");
- return EXIT_FAILURE;
- }
+Evas_Object *__t__get_layout(void)
+{
+ return s_animation.layout;
+}
- if (init_layout(msg) == EXIT_FAILURE) {
- _E("Failed to init the layout object");
- if (msg) {
- evas_object_del(s_animation.txt);
- }
- evas_object_del(s_animation.win);
- }
+Evas_Object *__t__get_display_block(void)
+{
+ return s_animation.display_block;
+}
- return EXIT_SUCCESS;
+Evas_Object * __t__animation_create_layout(Evas_Object *win, const char *file_name)
+{
+ return __create_layout(win, file_name);
}
-int fini_animation(void)
+Evas_Object *__t__animation_create_window(void)
{
- fini_layout();
- evas_object_del(s_animation.win);
- fflush(stdout);
- close(1);
- return EXIT_SUCCESS;
+ return __create_window();
+}
+
+char * __t__get_layout_file_name(int animation_type, int w, int h)
+{
+ return __get_layout_file_name(animation_type, w, h);
+}
+
+Eina_Bool __t__is_layout_file_exist(const char *file_name)
+{
+ return __is_layout_file_exist(file_name);
}
+#endif