code refactoring 46/127746/2
authorYoungHun Cho <hoon.cho@samsung.com>
Fri, 28 Apr 2017 13:18:17 +0000 (22:18 +0900)
committerYoungHun Cho <hoon.cho@samsung.com>
Fri, 28 Apr 2017 13:19:25 +0000 (22:19 +0900)
Change-Id: I4d564d2cd916ced7306312ca1bbaf1df93dd1f2c

inc/animation.h [changed mode: 0644->0755]
inc/boot_sound.h [new file with mode: 0755]
src/animation.c
src/boot.c [changed mode: 0644->0755]
src/boot_sound.c [new file with mode: 0755]
test/test_main.c

old mode 100644 (file)
new mode 100755 (executable)
index a7cd7c1..5ce803a
@@ -15,8 +15,8 @@
  *
  */
 
-#ifndef __BOOT_ANIMATION__
-#define __BOOT_ANIMATION__
+#ifndef __BOOT_ANIMATION_H__
+#define __BOOT_ANIMATION_H__
 
 #include <Elementary.h>
 
@@ -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 (executable)
index 0000000..024790c
--- /dev/null
@@ -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
index f633a0e..6f2e222 100644 (file)
@@ -286,4 +286,3 @@ Evas_Object *__t__get_display_block(void)
        return s_animation.display_block;
 }
 #endif
-
old mode 100644 (file)
new mode 100755 (executable)
index 360839d..afb8b8d
  *
  */
 
-#include <stdio.h>
+#include <vconf.h>
+#include <getopt.h>
 #include <stdlib.h>
-#include <string.h>
-#include <errno.h>
 #include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <linux/fb.h>
-#include <stddef.h>
-#include <unistd.h>
-
-#include <pthread.h>
-#include <Elementary.h>
-#include <getopt.h>
-#include <system_settings.h>
-#include <vconf.h>
 
 #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 <mm_sound_private.h>
-#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 (executable)
index 0000000..db14398
--- /dev/null
@@ -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 <vconf.h>
+#include <app.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#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
+               }
+       }
+}
+
index 1ced4e7..c0d1d99 100755 (executable)
@@ -5,6 +5,7 @@
 #include "function_test/function_test.h"
 #include "feature_test/feature_test.h"
 #include "animation.h"
+#include "app_log.h"
 
 #include <Elementary.h>
 #include <vconf.h>