Android 開(kāi)機(jī)充電圖標(biāo)和充電動(dòng)畫(huà)效果
首先驅(qū)動(dòng)需要先獲取到2個(gè)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_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;
}
充電的閃電圖標(biāo)和充電動(dòng)畫(huà)啟動(dòng)邏輯
閃電圖標(biāo)啟動(dòng)邏輯:POWER_SUPPLY_TYPE_USB的power supply上報(bào)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);
充電動(dòng)畫(huà)的啟動(dòng)邏輯:POWER_SUPPLY_TYPE_BATTERY的power supply上報(bào)充電狀態(tài)
(CHARGE_STATE_NOT_CHARGING,CHARGE_STATE_FASTCHARGE) bq->charge_state = CHARGE_STATE_FASTCHARGE; power_supply_changed(&bq->batt_psy);
利用dumpsys分析當(dāng)前battery 狀態(tài)
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
如上主要關(guān)注2個(gè)字段:
USB powered : true
那么閃電圖標(biāo)應(yīng)該會(huì)出現(xiàn)
status: 2
那么充電動(dòng)畫(huà)應(yīng)該啟動(dòng)了
同時(shí)我們還可以通過(guò)shell指令的方式啟動(dòng)充電圖標(biāo)和充電動(dòng)畫(huà)
dumpsys battery set usb 1
閃電圖標(biāo)應(yīng)該會(huì)出現(xiàn)
dumpsys battery set status 2
充電動(dòng)畫(huà)應(yīng)該啟動(dòng)了
dumpsys battery set usb 0
閃電圖標(biāo)消失
dumpsys battery set status 4
充電動(dòng)畫(huà)消失
總結(jié)
以上所述是小編給大家介紹的Android 開(kāi)機(jī)充電圖標(biāo)和充電動(dòng)畫(huà)效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
ListView點(diǎn)擊Item展開(kāi)菜單實(shí)現(xiàn)代碼詳解
這篇文章主要介紹了ListView點(diǎn)擊Item展開(kāi)菜單實(shí)現(xiàn)代碼詳解的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
Kotlin標(biāo)準(zhǔn)庫(kù)函數(shù)使用分析及介紹
Kotlin提供了一個(gè)系統(tǒng)庫(kù),是Java庫(kù)的增強(qiáng)。其中有很多函數(shù)在適配了Java的類型和方法同時(shí)使用Kotlin的語(yǔ)法。其中一些底層的函數(shù) 是使用比較廣泛的2022-09-09
Android Studio 中的Gradle構(gòu)建系統(tǒng)示例
這篇文章主要介紹了Android Studio 中的Gradle構(gòu)建系統(tǒng)示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-11-11
Android PhoneWindowManager監(jiān)聽(tīng)屏幕右側(cè)向左滑動(dòng)實(shí)現(xiàn)返回功能
這篇文章主要介紹了Android PhoneWindowManager監(jiān)聽(tīng)屏幕右側(cè)向左滑動(dòng)實(shí)現(xiàn)返回功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04
android 仿微信demo——登錄功能實(shí)現(xiàn)(服務(wù)端)
這系列文章主要介紹了微信小程序-閱讀小程序?qū)嵗?,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧,希望能給你們提供幫助2021-06-06
Android中SparseArray性能優(yōu)化的使用方法
這篇文章主要為大家詳細(xì)介紹了Android中SparseArray性能優(yōu)化的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-04-04
Jetpack?Compose?的新型架構(gòu)?MVI使用詳解
這篇文章主要介紹了Jetpack?Compose?的新型架構(gòu)?MVI使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09

