Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173638
  • 博文数量: 47
  • 博客积分: 992
  • 博客等级: 准尉
  • 技术积分: 565
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-08 21:57
文章分类

全部博文(47)

文章存档

2019年(1)

2018年(1)

2017年(1)

2014年(6)

2013年(1)

2012年(2)

2011年(35)

我的朋友

分类: 嵌入式

2011-03-25 14:49:17

Android110325: ActivityManagerService注记 2


Email:    zcatt@163.com
Blog    http://zcatt.cublog.cn
 
内容提要
屏幕尺寸大小.以供备忘和参考。

声明
仅限学习交流,禁止商业用途。转载需注明出处。

版本记录
Date        Ver        Note
2011-03-25    0.1        Draft.  zcatt, Beijing
2011-05-03    0.2        AThread is also the handler thread of ActivityThread.SystemMain()
 
ActivityManagerService的初始化是在run()@SystemServer.ServerThread中进行的。

class ServerThread extends Thread {
    public void run() {
        ... ...
        context = ActivityManagerService.main(factoryTest);
        ... ...
        ActivityManagerService.setSystemProcess();
        ... ...
        ActivityManagerService.installSystemProviders();
        ... ...
    }


ActivityManagerService.main()中会创建自己的运行线程ActivityManagerService.AThread,负责处理Handler.AThread也是ActivityThread.systemMain()生成的mSystemThread的handler thread。注意,是在在AThread中实例化的ActivityMangerService。而其它的初始化操作则在main()中完成。为此两个线程之间采用了两个同步点。
public final class ActivityManagerService extends ActivityManagerNative implements Watchdog.Monitor {
    public static final Context main(int factoryTest) {
        AThread thr = new AThread();
        thr.start();

        synchronized (thr) {
            while (thr.mService == null) {
                try {
                    thr.wait();
                } catch (InterruptedException e) {
                }
            }
        }
    ... ...
        ActivityThread at = ActivityThread.systemMain();
        mSystemThread = at;
    // other initialization
    ... ...
        synchronized (thr) {
            thr.mReady = true;
            thr.notifyAll();
        }
    ... ...
    }


另外,Watchdog的handler也挂接到AThread。ActivityManagerService会向Watchdog注册/添加monitor。ActivityManagerService的monitor就做一件事,检查deadlock。



ActivityManagerService的函数可以分成这样几类
1.    permissions
2.    task management
3.    thumbnails
4.    content providers
5.    global management
6.    services
7.    backup restore
8.    broadcast
9.    instrumentation
10.    configuration
11.    liftime management


Locations of visitors to this page
阅读(936) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~