Android P版本默认蓝牙只在连接的时候才显示连接图标, 如果想要在状态栏显示图标,将图标显示从蓝牙连接内部判断拿出来即可。
路径:vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarPolicy.java
private final void updateBluetooth() {
int iconId = R.drawable.stat_sys_data_bluetooth;
String contentDescription =
mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
boolean bluetoothVisible = false;
if (mBluetooth != null) {
+ bluetoothVisible = mBluetooth.isBluetoothEnabled();//添加这句
if (mBluetooth.isBluetoothConnected()) {
iconId = R.drawable.stat_sys_data_bluetooth_connected;
contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
- //bluetoothVisible = mBluetooth.isBluetoothEnabled();删掉这句
}
}
mIconController.setIcon(mSlotBluetooth, iconId, contentDescription);
mIconController.setIconVisibility(mSlotBluetooth, bluetoothVisible);
}