当前位置: 首页 > news >正文

SystemUI导航栏

SystemUI导航栏

  • 1、系统中参数项
    • 1.1 相关开关属性
    • 2.2 属性设置代码
  • 2、设置中设置“三按钮”导航更新流程
    • 2.1 属性资源覆盖叠加
    • 2.2 SystemUI导航栏接收改变广播
    • 2.3 SystemUI导航栏布局更新
    • 2.4 时序图

android13-release


1、系统中参数项

1.1 相关开关属性

设置->系统->手势->系统导航->“三按钮”导航
在这里插入图片描述

  • 设置中:“三按钮”导航
    packages/apps/Settings/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
    packages/apps/Settings/res/values-zh-rCN/strings.xml
    <string name="legacy_navigation_title" msgid="7877402855994423727">"“三按钮”导航"</string>

  • 默认导航栏模式:config_navBarInteractionMode
    frameworks/base/core/res/res/values/config.xml
   <!-- Controls the navigation bar interaction mode:0: 3 button mode (back, home, overview buttons)1: 2 button mode (back, home buttons + swipe up for overview)2: gestures only for back, home and overview --><integer name="config_navBarInteractionMode">0</integer><!-- Whether a software navigation bar should be shown. NOTE: in the future this may beautodetected from the Configuration. --><bool name="config_showNavigationBar">false</bool>
  • Settings数据库中:adb shell settings get Secure navigation_mode
    frameworks/base/core/java/android/provider/Settings.java
/*** Navigation bar mode.*  0 = 3 button*  1 = 2 button*  2 = fully gestural* @hide*/
@Readable
public static final String NAVIGATION_MODE ="navigation_mode";
  • prop属性"qemu.hw.mainkeys":允许系统属性覆盖此设置。由仿真器使用。使用方法hasNavigationBar()
  • 导航栏高度:navigation_bar_height
    frameworks/base/core/res/res/values/dimens.xml
   <!-- Height of the bottom navigation / system bar. --><dimen name="navigation_bar_height">48dp</dimen><!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height --><dimen name="navigation_bar_height_landscape">48dp</dimen>

2.2 属性设置代码

设置中显示判断:

  • String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton";
    /product/overlay/NavigationBarMode3Button/NavigationBarMode3ButtonOverlay.apk
  • String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton";
    /product/overlay/NavigationBarMode2Button/NavigationBarMode2ButtonOverlay.apk
  • String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural";
    /product/overlay/NavigationBarModeGestural/NavigationBarModeGesturalOverlay.apk

packages/apps/Settings/src/com/android/settings/gestures/SystemNavigationPreferenceController.java

