news 2026/7/21 8:38:02

Android16 蓝牙打开时,状态栏显示蓝牙图标

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Android16 蓝牙打开时,状态栏显示蓝牙图标

说明

本修改主要针对 Android 16(API 36)AOSP 源码中的 SystemUI 模块。

项目内容
适用版本Android 16(API 36)
涉及模块frameworks/base/packages/SystemUI
修改类PhoneStatusBarPolicy
修改方法updateBluetooth()

在 Android 16 原生 SystemUI 中,PhoneStatusBarPolicy.updateBluetooth()默认仅在蓝牙已连接且满足音频 Profile 条件时才显示状态栏图标。用户仅打开蓝牙开关、尚未连接设备时,状态栏不会出现蓝牙图标,与快捷设置中蓝牙已开启的状态不一致。

本次修改在 Android 16 上实现:

  • 蓝牙开启即显示stat_sys_data_bluetooth图标(新增资源)
  • 蓝牙已连接时切换为stat_sys_data_bluetooth_connected图标
  • 蓝牙关闭时隐藏图标

若移植到其他 Android 版本,需确认对应分支中PhoneStatusBarPolicy.java路径及updateBluetooth()实现是否一致,资源命名是否相同。


修改文件

frameworks/base/packages/SystemUI/res/drawable/stat_sys_data_bluetooth.xml (新增) frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java (修改)

1. 新增stat_sys_data_bluetooth.xml

路径:frameworks/base/packages/SystemUI/res/drawable/stat_sys_data_bluetooth.xml

<!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><vectorxmlns:android="http://schemas.android.com/apk/res/android"android:width="17dp"android:height="17dp"android:viewportWidth="17.0"android:viewportHeight="17.0"><groupandroid:translateY="0.5"android:translateX="0.5"><pathandroid:pathData="M8.84,8l2.62,-2.62c0.29,-0.29 0.29,-0.75 0,-1.04L8.33,1.22L8.31,1.2c-0.3,-0.28 -0.76,-0.26 -1.03,0.04c-0.13,0.13 -0.2,0.31 -0.2,0.5v4.51L4.24,3.4c-0.29,-0.29 -0.74,-0.29 -1.03,0s-0.29,0.74 0,1.03L6.78,8l-3.56,3.56c-0.29,0.29 -0.29,0.74 0,1.03s0.74,0.29 1.03,0l2.83,-2.83v4.51c0,0.4 0.33,0.73 0.73,0.73c0.18,0 0.36,-0.07 0.5,-0.2l0.03,-0.03l3.12,-3.12c0.29,-0.29 0.29,-0.75 0,-1.04L8.84,8zM8.47,6.37V3.36l1.5,1.5L8.47,6.37zM8.47,12.63V9.62l1.5,1.5L8.47,12.63z"android:fillColor="#FFFFFF"/></group></vector>

2. 修改PhoneStatusBarPolicy.java

路径:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java

方法:updateBluetooth()

修改前

