android从init到开机动画启动关闭流程一简易图(surfaceflinger启动的位置)

\

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值