static boolean isOverlayPackageAvailable(Context context, String overlayPackage) {try {return context.getPackageManager().getPackageInfo(overlayPackage, 0) != null;} catch (PackageManager.NameNotFoundException e) {// Not found, just return unavailablereturn false;}
}

frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java

private int mNavBarMode = NAV_BAR_MODE_3BUTTON;mNavBarMode = mNavigationModeController.addListener(mModeChangedListener);

frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationModeController.java

private int getCurrentInteractionMode(Context context) {int mode = context.getResources().getInteger(com.android.internal.R.integer.config_navBarInteractionMode);if (DEBUG) {Log.d(TAG, "getCurrentInteractionMode: mode=" + mode+ " contextUser=" + context.getUserId());}return mode;
}public void updateCurrentInteractionMode(boolean notify) {mCurrentUserContext = getCurrentUserContext();int mode = getCurrentInteractionMode(mCurrentUserContext);mUiBgExecutor.execute(() ->Settings.Secure.putString(mCurrentUserContext.getContentResolver(),Secure.NAVIGATION_MODE, String.valueOf(mode)));if (DEBUG) {Log.d(TAG, "updateCurrentInteractionMode: mode=" + mode);dumpAssetPaths(mCurrentUserContext);}if (notify) {for (int i = 0; i < mListeners.size(); i++) {mListeners.get(i).onNavigationModeChanged(mode);}}
}

frameworks/base/services/core/java/com/android/server/wm/DisplayPolicy.java

if (mDisplayContent.isDefaultDisplay) {mHasStatusBar = true;mHasNavigationBar = mContext.getResources().getBoolean(R.bool.config_showNavigationBar);// Allow a system property to override this. Used by the emulator.// See also hasNavigationBar().String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");if ("1".equals(navBarOverride)) {mHasNavigationBar = false;} else if ("0".equals(navBarOverride)) {mHasNavigationBar = true;}
} else {mHasStatusBar = false;mHasNavigationBar = mDisplayContent.supportsSystemDecorations();
}

2、设置中设置“三按钮”导航更新流程

2.1 属性资源覆盖叠加

OverlayManagerService 运行时资源叠加层 (RRO)
点击设置后,导航栏模式通过 OverlayManagerService 服务对 config_navBarInteractionMode 资源进行叠加,而settings的Secure表中navigation_mode属性只是记录模式。
frameworks/base/services/core/java/com/android/server/om/OverlayManagerService.java

资源叠加主要文件:config.xml
frameworks/base/core/res/res/values/config.xml
/product/overlay/NavigationBarMode3Button/NavigationBarMode3ButtonOverlay.apk
/product/overlay/NavigationBarMode2Button/NavigationBarMode2ButtonOverlay.apk
/product/overlay/NavigationBarModeGestural/NavigationBarModeGesturalOverlay.apk

  • updateActivityManager(affectedPackages, userId):发送受覆盖状态更改影响的所有目标包的配置更改事件。
  • broadcastActionOverlayChanged(targets, userId):发送覆盖包已更改广播ACTION_OVERLAY_CHANGED
private void updateTargetPackagesLocked(@Nullable Set<PackageAndUser> updatedTargets) {if (CollectionUtils.isEmpty(updatedTargets)) {return;}persistSettingsLocked();final SparseArray<ArraySet<String>> userTargets = groupTargetsByUserId(updatedTargets);for (int i = 0, n = userTargets.size(); i < n; i++) {final ArraySet<String> targets = userTargets.valueAt(i);final int userId = userTargets.keyAt(i);final List<String> affectedPackages = updatePackageManagerLocked(targets, userId);if (affectedPackages.isEmpty()) {// The package manager paths are already up-to-date.continue;}FgThread.getHandler().post(() -> {// Send configuration changed events for all target packages that have been affected// by overlay state changes.updateActivityManager(affectedPackages, userId);// Do not send broadcasts for all affected targets. Overlays targeting the framework// or shared libraries may cause too many broadcasts to be sent at once.broadcastActionOverlayChanged(targets, userId);});}
}

2.2 SystemUI导航栏接收改变广播

mReceiver :监听ACTION_OVERLAY_CHANGED广播
Secure.NAVIGATION_MODE:记录导航栏模式改变值
mListeners.get(i).onNavigationModeChanged(mode):通知导航栏模式改变的ModeChangedListener监听

frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationModeController.java

private BroadcastReceiver mReceiver = new BroadcastReceiver() {@Overridepublic void onReceive(Context context, Intent intent) {if (DEBUG) {Log.d(TAG, "ACTION_OVERLAY_CHANGED");}updateCurrentInteractionMode(true /* notify */);}
};public NavigationModeController(Context context,DeviceProvisionedController deviceProvisionedController,ConfigurationController configurationController,@UiBackground Executor uiBgExecutor,DumpManager dumpManager) {//... ...IntentFilter overlayFilter = new IntentFilter(ACTION_OVERLAY_CHANGED);overlayFilter.addDataScheme("package");overlayFilter.addDataSchemeSpecificPart("android", PatternMatcher.PATTERN_LITERAL);mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, overlayFilter, null, null);//... ...
}public void updateCurrentInteractionMode(boolean notify) {mCurrentUserContext = getCurrentUserContext();int mode = getCurrentInteractionMode(mCurrentUserContext);mUiBgExecutor.execute(() ->Settings.Secure.putString(mCurrentUserContext.getContentResolver(),Secure.NAVIGATION_MODE, String.valueOf(mode)));if (DEBUG) {Log.d(TAG, "updateCurrentInteractionMode: mode=" + mode);dumpAssetPaths(mCurrentUserContext);}if (notify) {for (int i = 0; i < mListeners.size(); i++) {mListeners.get(i).onNavigationModeChanged(mode);}}
}

2.3 SystemUI导航栏布局更新

NavigationModeController通知监听执行onNavigationModeChanged方法更新,最后 navBar.getView().updateStates()执行更新界面NavigationBarView

  • updateSlippery():更新WindowManager.LayoutParams.FLAG_SLIPERY状态,具体取决于是否启用了向上滑动,或者通知是否在未处于动画状态的情况下完全打开。如果启用了slide,触摸事件将离开导航栏窗口并进入全屏应用程序/主页窗口,如果没有,则手势离开导航栏后,导航栏将收到取消的触摸事件。
  • reloadNavIcons():重新导入导航栏相关图片资源
  • updateNavButtonIcons:更新界面导航栏图标、显示状态,及活动触摸区域

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

@Override
public void onNavigationModeChanged(int mode) {if (mNavMode == mode) {return;}final int oldMode = mNavMode;mNavMode = mode;updateAccessibilityButtonModeIfNeeded();mHandler.post(() -> {// create/destroy nav bar based on nav mode only in unfolded stateif (oldMode != mNavMode) {updateNavbarForTaskbar();}for (int i = 0; i < mNavigationBars.size(); i++) {NavigationBar navBar = mNavigationBars.valueAt(i);if (navBar == null) {continue;}navBar.getView().updateStates();}});
}

frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java

public void updateStates() {if (mNavigationInflaterView != null) {// Reinflate the navbar if needed, no-op unless the swipe up state changesmNavigationInflaterView.onLikelyDefaultLayoutChange();}updateSlippery();reloadNavIcons();updateNavButtonIcons();WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(!mShowSwipeUpUi);getHomeButton().setAccessibilityDelegate(mShowSwipeUpUi ? mQuickStepAccessibilityDelegate : null);
}

2.4 时序图

在这里插入图片描述

相关文章:

SystemUI导航栏

SystemUI导航栏 1、系统中参数项1.1 相关开关属性2.2 属性设置代码 2、设置中设置“三按钮”导航更新流程2.1 属性资源覆盖叠加2.2 SystemUI导航栏接收改变广播2.3 SystemUI导航栏布局更新2.4 时序图 android13-release 1、系统中参数项 1.1 相关开关属性 设置->系统->…...

3d 贴图下载quixel

Quixel Megascans https://polyhaven.com/a/studio_small_03 Quixel Bridge&#xff1a;3D艺术家的宝库 在3D建模和渲染的世界中&#xff0c;找到高质量、适合项目的贴图素材至关重要。Quixel Bridge就是这样一个为3D艺术家提供大量免费贴图素材的资源库。在本文中&#xff…...

Linux权限维持

SSH 后门 软链接sshd 目标主机建立软连接&#xff1a; ln -sf /usr/sbin/sshd /tmp/su;/tmp/su -oport1189 #端口可以任意指定&#xff0c;最好伪装一下 查看端口&#xff1a; netstat -anlp|grep 1189 攻击机ssh登录&#xff1a; ssh rootx.x.x.x -p 1189 #如果root用户…...

互联网通信的核心协议HTTP和HTTPS

HTTP&#xff1a;超文本传输协议 HTTP&#xff0c;全称为超文本传输协议&#xff08;Hypertext Transfer Protocol&#xff09;&#xff0c;是一种用于在Web上传输超文本文档的协议。它是Web通信的基础&#xff0c;允许浏览器与Web服务器之间的数据交换。HTTP使用了经典的客户…...

javaWeb网上购物系统的设计与实现

摘 要 随着计算机网络技术的飞速发展和人们生活节奏的不断加快&#xff0c;电子商务技术已经逐渐融入了人们的日常生活当中&#xff0c;网上商城作为电子商务最普遍的一种形式&#xff0c;已被大众逐渐接受。因此开发一个网上商城系统&#xff0c;适合当今形势&#xff0c;更加…...

MySQL 主从复制、读写分离

MySQL 主从复制、读写分离 1、MySQL 主从复制1.1什么是主从复制&#xff1f;1.2为什么要读写分离呢&#xff1f;1.3 什么时候要读写分离&#xff1f;1.4主从复制与读写分离1.5mysql支持的复制类型1.6主从复制的工作过程1.7MySQL 读写分离原理1.8目前较为常见的 MySQL 读写分离分…...

基于虚拟阻抗的下垂控制——孤岛双机并联Simulink仿真

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

windows内核编程(2021年出版)笔记

1. Windows内部概览 1.1 进程 进程包含以下内容&#xff1a; 可执行程序&#xff0c;代码和数据私有的虚拟地址空间&#xff0c;分配内存时从这里分配主令牌&#xff0c;保存进程默认安全上下文&#xff0c;进程中的线程执行代码时会用到它私有句柄表&#xff0c;保存进程运…...

时序预测 | MATLAB实现EMD-iCHOA+GRU基于经验模态分解-改进黑猩猩算法优化门控循环单元的时间序列预测

时序预测 | MATLAB实现EMD-iCHOAGRU基于经验模态分解-改进黑猩猩算法优化门控循环单元的时间序列预测 目录 时序预测 | MATLAB实现EMD-iCHOAGRU基于经验模态分解-改进黑猩猩算法优化门控循环单元的时间序列预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 EMD-iCHOAGR…...

FFmpeg 命令:从入门到精通 | FFmpeg 解码流程

FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程 FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程流程图FFmpeg 解码的函数FFmpeg 解码的数据结构补充小知识 FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程 本内容参考雷霄骅博士的 FFmpeg 教程。 流…...

连接虚拟机工具推荐

连接虚拟机工具推荐 连接虚拟机的工具有很多种&#xff0c;以下是一些常用的推荐&#xff1a; PuTTY&#xff1a;这是一个非常常用的SSH和telnet客户端&#xff0c;适用于Windows系统。它允许你在本地机器上通过命令行接口远程登录到虚拟机。 SecureCRT&#xff1a;这是一个支…...

万字详解HTTP协议面试必备技能

目录 一、HTTP 是什么 二、理解 "应用层协议" 2.1理解 HTTP 协议的工作过程 2.2HTTP 协议格式 2.3抓包工具的使用 2.4抓包工具的原理 2.5抓包结果 2.5.1HTTP请求 2.5.2HTTP响应 2.6协议格式总结 三、HTTP 请求 (Request) 3.1认识 URL 3.1.1URL 基本格式 …...

Debian跳过grub页面

nano /etc/default/grub将GRUB_TIMEOUT的值改为0 将GRUB_CMDLINE_LINUX_DEFAULT的值改为"quiet splash" 如果要禁用开局日志的话&#xff0c;将GRUB_CMDLINE_LINUX_DEFAULT的值改为"quiet splash loglevel0" update-grub...

【已解决】RuntimeError Java gateway process exited before sending its port number

RuntimeError: Java gateway process exited before sending its port number 问题 思路 &#x1f3af;方法一 在代码前加入如下代码&#xff08;如图&#xff09;&#xff1a; import os os.environ[‘JAVA_HOME’] “/usr/local/jdk1.8.0_221” # 记得把地址改成自己的 …...

数据结构与算法-循环链表、双向链表

我们这里接着上一篇单链表继续往下深入学习循环链表、双向链表。 链表 &#x1f388;3.循环链表&#x1f52d;3.1循环链表的概念&#x1f52d;3.2循环链表的基本操作&#x1f50e;3.2.1创建空表&#x1f50e;3.2.2插入操作&#x1f50e;3.2.3删除操作 &#x1f388;4.双向链表&…...

javascript中依次输出元素并不断循环实现echarts柱图动画效果

循环来遍历数组并输出其中的元素 在JavaScript中&#xff0c;你可以使用循环来遍历数组并输出其中的元素。如果你想要依次输出6个元素并不断循环&#xff0c;可以使用如下的代码&#xff1a; let arr [/* 你的数组 */];for (let i 0; i < arr.length; i) {console.log(a…...

互联网Java工程师面试题·Memcached篇·第一弹

目录 1、Memcached 是什么&#xff0c;有什么作用&#xff1f; 1.1 memcached 服务在企业集群架构中有哪些应用场景&#xff1f; 1.1.1 作为数据库的前端缓存应用 1.1.2 作业集群的 session 会话共享存储 2、Memcached 服务分布式集群如何实现&#xff1f; 3、Memcach…...

git 详解-提升篇

git 冷门使用 承接上一篇 《git 进阶篇》&#xff0c;简单讲解 git 冷门使用方法。 码农常规使用工具 git 偶尔也有非常规操作。例如&#xff1a;提交代码时同事已经更新&#xff0c;但又不想回退本地补丁&#xff1b;或者已经提交补丁需要变更提交日志信息。 作者&#xff1…...

RPA的安全风险及应对策略

RPA已经深度革新了工作流程&#xff0c;大大提升效率并减少了人为错误&#xff0c;使企业运营更加高效。据预测&#xff0c;至2030年&#xff0c;全球RPA市场将以39.9%的复合年增长率持续发展&#xff0c;这显示了RPA对企业生产力的巨大推动力。 RPA能够承担人类的繁琐工作&am…...

数据结构与算法--贪心算法

数据结构与算法-贪心算法 1 贪心算法的概念 2 贪心算法的套路 3 贪心算法常用技巧 4 会议问题 5 字典序问题 1 贪心算法的概念 在某一标准下,优先考虑最满足标准的样本,最后考虑不满足标准的样本,最终得到一个答案的算法,叫做贪心算法 也就是说 不是从整体上加以考虑,所…...

VB.net复制Ntag213卡写入UID

本示例使用的发卡器&#xff1a;https://item.taobao.com/item.htm?ftt&id615391857885 一、读取旧Ntag卡的UID和数据 Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click轻松读卡技术支持:网站:Dim i, j As IntegerDim cardidhex, …...

Debian系统简介

目录 Debian系统介绍 Debian版本介绍 Debian软件源介绍 软件包管理工具dpkg dpkg核心指令详解 安装软件包 卸载软件包 查询软件包状态 验证软件包完整性 手动处理依赖关系 dpkg vs apt Debian系统介绍 Debian 和 Ubuntu 都是基于 Debian内核 的 Linux 发行版&#xff…...

AtCoder 第409​场初级竞赛 A~E题解

A Conflict 【题目链接】 原题链接&#xff1a;A - Conflict 【考点】 枚举 【题目大意】 找到是否有两人都想要的物品。 【解析】 遍历两端字符串&#xff0c;只有在同时为 o 时输出 Yes 并结束程序&#xff0c;否则输出 No。 【难度】 GESP三级 【代码参考】 #i…...

渲染学进阶内容——模型

最近在写模组的时候发现渲染器里面离不开模型的定义,在渲染的第二篇文章中简单的讲解了一下关于模型部分的内容,其实不管是方块还是方块实体,都离不开模型的内容 🧱 一、CubeListBuilder 功能解析 CubeListBuilder 是 Minecraft Java 版模型系统的核心构建器,用于动态创…...

【RockeMQ】第2节|RocketMQ快速实战以及核⼼概念详解(二)

升级Dledger高可用集群 一、主从架构的不足与Dledger的定位 主从架构缺陷 数据备份依赖Slave节点&#xff0c;但无自动故障转移能力&#xff0c;Master宕机后需人工切换&#xff0c;期间消息可能无法读取。Slave仅存储数据&#xff0c;无法主动升级为Master响应请求&#xff…...

从 GreenPlum 到镜舟数据库:杭银消费金融湖仓一体转型实践

作者&#xff1a;吴岐诗&#xff0c;杭银消费金融大数据应用开发工程师 本文整理自杭银消费金融大数据应用开发工程师在StarRocks Summit Asia 2024的分享 引言&#xff1a;融合数据湖与数仓的创新之路 在数字金融时代&#xff0c;数据已成为金融机构的核心竞争力。杭银消费金…...

go 里面的指针

指针 在 Go 中&#xff0c;指针&#xff08;pointer&#xff09;是一个变量的内存地址&#xff0c;就像 C 语言那样&#xff1a; a : 10 p : &a // p 是一个指向 a 的指针 fmt.Println(*p) // 输出 10&#xff0c;通过指针解引用• &a 表示获取变量 a 的地址 p 表示…...

热烈祝贺埃文科技正式加入可信数据空间发展联盟

2025年4月29日&#xff0c;在福州举办的第八届数字中国建设峰会“可信数据空间分论坛”上&#xff0c;可信数据空间发展联盟正式宣告成立。国家数据局党组书记、局长刘烈宏出席并致辞&#xff0c;强调该联盟是推进全国一体化数据市场建设的关键抓手。 郑州埃文科技有限公司&am…...

Linux 下 DMA 内存映射浅析

序 系统 I/O 设备驱动程序通常调用其特定子系统的接口为 DMA 分配内存&#xff0c;但最终会调到 DMA 子系统的dma_alloc_coherent()/dma_alloc_attrs() 等接口。 关于 dma_alloc_coherent 接口详细的代码讲解、调用流程&#xff0c;可以参考这篇文章&#xff0c;我觉得写的非常…...

负载均衡器》》LVS、Nginx、HAproxy 区别

虚拟主机 先4&#xff0c;后7...