blob: 3689d5ed937eae7dc0085adef6fdc7ad71af2625 [file] [log] [blame]
Mathias Agopian627e7b52009-05-21 19:21:59 -07001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#define LOG_TAG "BootAnimation"
18
Keun-young Park721c9dc2017-05-19 17:13:04 -070019#include <stdint.h>
20#include <inttypes.h>
21
Mathias Agopianac31a3b2009-05-21 19:59:24 -070022#include <binder/IPCThreadState.h>
23#include <binder/ProcessState.h>
24#include <binder/IServiceManager.h>
Yabin Cui16104862015-01-26 19:43:58 -080025#include <cutils/properties.h>
26#include <sys/resource.h>
Mathias Agopian627e7b52009-05-21 19:21:59 -070027#include <utils/Log.h>
Keun-young Park721c9dc2017-05-19 17:13:04 -070028#include <utils/SystemClock.h>
Mathias Agopian627e7b52009-05-21 19:21:59 -070029#include <utils/threads.h>
30
Mathias Agopian627e7b52009-05-21 19:21:59 -070031#include "BootAnimation.h"
32
33using namespace android;
34
35// ---------------------------------------------------------------------------
36
Andreas Gampecfedceb2014-09-30 21:48:18 -070037int main()
Mathias Agopian627e7b52009-05-21 19:21:59 -070038{
Mathias Agopian627e7b52009-05-21 19:21:59 -070039 setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY);
Mathias Agopian627e7b52009-05-21 19:21:59 -070040
Mathias Agopiande363132009-07-28 15:27:39 -070041 char value[PROPERTY_VALUE_MAX];
42 property_get("debug.sf.nobootanimation", value, "0");
43 int noBootAnimation = atoi(value);
Dmitri Plotnikova8d2c642016-12-08 10:49:24 -080044 if (!noBootAnimation) {
45 property_get("ro.boot.quiescent", value, "0");
46 noBootAnimation = atoi(value);
47 }
Steve Block6215d3f2012-01-04 20:05:49 +000048 ALOGI_IF(noBootAnimation, "boot animation disabled");
Mathias Agopiande363132009-07-28 15:27:39 -070049 if (!noBootAnimation) {
Mathias Agopian627e7b52009-05-21 19:21:59 -070050
Mathias Agopiande363132009-07-28 15:27:39 -070051 sp<ProcessState> proc(ProcessState::self());
52 ProcessState::self()->startThreadPool();
Mathias Agopian627e7b52009-05-21 19:21:59 -070053
Keun-young Park721c9dc2017-05-19 17:13:04 -070054 // TODO: replace this with better waiting logic in future, b/35253872
55 int64_t waitStartTime = elapsedRealtime();
56 sp<IServiceManager> sm = defaultServiceManager();
57 const String16 name("SurfaceFlinger");
58 const int SERVICE_WAIT_SLEEP_MS = 100;
59 const int LOG_PER_RETRIES = 10;
60 int retry = 0;
61 while (sm->checkService(name) == nullptr) {
62 retry++;
63 if ((retry % LOG_PER_RETRIES) == 0) {
64 ALOGW("Waiting for SurfaceFlinger, waited for %" PRId64 " ms",
65 elapsedRealtime() - waitStartTime);
66 }
67 usleep(SERVICE_WAIT_SLEEP_MS * 1000);
68 };
69 int64_t totalWaited = elapsedRealtime() - waitStartTime;
70 if (totalWaited > SERVICE_WAIT_SLEEP_MS) {
71 ALOGI("Waiting for SurfaceFlinger took %" PRId64 " ms", totalWaited);
72 }
73
Mathias Agopiande363132009-07-28 15:27:39 -070074 // create the boot animation object
75 sp<BootAnimation> boot = new BootAnimation();
76
77 IPCThreadState::self()->joinThreadPool();
Mathias Agopiande363132009-07-28 15:27:39 -070078 }
Mathias Agopian627e7b52009-05-21 19:21:59 -070079 return 0;
80}