From bf60dee9819f204814d590cc247a79665c46b9b4 Mon Sep 17 00:00:00 2001 From: YoungHun Cho Date: Fri, 28 Apr 2017 22:18:17 +0900 Subject: [PATCH] code refactoring Change-Id: I4d564d2cd916ced7306312ca1bbaf1df93dd1f2c --- inc/animation.h | 5 +- inc/boot_sound.h | 23 ++++++++ src/animation.c | 1 - src/boot.c | 157 +++++++++---------------------------------------------- src/boot_sound.c | 71 +++++++++++++++++++++++++ test/test_main.c | 1 + 6 files changed, 124 insertions(+), 134 deletions(-) mode change 100644 => 100755 inc/animation.h create mode 100755 inc/boot_sound.h mode change 100644 => 100755 src/boot.c create mode 100755 src/boot_sound.c diff --git a/inc/animation.h b/inc/animation.h old mode 100644 new mode 100755 index a7cd7c1..5ce803a --- a/inc/animation.h +++ b/inc/animation.h @@ -15,8 +15,8 @@ * */ -#ifndef __BOOT_ANIMATION__ -#define __BOOT_ANIMATION__ +#ifndef __BOOT_ANIMATION_H__ +#define __BOOT_ANIMATION_H__ #include @@ -28,3 +28,4 @@ char *get_layout_file_name(int state, int w, int h); Eina_Bool is_layout_file_exist(const char *file_name); #endif + diff --git a/inc/boot_sound.h b/inc/boot_sound.h new file mode 100755 index 0000000..024790c --- /dev/null +++ b/inc/boot_sound.h @@ -0,0 +1,23 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __BOOT_SOUND_H__ +#define __BOOT_SOUND_H__ + +void play_boot_sound(int boot_type); + +#endif diff --git a/src/animation.c b/src/animation.c index f633a0e..6f2e222 100644 --- a/src/animation.c +++ b/src/animation.c @@ -286,4 +286,3 @@ Evas_Object *__t__get_display_block(void) return s_animation.display_block; } #endif - diff --git a/src/boot.c b/src/boot.c old mode 100644 new mode 100755 index 360839d..afb8b8d --- a/src/boot.c +++ b/src/boot.c @@ -15,68 +15,23 @@ * */ -#include +#include +#include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include #include "animation.h" #include "boot.h" #include "app_log.h" -#include "test.h" +#include "boot_sound.h" -#define XRGB8888 4 +#include "test.h" extern char *optarg; -extern int optind, opterr, optopt; - -//#define SOUND_PROFILE -#ifdef SOUND_PROFILE -#include -#endif +extern int optind; void(*boot_exit)(void); -static void print_usages(char *argv0) -{ - __D("Usage) %s {--start|--stop}\n" - " Ex:" - " # %s --start\n" - " # %s --stop\n" - " # %s --off\n", argv0, argv0, argv0, argv0); -} - - -#ifdef SOUND_PROFILE -/* Sound is not supported Since Tizen 4.0 */ -static int get_wav_file(int state, char *wavpath) -{ - __D("Get wav file"); - if (state == TYPE_ON) { - snprintf(wavpath, FILE_PATH_MAX-1, "%s", DEFAULT_POWERON_WAV); - __D("Wav file: %s", wavpath); - } else - return -1; - - return 0; -} -#endif - static int __check_on_off_type(void *user_data) { int c; @@ -96,7 +51,7 @@ static int __check_on_off_type(void *user_data) argv = args->argv; for (i = 0; i < argc; i++) { - __D("argc %d [%s]", i, argv[i]); + __D("argc %d [%s]", i, argv[i]); } while ((c = getopt_long(argc, argv, "sopc", long_options, NULL)) >= 0) { @@ -125,77 +80,6 @@ static int __check_on_off_type(void *user_data) return type; } -static int __prepare_animation(keynode_t * node, void *user_data) -{ -#ifdef SOUND_PROFILE - /* Sound is not supported Since Tizen 4.0 */ - /* check sound profile */ - char wav_path[256]; - int soundon = 1; /* default sound on */ - - if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) { - __D("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!"); - } - - __D("Sound status: %d", soundon); -#endif - - int type = -1; - type = __check_on_off_type(user_data); - if (type < 0) { - __E("Failed to get on off type or UNKNOWN_TYPE: %d", type); - return EXIT_FAILURE; - } - - if (init_animation(type) != EXIT_SUCCESS) { - __E("Exit boot-animation"); - return EXIT_FAILURE; - } - -#ifdef SOUND_PROFILE - if (soundon) { - __D("Sound on!!"); - if (!get_wav_file(type, wav_path)) { - __D("File path: %s", wav_path); - mm_sound_boot_ready(3); - mm_sound_boot_play_sound(wav_path); - } - } -#endif - __D("EXIT SUCESS"); - - return EXIT_SUCCESS; -} - -#if 0 -static void _boot_ani_ui_set_scale(void) -{ - double root_height = 0.0; - double root_width = 0.0; - char buf[128] = { 0, }; - Display *disp; - int screen_num; - - disp = XOpenDisplay(NULL); - if (disp == NULL) - return; - - screen_num = DefaultScreen(disp); - - root_height = DisplayHeight(disp, screen_num); - root_width = DisplayWidth(disp, screen_num); - - XCloseDisplay(disp); - - snprintf(buf, sizeof(buf), "%lf", root_height / BA_DEFAULT_WINDOW_H); - //snprintf(buf, sizeof(buf), "%lf", root_width / BA_DEFAULT_WINDOW_W); - __D("Boot animation scale : [%s]", buf); - - setenv("ELM_SCALE", buf, 1); - setenv("SCALE_FACTOR", buf, 1); -} -#endif - #if (!TEST_MODE) int main(int argc, char *argv[]) { @@ -204,7 +88,12 @@ int main(int argc, char *argv[]) setenv("HOME", "/home/root", 1); if (argc < 2) { - print_usages(argv[0]); + printf("Usage) %s {--start|--stop}\n", argv[0]); + printf(" Ex:"); + printf(" # %s --start\n", argv[0]); + printf(" # %s --stop\n", argv[0]); + printf(" # %s --off\n", argv[0]); + return EXIT_FAILURE; } @@ -217,10 +106,6 @@ int main(int argc, char *argv[]) } invoked_flag = 1; -#if 0 - _boot_ani_ui_set_scale(); -#endif - close(1); fd = open("/tmp/myfile.txt", O_CREAT|O_RDWR, S_IRWXU|S_IRWXO); __D("Result of log file open: %d", fd); @@ -228,14 +113,24 @@ int main(int argc, char *argv[]) elm_init(argc, argv); boot_exit = elm_exit; - if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 0) != 0) { - __D("Failed to set finished value to 0\n"); + int boot_type = -1; + boot_type = __check_on_off_type(&args); + if (boot_type < 0) { + __E("Failed to get on off type or UNKNOWN_TYPE: %d", boot_type); + return 1; } - if (__prepare_animation(NULL, &args) != EXIT_SUCCESS) { - vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1); + + if (init_animation(boot_type) != EXIT_SUCCESS) { + __E("Exit boot-animation"); return 1; } + if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 0) != 0) { + __D("Failed to set finished value to 0\n"); + } + + play_boot_sound(boot_type); + elm_run(); fini_animation(); diff --git a/src/boot_sound.c b/src/boot_sound.c new file mode 100755 index 0000000..db14398 --- /dev/null +++ b/src/boot_sound.c @@ -0,0 +1,71 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include + +#include "boot.h" +#include "app_log.h" + +static const int is_supported = 0; +static bool __get_wav_file(int state, char *wavpath) +{ + __D("Get wav file"); + if (state == TYPE_ON) { + snprintf(wavpath, FILE_PATH_MAX-1, "%s", DEFAULT_POWERON_WAV); + __D("Wav file: %s", wavpath); + + return true; + } + + return false; +} + +static int __get_sound_status(void) +{ + int soundon = 1; + + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) { + __D("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!"); + } + + __D("Sound status: %d", soundon); + + return soundon; +} + +void play_boot_sound(int boot_type) +{ + if(!is_supported) return ; + + int soundon = __get_sound_status(); + if (soundon) { + __D("Sound on!!"); + + char wav_path[256]; + if (__get_wav_file(boot_type, wav_path)) { + __D("File path: %s", wav_path); +#ifdef MM_SOUND + mm_sound_boot_ready(3); + mm_sound_boot_play_sound(wav_path); +#endif + } + } +} + diff --git a/test/test_main.c b/test/test_main.c index 1ced4e7..c0d1d99 100755 --- a/test/test_main.c +++ b/test/test_main.c @@ -5,6 +5,7 @@ #include "function_test/function_test.h" #include "feature_test/feature_test.h" #include "animation.h" +#include "app_log.h" #include #include -- 2.7.4