Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Android to realize boot charging icon and charging animation effect

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use Android to achieve boot charging icon and charging animation effects, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

First of all, the driver needs to get 2 power supply first.

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)

Start-up logic of charging animation: power supply of POWER_SUPPLY_TYPE_BATTERY reports charging status

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

Using dumpsys to analyze the current battery status

V2_PRO:/ # dumpsys batteryCurrent 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

As mentioned above, we mainly focus on 2 fields:

USB powered: true

Then the lightning icon should appear.

Status: 2

Then the charging animation should be started.

At the same time, we can also start the charging icon and charging animation by shell command.

Dumpsys battery set usb 1

The lightning icon should appear.

Dumpsys battery set status 2

The charging animation should be started.

Dumpsys battery set usb 0

The lightning icon disappears.

Dumpsys battery set status 4

Charging animation disappears

The above is all the content of this article "how to use Android to achieve boot charging icon and charging animation effect". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report