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

对比Android 11, Android 13的SystemUI的源码文件目录,部分文件位置移动了或者删除了,其它的做出了很多改变,变的更加清晰、模块化...

代码里面注解用的频繁了. Dragger2是一个依赖注入框架,在编译期间自动生成代码,负责依赖对象的创建.

Dragger2\](https://blog.csdn.net/qq_28898075/article/details/103145367) #### 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详解\](https://juejin.cn/post/7223216421199315000) 关于导航栏的创建,系统会判断屏幕大小来决定是否生成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, RegisterStatusBarResult result) { updateAccessibilityButtonModeIfNeeded(); // Don't need to create nav bar on the default display if we initialize TaskBar. final boolean shouldCreateDefaultNavbar = includeDefaultDisplay \&\& !initializeTaskbarIfNecessary(); Display\[\] displays = mDisplayTracker.getAllDisplays(); for (Display display : displays) { if (shouldCreateDefaultNavbar \|\| display.getDisplayId() != mDisplayTracker.getDefaultDisplayId()) { createNavigationBar(display, null /\* savedState \*/, result); } } } @VisibleForTesting void createNavigationBar(Display display, Bundle savedState, RegisterStatusBarResult result) { ... //从这里分为两个部分 NavigationBar navBar = component.getNavigationBar();//导航栏实例化,navBar通过注解生成的 navBar.init();//将导航栏添加到屏幕上 mNavigationBars.put(displayId, navBar); ... } \`\`\` \`\`\` \

相关推荐
刮风那天1 小时前
Android 如何降低进程优先级可以被查杀?
android
资源分享助手3 小时前
超级改图P图改字无限制版教程(安卓)AI改图软件、图片改字软件、安卓修图APP、智能消除工具、图片拼接APP、超级改图下载
android·人工智能
Lehjy3 小时前
【Linux】文件系统磁盘存储结构
android·linux·运维
BU摆烂会噶3 小时前
【LangGraph】节点内调用与状态隔离
android·人工智能·python·ui·langchain·人机交互
BU摆烂会噶4 小时前
【LangGraph】作为节点添加与状态共享
android·人工智能·python·ui·langchain·人机交互
刘大猫.5 小时前
重塑经典:Snapseed4.0全面登陆安卓,内置“胶片相机”与专业手动模式
android·数码相机·ai·机器人·大模型·算力·snapseed4.0
Languorous.5 小时前
MySQL聚合查询:COUNT、SUM、AVG用法,实战案例演示
android·数据库
沅霖6 小时前
Android Studio Java工程开发环境,怎么切换到Kotlin开发环境
android·kotlin·android studio
largecode6 小时前
企业名称能在来电显示吗?号码显示公司名服务打通多终端展示
android·xml·ios·iphone·xcode·webview·phonegap
龙之叶6 小时前
Android 12:从 Editor 到 FloatingToolbar 全局收敛长按菜单
android