privatefinalvoidupdateBluetooth(){inticonId=R.drawable.stat_sys_data_bluetooth_connected;StringcontentDescription=mResources.getString(R.string.accessibility_quick_settings_bluetooth_on);booleanbluetoothVisible=false;if(mBluetooth!=null){// Bug 2687381, The Bluetooth icon is not displayed normally.Log.d(TAG,"updateBluetooth(), mIsActive:"+mBluetooth.isBluetoothAudioActive());if(mBluetooth.isBluetoothConnected()&&(mBluetooth.isBluetoothAudioActive()||!mBluetooth.isBluetoothAudioProfileOnly())){contentDescription=mResources.getString(R.string.accessibility_bluetooth_connected);bluetoothVisible=mBluetooth.isBluetoothEnabled();}}// ...}

修改后

privatefinalvoidupdateBluetooth(){// Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when open// int iconId = R.drawable.stat_sys_data_bluetooth_connected;inticonId=R.drawable.stat_sys_data_bluetooth;StringcontentDescription=mResources.getString(R.string.accessibility_quick_settings_bluetooth_on);booleanbluetoothVisible=false;if(mBluetooth!=null){// Bug 2687381, The Bluetooth icon is not displayed normally.Log.d(TAG,"updateBluetooth(), mIsActive:"+mBluetooth.isBluetoothAudioActive());// Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when openbluetoothVisible=mBluetooth.isBluetoothEnabled();if(mBluetooth.isBluetoothConnected()&&(mBluetooth.isBluetoothAudioActive()||!mBluetooth.isBluetoothAudioProfileOnly())){contentDescription=mResources.getString(R.string.accessibility_bluetooth_connected);bluetoothVisible=mBluetooth.isBluetoothEnabled();// Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when openiconId=R.drawable.stat_sys_data_bluetooth_connected;}}// ...}

修改点

private final void updateBluetooth() { - int iconId = R.drawable.stat_sys_data_bluetooth_connected; + // Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when open + // int iconId = R.drawable.stat_sys_data_bluetooth_connected; + int iconId = R.drawable.stat_sys_data_bluetooth; String contentDescription = mResources.getString(R.string.accessibility_quick_settings_bluetooth_on); boolean bluetoothVisible = false; if (mBluetooth != null) { // Bug 2687381, The Bluetooth icon is not displayed normally. Log.d(TAG, "updateBluetooth(), mIsActive:" + mBluetooth.isBluetoothAudioActive()); + // Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when open + bluetoothVisible = mBluetooth.isBluetoothEnabled(); if (mBluetooth.isBluetoothConnected() && (mBluetooth.isBluetoothAudioActive() || !mBluetooth.isBluetoothAudioProfileOnly())) { contentDescription = mResources.getString( R.string.accessibility_bluetooth_connected); bluetoothVisible = mBluetooth.isBluetoothEnabled(); + // Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when open + iconId = R.drawable.stat_sys_data_bluetooth_connected; } }

附图

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/21 8:36:34

Grok CLI重大更新前瞻:AI命令行工具部署与代码生成实践

这次我们来看一个备受关注的技术动态&#xff1a;xAI 即将在下周发布 Grok CLI 的重大更新。对于关注 AI 命令行工具和代码辅助的开发者来说&#xff0c;这绝对是一个值得关注的消息。Grok CLI 作为 xAI 推出的命令行界面工具&#xff0c;主要面向开发者和技术用户&#xff0c;…

作者头像 李华
网站建设 2026/7/21 8:34:18

C2000 HRCAP高分辨率捕获模块:从校准到实战的精密时间测量指南

1. 项目概述&#xff1a;为什么我们需要高分辨率捕获&#xff1f;在电机控制、数字电源或者精密仪器开发的圈子里混久了&#xff0c;你肯定遇到过这样的场景&#xff1a;需要测量一个高速旋转编码器的脉冲间隔&#xff0c;或者解析一个脉宽调制信号的精确占空比。普通的定时器捕…

作者头像 李华
网站建设 2026/7/21 8:33:19

深入解析TI EVE内存架构:DMEM、WBUF、IBUF与程序缓存协同设计

1. 项目概述&#xff1a;EVE内存架构的核心价值在嵌入式视觉处理领域&#xff0c;尤其是汽车ADAS、信息娱乐系统这类对实时性要求极高的场景里&#xff0c;处理器的算力固然重要&#xff0c;但内存架构的设计往往才是决定整个系统性能上限和稳定性的“隐形冠军”。想象一下&…

作者头像 李华
网站建设 2026/7/21 8:32:56

YOLOv11室内办公环境绝缘手套目标检测数据集

YOLOv11室内办公环境绝缘手套目标检测数据集 &#x1f4ca; 数据集基本信息 目标类别&#xff1a; [‘Left Insulation Gloves’, ‘Right Insulation Gloves’]中文类别&#xff1a;[‘左侧绝缘手套’, ‘右侧绝缘手套’]训练集&#xff1a;1593 张验证集&#xff1a;455 张测…

作者头像 李华
网站建设 2026/7/21 8:32:32

深入解析C2000 DSP Bootloader:从启动模式到数据流协议实战

1. 项目概述与核心价值如果你正在开发基于德州仪器C2000系列DSP的嵌入式系统&#xff0c;那么Bootloader绝对是你绕不开的核心话题。这不仅仅是芯片上电后执行的第一段代码&#xff0c;更是连接硬件初始化与应用程序的桥梁&#xff0c;决定了你的系统如何“醒来”并开始工作。很…

作者头像 李华
网站建设 2026/7/21 8:27:10

具身智能的TVA-VLA双引擎架构(系列)

前沿技术探索&#xff1a;AI智能体视觉&#xff08;TVA&#xff0c;Transformer-based Vision Agent&#xff09;是依托Transformer架构与“因式智能体”理论所构建的颠覆性工业视觉技术&#xff0c;是集深度强化学习&#xff08;DRL&#xff09;、卷积神经网络&#xff08;CNN…

作者头像 李华