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.
23 #include <sys/ioctl.h>
25 #include <sys/types.h>
34 #include <Elementary.h>
37 #include <mm_sound_private.h>
38 #include <system_settings.h>
42 #include "animation.h"
49 extern int optind, opterr, optopt;
58 static void print_usages(char *argv0)
60 printf("Usage) %s {--start|--stop}\n"
65 " # %s --offmsg YOUR_MESSAGE\n", argv0, argv0, argv0, argv0,
69 static int get_wav_file(int state, char *wavpath)
72 if (state == TYPE_ON) {
73 snprintf(wavpath, FILE_PATH_MAX-1, "%s", DEFAULT_POWERON_WAV);
74 _D("Wav file: %s", wavpath);
81 static int xready_cb(keynode_t * node, void *user_data)
86 int type = TYPE_UNKNOWN;
87 int clear_type = TYPE_UNKNOWN;
88 int soundon = 1; /* default sound on */
89 struct args *args = user_data;
91 static struct option long_options[] = {
92 {"start", no_argument, 0, 's' },
93 {"stop", no_argument, 0, 'p' },
94 {"off", no_argument, 0, 'o' },
95 {"offmsg", required_argument, 0, 'm' },
96 {"clear", no_argument, 0, 'c' },
99 static int invoked_flag = 0;
102 printf("xready_cb\n");
104 if (invoked_flag == 1) {
105 _E("Already launched");
106 printf("Error Already launched\n");
116 for (i = 0; i < argc; i++) {
117 _D("argc %d [%s]", i, argv[i]);
118 printf("argc %d [%s]\n", i, argv[i]);
120 while ((c = getopt_long(argc, argv, "spom:c", long_options, NULL)) >= 0) {
130 type = TYPE_OFF_NOEXIT;
133 if (args->msg) continue;
134 type = TYPE_OFF_WITH_MSG;
135 args->msg = strdup(optarg);
140 clear_type = TYPE_CLEAR;
144 _D("[Boot-ani] unknown arg [%s]", optarg);
145 printf("[Boot-anim] unknown arg [%s]\n", optarg);
150 /* check sound profile */
151 if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) {
152 _D("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!");
153 printf("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!\n");
156 _D("Sound status: %d", soundon);
157 printf("Sound status: %d\n", soundon);
159 if (init_animation(type, args->msg) != EXIT_SUCCESS) {
160 _D("Exit boot-animation");
161 printf("Exit boot-animation\n");
167 printf("Sound on!!\n");
168 if (!get_wav_file(type, wav_path)) {
169 _D("File path: %s", wav_path);
170 printf("File path: %s\n", wav_path);
171 mm_sound_boot_ready(3);
172 mm_sound_boot_play_sound(wav_path);
181 static void _boot_ani_ui_set_scale(void)
183 double root_height = 0.0;
184 double root_width = 0.0;
185 char buf[128] = { 0, };
189 disp = XOpenDisplay(NULL);
193 screen_num = DefaultScreen(disp);
195 root_height = DisplayHeight(disp, screen_num);
196 root_width = DisplayWidth(disp, screen_num);
200 snprintf(buf, sizeof(buf), "%lf", root_height / BA_DEFAULT_WINDOW_H);
201 //snprintf(buf, sizeof(buf), "%lf", root_width / BA_DEFAULT_WINDOW_W);
202 _D("Boot animation scale : [%s]", buf);
204 setenv("ELM_SCALE", buf, 1);
205 setenv("SCALE_FACTOR", buf, 1);
209 int main(int argc, char *argv[])
213 setenv("HOME", "/home/root", 1);
216 print_usages(argv[0]);
225 _boot_ani_ui_set_scale();
229 fd = open("/tmp/myfile.txt", O_CREAT|O_RDWR, S_IRWXU|S_IRWXO);
230 _D("result of open: %d", fd);
231 printf("[%s/%s/%d] fd == %d\n", __FILE__, __func__, __LINE__, fd);
233 elm_init(argc, argv);
235 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 0) != 0) {
236 _D("Failed to set finished value to 0\n");
237 printf("[%s/%s/%d] Failed to set finished value to 0\n", __FILE__, __func__, __LINE__);
239 if (xready_cb(NULL, &args) != EXIT_SUCCESS) {
240 vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1);