Android系统的开机画面显示过程分析(9)
-
void handle_control_message(const char *msg, const char *arg)
-
{
-
if (!strcmp(msg,"start")) {
-
msg_start(arg);
-
} else if (!strcmp(msg,"stop")) {
-
msg_stop(arg);
-
} else {
-
ERROR("unknown control msg '%s'\n", msg);
-
}
-
}
-
static void msg_start(const char *name)
-
{
-
struct service *svc;
-
char *tmp = NULL;
-
char *args = NULL;
-
-
if (!strchr(name, ':'))
-
svc = service_find_by_name(name);
-
else {
-
tmp = strdup(name);
-
args = strchr(tmp, ':');
-
*args = '\0';
-
args++;
-
-
svc = service_find_by_name(tmp);
-
}
-
-
if (svc) {
-
service_start(svc, args);
-
} else {
-
ERROR("no such service '%s'\n", name);
-
}
-
if (tmp)
-
free(tmp);
-
}
-
int main(int argc, char** argv)
-
{
-
#if defined(HAVE_PTHREADS)
-
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY);
-
#endif
-
-
char value[PROPERTY_VALUE_MAX];
-
property_get("debug.sf.nobootanimation", value, "0");
-
int noBootAnimation = atoi(value);
-
LOGI_IF(noBootAnimation, "boot animation disabled");
-
if (!noBootAnimation) {
-
-
sp<ProcessState> proc(ProcessState::self());
-
ProcessState::self()->startThreadPool();
-
-
// create the boot animation object
-
sp<BootAnimation> boot = new BootAnimation();
-
-
IPCThreadState::self()->joinThreadPool();
-
-
}
-
return 0;
-
}
这个函数首先检查系统属性“debug.sf.nobootnimaition”的值是否不等于0。如果不等于的话,那么接下来就会启动一个Binder线程池,并且创建一个BootAnimation对象。这个BootAnimation对象就是用来显示第三个开机画面的。由于BootAnimation对象在显示第三个开机画面的过程中,需要与SurfaceFlinger服务通信,因此,应用程序bootanimation就需要启动一个Binder线程池。
-
void BootAnimation::onFirstRef() {
-
status_t err = mSession->linkToComposerDeath(this);
-
LOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err));
-
if (err == NO_ERROR) {
-
run("BootAnimation", PRIORITY_DISPLAY);
-
}
-
}
-
BootAnimation::BootAnimation() : Thread(false)
-
{
-
mSession = new SurfaceComposerClient();
-
}