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

发布时间:2026/11/20 0:20:55
Android16 蓝牙打开时,状态栏显示蓝牙图标 说明本修改主要针对 Android 16API 36AOSP 源码中的 SystemUI 模块。项目内容适用版本Android 16API 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:androidhttp://schemas.android.com/apk/res/androidandroid:width17dpandroid:height17dpandroid:viewportWidth17.0android:viewportHeight17.0groupandroid:translateY0.5android:translateX0.5pathandroid:pathDataM8.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.63zandroid:fillColor#FFFFFF//group/vector2. 修改PhoneStatusBarPolicy.java路径frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java方法updateBluetooth()修改前privatefinalvoidupdateBluetooth(){inticonIdR.drawable.stat_sys_data_bluetooth_connected;StringcontentDescriptionmResources.getString(R.string.accessibility_quick_settings_bluetooth_on);booleanbluetoothVisiblefalse;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())){contentDescriptionmResources.getString(R.string.accessibility_bluetooth_connected);bluetoothVisiblemBluetooth.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;inticonIdR.drawable.stat_sys_data_bluetooth;StringcontentDescriptionmResources.getString(R.string.accessibility_quick_settings_bluetooth_on);booleanbluetoothVisiblefalse;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 openbluetoothVisiblemBluetooth.isBluetoothEnabled();if(mBluetooth.isBluetoothConnected()(mBluetooth.isBluetoothAudioActive()||!mBluetooth.isBluetoothAudioProfileOnly())){contentDescriptionmResources.getString(R.string.accessibility_bluetooth_connected);bluetoothVisiblemBluetooth.isBluetoothEnabled();// Create by yeruilai 2026-6-6 19:54:14 Display Bluetooth icon when openiconIdR.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; } }附图

关于本文作者

来自尧图内容编辑团队

尧图内容编辑团队 内容团队

尧图内容编辑团队

本文由尧图网络内容编辑团队执笔。团队由资深项目经理、前端工程师与设计师组成,所有内容均来自亲手交付的真实项目,先讲清问题、再给出可落地的解法。尧图深耕北京网站建设十年,服务过京华建材集团、智造科技等各行业客户,把一线经验沉淀为可复用的行业观察。

  • 十年建站经验,覆盖建材、制造、服务、文创等
  • 项目经理把关选题与事实准确性
  • 工程师与设计师联合撰写专业细节
  • 统一编辑规范,保证文风与排版一致
  • 每月复盘转化数据,迭代选题方向

延伸阅读

相关资讯与近期热门内容

深度阅读推荐

建站决策前值得细读的三篇

网站改版的5个关键决策
2024-08-12

网站改版的5个关键决策

什么时候该改版、改到什么程度、如何避免流量掉光,京华建材集团改版复盘给出答案。

获取专属建站方案

看完文章,把您的行业与预算告诉我们,免费获取一份量身定制的官网建设方案与报价。

立即免费咨询