Android13 关于SystemUI更新/Nav Bar add volume button&&other button

对比Android 11, Android 13的SystemUI的源码文件目录,部分文件位置移动了或者删除了,其它的做出了很多改变,变的更加清晰、模块化…
代码里面注解用的频繁了. Dragger2是一个依赖注入框架,在编译期间自动生成代码,负责依赖对象的创建.
Dragger2

SystemUI初始化
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\CentralSurfacesImpl.java
    @Override
    public void start() {
        ...
        //statusBar相关,主要处理和信号有关的icon,比如mobile,wifi,vpn等
        mStatusBarSignalPolicy.init();
        ...
        createAndAddWindows(result);//入口,添加view的核心函数
        ...
        //关于壁纸
        if (mWallpaperSupported) {
            // Make sure we always have the most current wallpaper info.
            IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
            mBroadcastDispatcher.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter,
                    null /* handler */, UserHandle.ALL);
            mWallpaperChangedReceiver.onReceive(mContext, null);
        } else if (DEBUG) {
            Log.v(TAG, "start(): no wallpaper service ");
        }

        // Set up the initial notification state. This needs to happen before CommandQueue.disable()
        //初始化通知栏状态
        setUpPresenter();
        ...
        // Lastly, call to the icon policy to install/update all the icons.
        //状态栏上wifi,BT 等状态图标的更新
        mIconPolicy.init();
        ...
    }

    @Override
    public void createAndAddWindows(@Nullable RegisterStatusBarResult result) {
        makeStatusBarView(result);
        mNotificationShadeWindowController.attach();//添加通知
        mStatusBarWindowController.attach();//添加状态栏
    }
    
    protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) {
        updateDisplaySize(); // populates mDisplayMetrics
        updateResources();
        updateTheme();
        
        inflateStatusBarWindow();//状态栏初始化
        mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener());
        mWallpaperController.setRootView(mNotificationShadeWindowView);
        ...
        createNavigationBar(result);//导航栏初始化
        ...
    }
    
    protected void createNavigationBar(@Nullable RegisterStatusBarResult result) {
        mNavigationBarController.createNavigationBars(true /* includeDefaultDisplay */, result);
    }



    

NavigationBar详解
关于导航栏的创建,系统会判断屏幕大小来决定是否生成NavigationBar.如果屏幕过大导致判定为平板,
就会走Launcher3里面的/quickstep/taskbar 来替代导航栏.

frameworks\base\packages\SystemUI\src\com\android\systemui\navigationbar\NavigationBarController.java

    private boolean updateNavbarForTaskbar() {
        boolean taskbarShown = initializeTaskbarIfNecessary();
        if (!taskbarShown && mNavigationBars.get(mContext.getDisplayId()) == null) {
            createNavigationBar(mContext.getDisplay(), null, null);
        }
        return taskbarShown;
    }

    /** 平板:true */
    private boolean initializeTaskbarIfNecessary() {
        // Enable for tablet or (phone AND flag is set); assuming phone = !mIsTablet
        boolean taskbarEnabled = mIsTablet || mFeatureFlags.isEnabled(Flags.HIDE_NAVBAR_WINDOW);

        if (taskbarEnabled) {
            //是平板,移除屏幕上的navBar
            removeNavigationBar(mContext.getDisplayId());
            mTaskbarDelegate.init(mContext.getDisplayId());
        } else {
            mTaskbarDelegate.destroy();
        }
        return taskbarEnabled;
    }
    
    
    public void createNavigationBars(final boolean includeDefaultDisplay,
            RegisterSta
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值