下面两图让我们大概的了解了SystemUI代码结构和布局范围。
下面是Android SystemUI中包含的各项功能简介,虽然很多,但我这里只是讲解Status Bar,也就是系统上方的状态栏。看第二张图第一部分的顶部部分。
Status Bar 系统上方的状态栏
Navigator Bar 系统下方的导航栏
Keyguard 锁屏界面
PowerUI 电源界面
Recents Screen 近期任务界面
VolumeUI 音量调节对话框
Stack Divider 分屏功能调节器
PipUI 画中画界面
Screenshot 截屏界面
RingtonePlayer 铃声播放器界面
Settings Activity 系统设置中用到的一些界面,例如:NetworkOverLimitActivity,UsbDebuggingActivity等。
原归正传,我们从代码中查看SystemUI是如何启动的。我用的源码是Android 6.0 的,不过各个Android版本的启动过程大致是相同的。
1.SystemServer中启动SystemUIService
SystemService路径: base\services\java\com\android\server\SystemServer.java
SystemUIService的启动是在SystemServer中startSystemUi中启动的
static final void startSystemUi(Context context) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
而startSystemUi()在SystemServer中启动startOtherServices()中调用的。
private void startOtherServices() {
......
mActivityManagerService.systemReady(new Runnable() {
@Override
public void run() {
.......
try {
startSystemUi(context);
} catch (Throwable e) {
reportWtf("starting System UI", e);
}
...