android13中锁屏界面充电信息显示

android13中锁屏界面充电信息显示

平台支持在锁屏界面针对不同充电速度显示不同的充电提示语,快充、慢充对应的充电功率在相关配置文件中配置。相关代码逻辑如下:

根据充电速度mChargingSpeed显示对应提示语
SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
811 protected String computePowerIndication() {

823 switch (mChargingSpeed) {
824 case BatteryStatus.CHARGING_FAST:
825 chargingId = hasChargingTime
826 ? R.string.keyguard_indication_charging_time_fast
827 : R.string.keyguard_plugged_in_charging_fast;
828 break;
829 case BatteryStatus.CHARGING_SLOWLY:
830 chargingId = hasChargingTime
831 ? R.string.keyguard_indication_charging_time_slowly
832 : R.string.keyguard_plugged_in_charging_slowly;
833 break;
834 default:
835 chargingId = hasChargingTime
836 ? R.string.keyguard_indication_charging_time
837 : R.string.keyguard_plugged_in;
838 break;
839 }

判断充电速度:快充、慢充、常规充电
frameworks/base/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java
159 /**
160 * Return current chargin speed is fast, slow or normal.
161 *
162 * @return the charing speed
163 */
164 public final int getChargingSpeed(Context context) {
165 final int slowThreshold = context.getResources().getInteger(
166 R.integer.config_chargingSlowlyThreshold);
167 final int fastThreshold = context.getResources().getInteger(
168 R.integer.config_chargingFastThreshold);
169 return maxChargingWattage <= 0 ? CHARGING_UNKNOWN :
170 maxChargingWattage < slowThreshold ? CHARGING_SLOWLY :
171 maxChargingWattage > fastThreshold ? CHARGING_FAST :
172 CHARGING_REGULAR;
173 }

配置文件中小于5w是慢充,大于15w是快充
17
18
19
20 5000000
21
22
23
24 15000000

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值