1.状态栏头部
framelayout:status_bar_container ? phoneStatusBarView:status_bar ? LinearLayout:status_bar_contens ?AlphaOptimizedLinearLayout:system_icon_area 系统icon布局:system_icons 下拉QS界面时状态栏界面:com.android.systemui:id/content 设置界面:android:id/statusBarBackgroundAdbNotifications 增加通知:AdbNotifications
2.修改电池图标样式:
frameworks/base/packages/SettingsLib/res/values/colors.xml ?frameworks/base/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java//更改充电闪电图标的颜色 packages/apps/Settings/src/com/android/settings/Utils.java ? /frameworks/base/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java ? 电池图标的绘制 /packages/apps/Settings/src/com/mediatek/settings/fuelgauge/PowerUsageExts.java ?控制显示的开关 /frameworks/base/packages/SystemUI/res/layout/status_bar.xml ? ? 添加电量显示的textview /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java ? PhoneStatusBar中有个电量变化的监听回调 ?电量显示 /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController ?mBatteryController是一个广播,监听电量变化的广播Intent.ACTION_BATTERY_CHANGED BatteryMeterView //包含了电量的图标和电量百分比 packages/apps/SystemUI/res/layout/system_icons.xml ?系统自定义控件 /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java 在Intent.ACTION_BATTERY_CHANGED broadcast处理中调用fireBatteryLevelChanged()方法 fireBatteryLevelChanged中会回掉BatteryStateChangeCallback frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java中实现了BatteryStateChangeCallback, 并向BatteryControllerImpl注册了,mBatteryController.addCallback(this); 图标布局在 {croot}/frameworks/base/packages/SystemUI/res/layout/battery_detail.xml 状态更新应该在{croot}/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone 新增的工具类:D:\CODE\SystemUiRealme\src\com\oplusos\systemui\keyguard\onscreenfingerprint\OnScreenFingerprintControl.java FlavorTwoStatBatteryMeterView ?//包含了电量的图标和电量百分比的参照类 src-realme/com.oplusos.systemui.statusbar.widget.FlavorOneStatBatteryMeterView ?id/battery ? BatteryMeterView //包含了电量的图标和电量百分比 res-realme/layout/system_icons ?系统自定义控件 FlavorOneStatBatteryMeterView(样式实现类)-StatBatteryMeterView(oppo修改顶级类)-BaseBatteryMeterView(基础) id/airplane ?id/battery_text_out(100%) ?id/battery_content(图标) ?battery-text(100) ? ?stat_battery_view(电池自定义布局) FlavorOneChargeView(充电图标) ?quick_qs_statusbar_battery(下拉时候电池的view) ?stat_system_battery(电池状态) src-onplus/com.oplusos.systemui.statusbar.widget.FlavorTwoBatteryMeterDrawableBase 图标都定义在了/frameworks/base/core/res/res/values/config.xml 中的 config_statusBarIcons 里 本项目自定义修改图标的路径: com.unisoc.systemui.battery.BatteryMeterDrawable
3.左边状态栏树状图 ??
res\layout\status_bar.xml(状态栏)? res\layout\quick_status_bar_expanded_header.xml(QS下拉时的布局)? D:\CODE\SystemUiRealme\src\com\android\systemui\statusbar\notification\row\ExpandableNotificationRow.java 1.StatusBarWindowView(状态栏根布局) ?src\com\android\systemui\statusbar\phone\StatusBarWindowView.java 2.framelayout id/status_bar_container? 3.src\com\android\systemui\statusbar\phone\PhoneStatusBarView.java(主要用来显示系统状态、通知等,主要包括 notification icons和status bar icons )? 3.1) ImageView ? id/notification_lights_out 4.id/status_bar_contents ? 4.0.0)id/heads_up_status_bar_view ?运营商位置信息 ? systemui\statusbar\HeadsUpStatusBarView.java ?heads_up_status_bar_layout(布局)? 4.0.0.0)Space ?id/icon_placeholder 4.0.0.1)TextView ?id/text 4.0.1) id/status_bar_left_side 4.0.1.0)ViewStub ?id/operator_name 4.0.1.1)Clock ?id/clock 4.0.1.2)AlphaOptimizedFrameLayout id/notification_icon_area 4.0.1.2.0)AlphaOptimizedLinearLayout ?id/notification_icon_area_inner 4.0.1.2.0.0)NotificationIconContainer ?id/notificationIcons 4.0.1.2.0.0.0-4)StatusBarIconView(通知栏图标类) 4.1)id/cutout_space_view 4.2)AlphaOptimizedFrameLayout id/centered_icon_area 4.2.0) AlphaOptimizedLinearLayout ?id/center_icon_area_inner 4.3)AlphaOptimizedLinearLayout ?id/system_icon_area 4.3.0)id/system_icons 4.3.0.0)StatusIconContainer ?id/statusIcons 4.3.0.0.0-12)StatusBarIconView 4.3.0.1)BatteryMeterView ?id/battery ?电池自定义布局 4.3.0.1.0)ImageView
src\com\android\systemui\statusbar\phone\StatusBarWindowView.java ? ?? D:\CODE\SystemUiRealme\src\com\android\systemui\statusbar\policy\BatteryController.java X:\nico\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\StatusBarIconView.java X:\nico\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\StatusBarMobileView.java
4.去除暗黑反色问题
方法:DarkIconDispatcherImpl(applyDarkIntensity) ?StatusBarIconView(onDarkChanged)? 类:NotificationIconContainer(通知的管理类) ? ? ?statusbar\phone\StatusBarIconController.java(TintedIconManager/onIconAdded) (1)frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java PWM开始更新SystemUI的状态,此处我们重点关注updateLightStatusBarLw函数 updateLightStatusBarLw根据最上层的窗口确认是否为Light SystemUI的,接下来看下PolicyControl.getSystemUiVisibility (2)frameworks/base/services/core/java/com/android/server/policy/PolicyControl.java 在getSystemUiVisibility中又没有相关LIGHT的操作,那么有跑到了WindowState.getSystemUiVisibility中 (3)frameworks/base/services/core/java/com/android/server/wm/WindowState.java 此处很简单的就是获取mSystemUiVisibility,而mSystemUiVisibility最终是从哪里来的呢,那就要跳到PhoneWindow.java。 (此处跳动有点大,主要是从ViewRootImpl的relayout界面时携带的WindowManager.LayoutParams决定的) (4)frameworks/base/core/java/com/android/internal/policy/PhoneWindow.java 从此处可以看到,下拉栏颜色的设定还是由APP的主题所导致的
5.Systemui接收到StatusBarManagerService对状态栏的状态的update,以及对状态栏的更新
android:windowLightStatusBar ? 是否改变状态栏颜色属性 PhoneStatusBarPolicy.java这个类在初始化的时候注册了大量的监听 设置界面切换颜色: QuickStatusBarHeader: ?mBatteryRemainingIcon.onDarkChanged(tintArea, intensity, fillColor); DecorView View的底层类,涉及到statusbar ? calculateStatusBarColor ?winowLightStatusbar SYSTEM_UI_FLAG_LIGHT_STATUS_BAR <style name="Theme.Settings" parent="Theme.SettingsBase"> <style name="Theme.Settings.Home" parent="Theme.Settings.HomeBase"> 左上角icon图标优化 status_bar_battery_icon_height 时钟图标 ?status_bar_clock_size时钟文字 status_bar_icon_size ? status_bar_system_icon_size icon图标大小 status_bar_icon_drawing_size_dark(notification_header_icon_size_ambient) ? ?status_bar_icon_drawing_size 文件位置:src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java ?res/layout/system_icons.xml
|