SystemServer 定义有如下方法:
private static void startSystemUi(Context context, WindowManagerService windowManager) {
PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
Intent intent = new Intent();
intent.setComponent(pm.getSystemUiServiceComponent());
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.SYSTEM);
windowManager.onSystemUiStarted();
}
并且在SystemServer的startOtherServices的最后调用了这个方法 。
这个service是配置在 config_systemUIServiceComponent。
<!-- SystemUi service component -->
<string name="config_systemUIServiceComponent" translatable="false"
>com.android.systemui/com.android.systemui.SystemUIService</string>
SystemUIService解析
在其onCreate中调用:
((SystemUIApplication) getApplication()).startServicesIfNeeded();
NavigationBar是如何添加到系统的:
在NavigationBarFragment#create方法里面添加NavigationBarFrame到系统 Window中。
NavigationBarFrame 的孩子是什么?
NavigationBarView 定义在navigation_bar.xml,
而 NavigationBarFragment在其onCreateView方法中将navigation_bar.xml 也就是
NavigationBarView 添加到它的container中,也就是 NavigationBarFrame 。
所以NavigationBarFrame的孩子是NavigationBarView 。
NavigationBarFragment -> NavigationBarFrame -> NavigationBarView
Home KeyButton是如何添加到NavigationBarView中的?
NavigationBarFrame有一个孩子是NavigationBarInflaterView,
NavigationBarView在其onFinishInflate方法中调用inflateLayout,
NavigationBarInflaterView 的孩子有: mHorizontal , mVertical 。
onFinishInflate
inflateLayout
inflateButtons
inflateButton