Android中怎么实现开机充电图标和充电动画效果

发布时间:2021-06-09 18:02:57 作者:Leah
来源:亿速云 阅读:475

本篇文章为大家展示了Android中怎么实现开机充电图标和充电动画效果,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

kernel\msm-3.18\drivers\usb\phy\phy-msm-usb.c

motg->usb_psy.name = "usb";
motg->usb_psy.type = POWER_SUPPLY_TYPE_USB;
motg->usb_psy.supplied_to = otg_pm_power_supplied_to;
motg->usb_psy.num_supplicants = ARRAY_SIZE(otg_pm_power_supplied_to);
motg->usb_psy.properties = otg_pm_power_props_usb;
motg->usb_psy.num_properties = ARRAY_SIZE(otg_pm_power_props_usb);
motg->usb_psy.get_property = otg_power_get_property_usb;
motg->usb_psy.set_property = otg_power_set_property_usb;
motg->usb_psy.property_is_writeable
  = otg_power_property_is_writeable_usb;

if (!msm_otg_register_power_supply(pdev, motg))
  psy = &motg->usb_psy;

kernel\msm-3.18\drivers\power\bq2570x\bq2570x_charger.c

 usb_psy = power_supply_get_by_name("usb");

static int bq2570x_psy_register(struct bq2570x *bq)
{
  int ret;

  bq->batt_psy.name = "dc_o2";
  bq->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
  bq->batt_psy.properties = bq2570x_charger_props;
  bq->batt_psy.num_properties = ARRAY_SIZE(bq2570x_charger_props);
  bq->batt_psy.get_property = bq2570x_charger_get_property;
  bq->batt_psy.set_property = bq2570x_charger_set_property;
  bq->batt_psy.external_power_changed = bq2570x_external_power_changed;
  bq->batt_psy.property_is_writeable = bq2570x_charger_is_writeable;

  ret = power_supply_register(bq->dev, &bq->batt_psy);
  if (ret < 0) {
    pr_err("failed to register batt_psy:%d\n", ret);
    return ret;
  }

  return 0;
}

充电的闪电图标和充电动画启动逻辑

闪电图标启动逻辑:POWER_SUPPLY_TYPE_USB的power supply上报USB类型(CDP,DCP,USB)

power_supply_set_supply_type(bq->usb_psy, POWER_SUPPLY_TYPE_USB);
ret = power_supply_set_online(bq->usb_psy, true);
power_supply_changed(bq->usb_psy);

充电动画的启动逻辑:POWER_SUPPLY_TYPE_BATTERY的power supply上报充电状态

(CHARGE_STATE_NOT_CHARGING,CHARGE_STATE_FASTCHARGE)
bq->charge_state = CHARGE_STATE_FASTCHARGE;
power_supply_changed(&bq->batt_psy);

利用dumpsys分析当前battery 状态

V2_PRO:/ # dumpsys battery
Current Battery Service state:
 AC powered: false
 USB powered: true
 Wireless powered: false
 Max charging current: 0
 Max charging voltage: 0
 Charge counter: 0
 status: 2
 health: 2
 present: true
 level: 46
 scale: 100
 voltage: 7
 temperature: 270
 technology: Li-ion

上述内容就是Android中怎么实现开机充电图标和充电动画效果,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 新能源充电转换模块
  2. Android中检查、监听电量和充电状态的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android

上一篇:Spring Boot 中怎么配置条件注解

下一篇:如何在Java虚拟机中处理异常

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》