android:SurfaceFlinger启动 .
来源:互联网 发布:紧急通知最新域名升级 编辑:程序博客网 时间:2024/06/07 22:48
Android 2.2(froyo)
system_init()(base/cmds/system_server/library/system_init.cpp)中的 SurfaceFlinger::instantiate();会注册SurfaceFlinger服务:
- 119 void SurfaceFlinger::instantiate() {
- 120 if(surfaceflinger == NULL)
- 121 {
- 122 surfaceflinger = new SurfaceFlinger();
- 123 }
- 124 defaultServiceManager()->addService(
- 125 String16(“SurfaceFlinger”), surfaceflinger);
- 126 }
119 void SurfaceFlinger::instantiate() {120 if(surfaceflinger == NULL)121 {122 surfaceflinger = new SurfaceFlinger();123 }124 defaultServiceManager()->addService(125 String16(“SurfaceFlinger”), surfaceflinger);126 }
而defaultServiceManager()->addService()实际上调用的是BpServiceManager::addService(const String16& name, const sp<IBinder>& service),所以surfaceflinger就转化成了const sp<IBinder>,又由于sp<T>的构造函数为:
- 301 template<typename T>
- 302 sp<T>::sp(T* other)
- 303 : m_ptr(other)
- 304 {
- 305 if (other) other->incStrong(this);
- 306 }
301 template<typename T>302 sp<T>::sp(T* other)303 : m_ptr(other)304 {305 if (other) other->incStrong(this);306 }
在又有:
- 281 void RefBase::incStrong(const void* id) const
- 282 {
- 283 weakref_impl* const refs = mRefs;
- ….
- 296
- 297 android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong);
- 298 const_cast<RefBase*>(this)->onFirstRef();
- 299 }
281 void RefBase::incStrong(const void* id) const282 {283 weakref_impl* const refs = mRefs;….296297 android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong);298 const_cast<RefBase*>(this)->onFirstRef();299 }
所以,最终会调用SurfaceFlinger::onFirstRef()
- 376 void SurfaceFlinger::onFirstRef()
- 377 {
- 378 run(“SurfaceFlinger”, PRIORITY_URGENT_DISPLAY);
- 379
- 380 // Wait for the main thread to be done with its initialization
- 381 mReadyToRunBarrier.wait();
- 382 }
376 void SurfaceFlinger::onFirstRef()377 {378 run(“SurfaceFlinger”, PRIORITY_URGENT_DISPLAY);379380 // Wait for the main thread to be done with its initialization381 mReadyToRunBarrier.wait();382 }
于是SurfaceFlinger就开始运行了(readyToRun()->threadLoop())
Android 4.0(Ice Cream Sandwich)
init.rc中有
- 268 setprop system_init.startsurfaceflinger 0
- …
- 409 service surfaceflinger /system/bin/surfaceflinger
- 410 class main
- 411 user system
- 412 group graphics
- 413 onrestart restart zygote
268 setprop system_init.startsurfaceflinger 0…409 service surfaceflinger /system/bin/surfaceflinger410 class main411 user system412 group graphics413 onrestart restart zygote
所以system_init()将不会启动SurfaceFlinger,而是由init程序启动的。而且instantiate()实际为BinderService::instantiate(),后面的实际启动也是由RefBase机制来进行的。
加注:
当前在低于4.0的android中, 可以通过设置systeminit.startsurfaceflinger的属性值为0, 来禁止system server启动surfaceflinger.
- android:SurfaceFlinger启动
- android:SurfaceFlinger启动 .
- 【Android】Android SurfaceFlinger之SurfaceFlinger启动过程
- Android SurfaceFlinger之SurfaceFlinger启动过程
- Android SurfaceFlinger服务启动过程源码分析
- android L 的surfaceflinger服务启动分析
- android surfaceflinger(1)-启动初始化1
- android surfaceflinger
- Android SurfaceFlinger 学习之路(四)----SurfaceFlinger服务的启动与连接过程
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop
- android surfaceflinger研究----SurfaceFlinger loop .
- android surfaceflinger研究----SurfaceFlinger loop .
- WebSocket不同版本的三种握手方式以及一个Netty实现JAVA类
- 几种任务调度的 Java 实现方法与比较
- sqlplus配置和session中sql追踪
- Sqlite 常用函数
- xcode 编译程序运行,总是提示输入用户名和密码的解决方法
- android:SurfaceFlinger启动 .
- C++ 深拷贝与浅拷贝
- 关于bash的大括号
- C#中Split用法
- 当前上下文中不存在名称"Session"
- Eclipse快捷键
- 在ASP.NET中实现上传图片,并按比例生成缩略图
- 第五章 利用数组处理批量数据
- QueryString传值的加密与解密方法