android6.0系统启动流程

20 篇文章 0 订阅
1 篇文章 0 订阅


ArtMethod
Java文件




虚拟机执行的第一个Java文件
ZygoteInit.java




Class字节码。方法  ArtMethod()




init文件 需要Root权限才能访问


手机开机会启动init.rc 脚本。 会加载好边缘的init文件


init文件是 android-6.0.0_r1\system\core\init. 文件下编译的可执行文件


函数入口为main 函数


init.c 中会开启android-6.0.0_r1\frameworks\base\cmds 下的所有可执行文件 包括开启虚拟机的文件app_process文件


main()


com.android.internal.os.Zygote  Java






Run.start(“com.android.internal.ZygoteInit”,args,zygote);




调用虚拟机开启函数
if(startVm(&mJavaVM,&env,zygote)!=0){
Return;
}




JNI_CreateJavaVM. 创建java虚拟机 native JNIENV *env


/Users/xieyuhai/Documents/Source/android-4.4.4_r1/art/runtime/jni_internal.cc      JNI_CreateJavaVM




//JniEnv  *env 实例化
*p_env=Thread::Current()->GetJniEnv();
//实例化虚拟机的地方
*p_vm=runtime->GetJavaVM();




GetJniEnv();
这个函数定义在文件
/Users/xieyuhai/Documents/Source/android-4.4.4_r1/art/runtime/thread.h中


//Every thread may have an associated JNI environment
JNIEnvExt *jni_env_
JNIEnvExt 是JNIEnv子类


实际上还是通过 加载的类
Env->FindClass(slashClassName);//ClassLoader




function是JNINativeInterface


/*
 * Table of interface function pointers.
 */
struct JNINativeInterface {
    void*       reserved0;
    void*       reserved1;
    void*       reserved2;
    void*       reserved3;




struct _JNIEnv {
    /* do not rename this; it does not seem to be entirely opaque */
    const struct JNINativeInterface* functions;
  




//className 是com.android.internal.os.ZygoteInit   Java
//env->FindClass(env,className);  class字节码
//class_linker->FindClass(descriptor.c_str(), cl);


/Users/xieyuhai/Documents/Source/android-4.4.4_r1/art/runtime/jni_internal.cc


 static jclass FindClass(JNIEnv* env, const char* name)




/Users/xieyuhai/Documents/Source/android-6.0.1_r1/art/runtime/class_linker.cc


// Insert the class before loading the fields as the field roots
  // (ArtField::declaring_class_) are only visited from the class
  // table. There can't be any suspend points between inserting the
  // class and setting the field arrays below.
  mirror::Class* existing = InsertClass(descriptor.c_str(), klass.Get(), hash);


  LoadClass(self, dex_file, dex_class_def, klass);


jdk1.7
build_tool. 安全检查


const uint8_t* class_data = dex_file.GetClassData(dex_class_def);


 LoadClassMembers(self, dex_file, class_data, klass, &oat_class);


it.NumDirectMethods()//方法数量
ArtMethod* const direct_methods = (it.NumDirectMethods() != 0)
        ? AllocArtMethodArray(self, it.NumDirectMethods())
        : nullptr;


ArtMethod* const virtual_methods = (it.NumVirtualMethods() != 0)
        ? AllocArtMethodArray(self, it.NumVirtualMethods())
        : nullptr;


ptr 函数表的首地址(循环计算整个函数表内存)
for (size_t i = 0; i < length; ++i) {
    new(reinterpret_cast<void*>(ptr + i * method_size)) ArtMethod;
  }






———————开机动画


/Users/xieyuhai/Documents/Source/android-6.0.1_r1/frameworks/base/cmds/bootanimation/bootanimation_main.cpp


开机流程-》显示开机动画-》Luanch


sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();//开启线程池


// create the boot animation object
        sp<BootAnimation> boot = new BootAnimation();


        IPCThreadState::self()->joinThreadPool();




status_t BootAnimation::readyToRun() {




推送到媒体目录
adb push boot animation.zip /system/media/




丢到线程池之后会执行的
  
  readyToRun()
  
  540 宽度
  960  高度
  7   帧率  一秒播放多少帧
  p  标识符  
  0循环次数   无限循环
  
  2 
  
 1.首先通过 adb push 命令将文件上传到 sdcard 的根目录下。
2.然后通过 adb shell 进入 设备目录下,提取 root 权限, 把 bootanimation.zip 覆盖到 system/media 目录下。
3.修改 bootanimation.zip 文件权限为可读可写可执行(777)。


1.首先通过 adb push 命令将文件上传到 sdcard 的根目录下。
2.然后通过 adb shell 进入 设备目录下,提取 root 权限, 把 bootanimation.zip 覆盖到 system/media 目录下。
3.修改 bootanimation.zip 文件权限为可读可写可执行(777)。
  
  
  854 480 7
p 1 2 folder1
p 0 2 folder2
下面对上述参数进行解释:
854 480 7     ----854 480代表动画的分辨率,854代表动画的宽度,480代表动画的高度;7则代表帧率,也就是一秒钟播放多少幅动画图片;
p 1 2 folder1 ----这里的p为标志符,1代表循环次数,2代表阶段间隔时间,folder1代表对应的动画文件夹名;


循环次数:0 : 表示无限循环。
注意


1.desc.txt 文件要在 Linux 环境下生成,因为有些空格不一样
2.part 目录中的图片的命名要是连续的,比如pic_001, pic_002, _pic_003 …
3.打包成bootanimation.zip文件的时候,要要用zip格式的存储方式打包。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值