android_frameworks_base/cmds/bootanimation/bootanimation_main.cpp
Huihong Luo 50a2f36f73 Preload zip before waiting for surface flinger
This saves about 200 msec by preloading media zip file before waiting
for surface flinger becomes ready.

Android Auto results:
BootAnimation: BootAnimationPreloadTiming start time: 8261ms
BootAnimation: BootAnimationPreloadStopTiming start time: 8508ms

Bug: 62056504

Test: adb logcat -s BootAnimation
Change-Id: Iaedf774983a66c2838452c45a04b3a1f4c728f17
2019-02-14 13:37:34 -08:00

60 lines
1.7 KiB
C++

/*
* Copyright (C) 2007 The Android Open Source Project
*
* 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.
*/
#define LOG_TAG "BootAnimation"
#include <stdint.h>
#include <inttypes.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <sys/resource.h>
#include <utils/Log.h>
#include <utils/SystemClock.h>
#include "BootAnimation.h"
#include "BootAnimationUtil.h"
#include "audioplay.h"
using namespace android;
int main()
{
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY);
bool noBootAnimation = bootAnimationDisabled();
ALOGI_IF(noBootAnimation, "boot animation disabled");
if (!noBootAnimation) {
sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();
// create the boot animation object (may take up to 200ms for 2MB zip)
sp<BootAnimation> boot = new BootAnimation(audioplay::createAnimationCallbacks());
waitForSurfaceFlinger();
boot->run("BootAnimation", PRIORITY_DISPLAY);
ALOGV("Boot animation set up. Joining pool.");
IPCThreadState::self()->joinThreadPool();
}
return 0;
}