Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92
startSystemUi -> SystemServer.java
context.startServiceAsUser -> //ComponentName: com.android.systemui
onCreate -> SystemUIService.java
getApplication().startServicesIfNeeded -> //SystemUIApplication
SystemUIApplication -> SystemUIApplication.java
mServices[i].start() -> //SERVICES数组定义了运行的子服务列表,将会被依次启动
start -> SystemBars.java//这里只关注statusbar
new ServiceMonitor //mCallbacks是systemBars类,下面要用到
mServiceMonitor.start
mHandler.sendEmptyMessage -> ServiceMonitor.java //MSG_START_SERVICE
handleMessage ->
startService ->
mCallbacks.onNoService ->
onNoService -> SystemBars.java
createStatusBarFromConfig ->
mContext.getString //从xml获取类名: R.string.config_statusBarComponent
//在文件frameworks/base/packages/SystemUI/res/values/config.xml中
//为com.android.systemui.statusbar.phone.PhoneStatusBar
mContext.getClassLoader().loadClass //加载类
mStatusBar.start ->
start -> PhoneStatusBar.java
super.start //调用父类即BaseStatusBar
start -> BaseStatusBar.java
ServiceManager.getService(Context.STATUS_BAR_SERVICE)) //获取到对应的是StatusBarManagerService
mBarService.registerStatusBar //将自己注册到SystemBarService中,SystemBarService的处理都交由它实现
createAndAddWindows -> PhoneStatusBar.java //创建状态栏和导航栏窗口
addStatusBarWindow ->
makeStatusBarView //构造view
new StatusBarWindowManager
mStatusBarWindowManager.add //添加状态栏的view到窗口中
addNavigationBar //添加导航栏view到窗口中
new PhoneStatusBarPolicy //定义系统通知图标的设置策略
SERVICES列表:
private final Class>[] SERVICES = new Class[] {
com.android.systemui.tuner.TunerService.class, //定制状态栏服务
com.android.systemui.keyguard.KeyguardViewMediator.class,//锁屏模块
com.android.systemui.recents.Recents.class,//最近应用
com.android.systemui.volume.VolumeUI.class,//全局音量控制
com.android.systemui.statusbar.SystemBars.class,//系统状态栏
com.android.systemui.usb.StorageNotification.class,//Storage存储通知
com.android.systemui.power.PowerUI.class,//电量管理相关
com.android.systemui.media.RingtonePlayer.class,//铃声播放
com.android.systemui.keyboard.KeyboardUI.class,//键盘相关
};
参考: