android从init到开机动画启动关闭流程一简易图(surfaceflinger启动的位置)
2016-05-05 16:41
627 查看
![](http://www.android100.org/uploadfile/2014/0604/20140604020316_0.gif)
init主进程启动,解析init.rc后依次exec fork启动相关的进程,其中以class main和core为首的service将会率先启动,这里SF将会触发init启动一个bootanimation进程,其会开始启动动画显示,后台其他服务进程完成初始化,待Systemserver的其他核心service启动后,ActivityManagerService将会初始化完成并启动第一个lunch activity即桌面程序,在渲染图像前,需要让SF停止动画的显示,故由AMS通知SF停止显示,以方便Lunch最终display到UI上。这段显示的时间,基本就是后台服务的初始化运行,其中以SystemServer的耗时较长,导致开机动画一直循环显示。
通过 property_get("system_init.startsurfaceflinger", propBuf, "1");
在init.rc来决定启动的sufaceflinger在systemsever还是直接由init的main启动。
extern "C" status_t system_init() { ALOGI("Entered system_init()"); sp proc(ProcessState::self()); sp sm = defaultServiceManager(); ALOGI("ServiceManager: %p\n", sm.get()); sp grim = new GrimReaper(); sm->asBinder()->linkToDeath(grim, grim.get(), 0); char propBuf[PROPERTY_VALUE_MAX]; property_get("system_init.startsurfaceflinger", propBuf, "1"); if (strcmp(propBuf, "1") == 0) { // Start the SurfaceFlinger //在 init.rc中通过setprop system_init.startsurfaceflinger 0或者1,属性值为如果是1则在Systemserver中直接启动,否则以一个单独的main进程启动 SurfaceFlinger::instantiate(); } property_get("system_init.startsensorservice", propBuf, "1"); if (strcmp(propBuf, "1") == 0) { // Start the sensor service SensorService::instantiate(); } // And now start the Android runtime. We have to do this bit // of nastiness because the Android runtime initialization requires // some of the core system services to already be started. // All other servers should just start the Android runtime at // the beginning of their processes's main(), before calling // the init function. ALOGI("System server: starting Android runtime.\n"); AndroidRuntime* runtime = AndroidRuntime::getRuntime(); ALOGI("System server: starting Android services.\n"); JNIEnv* env = runtime->getJNIEnv(); if (env == NULL) { return UNKNOWN_ERROR; } jclass clazz = env->FindClass("com/android/server/SystemServer"); if (clazz == NULL) { return UNKNOWN_ERROR; } jmethodID methodId = env->GetStaticMethodID(clazz, "init2", "()V"); if (methodId == NULL) { return UNKNOWN_ERROR; } env->CallStaticVoidMethod(clazz, methodId); ALOGI("System server: entering thread pool.\n"); ProcessState::self()->startThreadPool(); IPCThreadState::self()->joinThreadPool(); ALOGI("System server: exiting thread pool.\n"); return NO_ERROR;http://www.android100.org/html/201406/04/17219.html http://www.360doc.com/content/11/1109/10/474846_162975894.shtml
相关文章推荐
- android删除文件夹或文件(文件可不为空)
- Android-Gradle打包
- android Studio开发介绍
- Android 双向Data Binding
- Android开发-线程池
- Android Context 是什么?
- android studio 界面xml创建问题
- 【Android】14、向上一个活动传递数据
- 系列篇|编译可在Android上运行的依赖库(一):glib库
- Android 插件化的 过去 现在 未来
- android 使用TabLayout出现的问题
- Android MVP模式
- Android 5.0+删除Sdcard文件
- android tools小应用
- Android TextView内容过长加省略号,点击显示全部内容
- 《Android源码设计模式解析与实战》读书笔记(二十二)
- android权限列表
- Android学习第九篇——2D动画翻转
- 《Android源码设计模式解析与实战》读书笔记(十)
- android编译系统(一):GUN Make简介