bug 现象:设置闹钟或静音模式后,状态栏不显示图标,但下拉状态栏中有显示
在网上搜索了下没人报这个问题,大家是都默认了???
找到一篇报道有写,bug 相关
关于 Bug 修复方面,Android 12 Beta 4 修复了部分未接来电通知无法关闭的问题,
修复了系统主题颜色不适用某些快速设置图块的问题,
修复了快速设置图块在拖动或重新排列时,未与网格对齐的问题。修复了通知栏不显示闹钟和静音图标的问题。
patch
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -203,8 +203,9 @@ public class KeyguardStatusBarView extends RelativeLayout implements // Set hidden status bar items private void loadBlockList() { Resources r = getResources(); - mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_volume)); - mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_alarm_clock)); + //aosp bug block alarm and mute icon + // mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_volume)); + // mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_alarm_clock)); mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_call_strength)); }
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
@@ -158,8 +158,9 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue } mDarkIconManager = new DarkIconManager(view.findViewById(R.id.statusIcons), mFeatureFlags); mDarkIconManager.setShouldLog(true); - mBlockedIcons.add(getString(com.android.internal.R.string.status_bar_volume)); - mBlockedIcons.add(getString(com.android.internal.R.string.status_bar_alarm_clock)); + //aosp bug block alarm and mute icon + // mBlockedIcons.add(getString(com.android.internal.R.string.status_bar_volume)); + // mBlockedIcons.add(getString(com.android.internal.R.string.status_bar_alarm_clock)); mBlockedIcons.add(getString(com.android.internal.R.string.status_bar_call_strength)); mDarkIconManager.setBlockList(mBlockedIcons);
分析思路:
状态栏icon对应 StatusBarIconView,找到其中
setVisibility(icon.visible && !mBlocked ? VISIBLE : GONE); 可以看到有个 mBlocked,有的显示有的不显示,那应该就是被黑了。
StatusBarIconControllerImpl.java
onTuningChanged(String key, String newValue) {
mIconHideList.addAll(StatusBarIconController.getIconHideList(mContext, newValue));
addSystemIcon(int index, StatusBarIconHolder holder) { boolean hidden = mIconHideList.contains(slot); l.onIconAdded(viewIndex, slot, hidden, holder));
StatusBarIconController.java
addHolder(int index, String slot, boolean blocked, StatusBarIconHolder holder) {
if (mBlockList.contains(slot)) {
blocked = true;
}
switch (holder.getType()) {
case TYPE_ICON:
return addIcon(index, slot, blocked, holder.getIcon());
被黑有两种方式,均在 StatusBarIconController 中过滤
第一种看到上面直接传递的 blocked,通过 config.xml 中配置
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\StatusBarIconController.java
static ArraySet<String> getIconHideList(Context context, String hideListStr) { ArraySet<String> ret = new ArraySet<>(); String[] hideList = hideListStr == null ? context.getResources().getStringArray(R.array.config_statusBarIconsToExclude) : hideListStr.split(","); for (String slot : hideList) { if (!TextUtils.isEmpty(slot)) { ret.add(slot); } } return ret; }
frameworks\base\packages\SystemUI\res\values\config.xml
<string-array name="config_statusBarIconsToExclude" translatable="false"> <item>@*android:string/status_bar_rotate</item> <item>@*android:string/status_bar_headset</item> </string-array>
可以看到耳机(headset)和旋转(rotate)被黑了
第二种,通过 mBlockList 进行添加,静音(volume)和闹钟(alarm_clock)和call_strength被黑了
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\StatusBarIconController.java
public void setBlockList(@Nullable List<String> blockList) { mBlockList.clear(); if (blockList == null || blockList.isEmpty()) { return; } mBlockList.addAll(blockList); }
KeyguardStatusBarView.java CollapsedStatusBarFragment.java
private void loadBlockList() { Resources r = getResources(); mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_volume)); mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_alarm_clock)); mBlockedIcons.add(r.getString(com.android.internal.R.string.status_bar_call_strength)); }