SystemUI的Home Button是如何添加到NavigationBar的

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值