sp 和 wp 类模板 以及RefBase类的代码在frameworks/base/include/utils/RefBase.h 和 frameworks/base/libs/utils/RefBase.cpp 中。
sp是Strong pointer ,wp是Weak pointer , 是实现android C++ 自动内存分配和回收避免内存泄漏的机制,类似于java的垃圾回收机制。sp 和 wp除了以上功能,并不做过多的其它任务。
有了以上基础,再来理解frameworks/base/cmds/bootanimation/bootanimation_main.cpp这个文件中的下面代码。
这又涉及到native service,IPC和BinderNative Service是在系统Init阶段通过Init.rc脚本建立的服务 。继续看这两篇文: http://blog.csdn.net/maxleng/article/details/5504485和 http://blog.csdn.net/maxleng/article/details/5490770
sp是Strong pointer ,wp是Weak pointer , 是实现android C++ 自动内存分配和回收避免内存泄漏的机制,类似于java的垃圾回收机制。sp 和 wp除了以上功能,并不做过多的其它任务。
有了以上基础,再来理解frameworks/base/cmds/bootanimation/bootanimation_main.cpp这个文件中的下面代码。
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 =newBootAnimation();
IPCThreadState::self()->joinThreadPool();
}
return0;
}
这又涉及到native service,IPC和BinderNative Service是在系统Init阶段通过Init.rc脚本建立的服务 。继续看这两篇文: http://blog.csdn.net/maxleng/article/details/5504485和 http://blog.csdn.net/maxleng/article/details/5490770