首先,驱动程序必须获取两个power supply 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 _ supplicant s=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\bq 2570 x\bq 2570 x _ charger.c
USB _ psy=power _ supply _ get _ by _ name ( USB ); staticintbq 2570 x _ psy _ register ( struct bq 2570 x * bq ) {int ret; bq-batt_psy.name=’dc_o2 ‘; bq-batt _ psy.type=power _ supply _ type _ battery; bq-batt _ psy.properties=bq 2570 x _ charger _ props; bq-batt _ psy.num _ properties=array _ size ( bq 2570 x _ charger _ props ); bq-batt _ psy.get _ property=bq 2570 x _ charger _ get _ property; bq-batt _ psy.set _ property=bq 2570 x _ charger _ set _ property; bq-batt _ psy.external _ power _ changed=bq 2570 x _ external _ power _ changed; bq-batt _ psy.property _ is _ writeable=bq 2570 x _ charger _ is _ writeable; ret=power _ supply _ register ( bq-dev,bq-batt_psy; if(ret0) pr _ err ( failedtoregisterbatt _ psy:% d\n (,ret ); 返回; }return 0; }充电的闪电图标和充电动画启动逻辑闪电图标启动逻辑:向POWER_SUPPLY_TYPE_USB的powersupplyUSB类型( 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 _ bate )
bq-charge _ state=charge _ state _ fast charge; power _ supply _ changed ( bq-batt _ psy; dumpsys中当前的battery状态V2_PRO:/# 分析的dumpsysbatterycurrentbatteryservicestate:AC powered:falseusbpowered:truewirelesspowered:falsemaxchargingcurrent:0 us:2 health:2 present:true level:46 scale:100 voltage:7 temperature:270 technology:Li-ion如上所述
USB powered : true
应该会出现闪电图标
在status: 2中,应启动充电动画
也可以使用shell命令启动充电图标和充电动画
dumpsys battery set usb 1
应该会出现闪电图标
dumpsys battery set status 2
充电动画应该启动了
dumpsys battery set usb 0
闪电图标消失
dumpsys battery set status 4
充值视频消失