下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
【移動(dòng)應(yīng)用開(kāi)發(fā)技術(shù)】怎么在Android8.0中實(shí)現(xiàn)慢充和快充提示語(yǔ)
今天就跟大家聊聊有關(guān)怎么在Android8.0中實(shí)現(xiàn)慢充和快充提示語(yǔ),可能很多人都不太了解,為了讓大家更加了解,在下給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。1.慢充和快充提示語(yǔ)\frameworks\base\packages\SystemUI\res-keyguard\values-zh-rCN中文提示語(yǔ)<string
name="keyguard_plugged_in"
msgid="89308975354638682">"正在充電"</string>
<string
name="keyguard_plugged_in_charging_fast"
msgid="8869226755413795173">"正在快速充電"</string>
<string
name="keyguard_plugged_in_charging_slowly"
msgid="6637043106038550407">"正在慢速充電"</string>英文提示語(yǔ)\frameworks\base\packages\SystemUI\res-keyguard\values1.快充充電器充電-顯示快速充電字符串<!--
When
the
lock
screen
is
showing
and
the
phone
plugged
in,
and
the
battery
is
not
fully
charged,
and
it's
plugged
into
a
fast
charger,
say
that
it's
charging
fast.
-->
<string
name="keyguard_plugged_in_charging_fast">Charging
rapidly</string>2.普通充電電器-顯示充電,該同7.0及其以前特性<!--
When
the
lock
screen
is
showing
and
the
phone
plugged
in,
and
the
battery
is
not
fully
charged,
say
that
it's
charging.
-->
<string
name="keyguard_plugged_in">Charging</string>3.電腦端或者筆記本端顯示-緩慢充電<!--
When
the
lock
screen
is
showing
and
the
phone
plugged
in,
and
the
battery
is
not
fully
charged,
and
it's
plugged
into
a
slow
charger,
say
that
it's
charging
slowly.
-->
<string
name="keyguard_plugged_in_charging_slowly">Charging
slowly</string>2.原理根據(jù)當(dāng)前的最大電壓和電流計(jì)算出電流速度,并進(jìn)行分類(lèi)為慢速充電,充電,快速充電2.1源代碼中的原始數(shù)據(jù)?public
static
final
String
EXTRA_MAX_CHARGING_CURRENT
=
“max_charging_current”;
?public
static
final
String
EXTRA_MAX_CHARGING_VOLTAGE
=
“max_charging_voltage”;發(fā)送“電池廣播”位置將最大電流和電壓上發(fā)應(yīng)用層,這里主要一些8.1以上新增的數(shù)據(jù),7.0以前有這個(gè)數(shù)據(jù)但是framework層沒(méi)有使用frameworks/base/services/core/java/com/android/server/BatteryService.java
//
發(fā)送電池廣播事件
private
void
sendIntentLocked()
{
//
Pack
up
the
values
and
broadcast
them
to
everyone
final
Intent
intent
=
new
Intent(Intent.ACTION_BATTERY_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
|
Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_CURRENT,
mBatteryProps.maxChargingCurrent);
intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE,
mBatteryProps.maxChargingVoltage);2.2adbshell查看linux的文件節(jié)點(diǎn)?獲取當(dāng)前的電流adb
shell
cat
/sys/class/power_supply/battery/current_max
adb
shell
cat
/sys/class/power_supply/battery/current_max
30000001?獲取當(dāng)前的電壓adb
shell
cat
/sys/class/power_supply/battery/voltage_max
adb
shell
cat
/sys/class/power_supply/battery/voltage_max
50000001?具體源碼system/core/healthd/BatteryMonitor.cpp
#define
POWER_SUPPLY_SYSFS_PATH
"/sys/class/"
POWER_SUPPLY_SUBSYSTEM
path.appendFormat("%s/%s/voltage_max",
POWER_SUPPLY_SYSFS_PATH,mChargerNames[i].string());2.3上層接收廣播frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java重點(diǎn)看maxChargingMicroAmp和maxChargingMicroVolt的算法規(guī)則private
final
BroadcastReceiver
mBroadcastReceiver
=
new
BroadcastReceiver()
{
}
else
if
(Intent.ACTION_BATTERY_CHANGED.equals(action))
{
final
int
status
=
intent.getIntExtra(EXTRA_STATUS,
BATTERY_STATUS_UNKNOWN);
final
int
plugged
=
intent.getIntExtra(EXTRA_PLUGGED,
0);
final
int
level
=
intent.getIntExtra(EXTRA_LEVEL,
0);
final
int
health
=
intent.getIntExtra(EXTRA_HEALTH,
BATTERY_HEALTH_UNKNOWN);
final
int
maxChargingMicroAmp
=
intent.getIntExtra(EXTRA_MAX_CHARGING_CURRENT,
-1);
int
maxChargingMicroVolt
=
intent.getIntExtra(EXTRA_MAX_CHARGING_VOLTAGE,
-1);
final
int
maxChargingMicroWatt;
if
(maxChargingMicroVolt
<=
0)
{
maxChargingMicroVolt
=
DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT;
}
if
(maxChargingMicroAmp
>
0)
{
//
Calculating
muW
=
muA
*
muV
/
(10^6
mu^2
/
mu);
splitting
up
the
divisor
//
to
maintain
precision
equally
on
both
factors.
maxChargingMicroWatt
=
(maxChargingMicroAmp
/
1000)
*
(maxChargingMicroVolt
/
1000);
}
else
{
maxChargingMicroWatt
=
-1;
}
final
Message
msg
=
mHandler.obtainMessage(
MSG_BATTERY_UPDATE,
new
BatteryStatus(status,
level,
plugged,
health,
maxChargingMicroWatt));
mHandler.sendMessage(msg);2.4顯示字符串frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java事件接收protected
class
BaseKeyguardCallback
extends
KeyguardUpdateMonitorCallback
{
public
static
final
int
HIDE_DELAY_MS
=
5000;
private
int
mLastSuccessiveErrorMessage
=
-1;
@Override
public
void
onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus
status)
{
boolean
isChargingOrFull
=
status.status
==
BatteryManager.BATTERY_STATUS_CHARGING
||
status.status
==
BatteryManager.BATTERY_STATUS_FULL;
boolean
wasPluggedIn
=
mPowerPluggedIn;
mPowerPluggedIn
=
status.isPluggedIn()
&&
isChargingOrFull;
mPowerCharged
=
status.isCharged();
mChargingWattage
=
status.maxChargingWattage;
mChargingSpeed
=
status.getChargingSpeed(mSlowThreshold,
mFastThreshold);
updateIndication();
if
(mDozing)
{
if
(!wasPluggedIn
&&
mPowerPluggedIn)
{
showTransientIndication(computePowerIndication());
hideTransientIndicationDelayed(HIDE_DELAY_MS);
}
else
if
(wasPluggedIn
&&
!mPowerPluggedIn)
{
hideTransientIndication();
}
}
}
=====================================================================================================
public
static
class
BatteryStatus
{
public
static
final
int
CHARGING_UNKNOWN
=
-1;
public
static
final
int
CHARGING_SLOWLY
=
0;
public
static
final
int
CHARGING_REGULAR
=
1;
public
static
final
int
CHARGING_FAST
=
2;
public
final
int
status;
public
final
int
level;
public
final
int
plugged;
public
final
int
health;
public
final
int
maxChargingWattage;
public
BatteryStatus(int
status,
int
level,
int
plugged,
int
health,
int
maxChargingWattage)
{
this.status
=
status;
this.level
=
level;
this.plugged
=
plugged;
this.health
=
health;
this.maxChargingWattage
=
maxChargingWattage;
}
public
final
int
getChargingSpeed(int
slowThreshold,
int
fastThreshold)
{
return
maxChargingWattage
<=
0
?
CHARGING_UNKNOWN
:
maxChargingWattage
<
slowThreshold
?
CHARGING_SLOWLY
:
maxChargingWattage
>
fastThreshold
?
CHARGING_FAST
:
CHARGING_REGULAR;
}顯示字符串frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationCon
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年路面保護(hù)合同樣本
- 2025版申通快遞股權(quán)轉(zhuǎn)讓涉及的競(jìng)業(yè)限制合同3篇
- 2024年熱軋卷板采購(gòu)協(xié)議
- 2025年度板材定制加工及銷(xiāo)售合同范本3篇
- 2024年中國(guó)塑料冰桶市場(chǎng)調(diào)查研究報(bào)告
- 2025版綠色環(huán)保財(cái)產(chǎn)分割與節(jié)能減排離婚協(xié)議3篇
- 2024年03月重慶2024年重慶銀行投資銀行部招考筆試歷年參考題庫(kù)附帶答案詳解
- 2024年特許經(jīng)營(yíng)合同(餐飲業(yè))
- 空中飛人模板課程設(shè)計(jì)
- 2025至2030年中國(guó)鮮橙飲品行業(yè)投資前景及策略咨詢(xún)研究報(bào)告
- 藥理學(xué)(浙江大學(xué))智慧樹(shù)知到答案2024年浙江大學(xué)
- 北京市東城區(qū)2023-2024學(xué)年八年級(jí)上學(xué)期期末生物試題【含答案解析】
- 2023-2024學(xué)年深圳市初三中考適應(yīng)性考試英語(yǔ)試題(含答案)
- 2024年貴州貴安發(fā)展集團(tuán)有限公司招聘筆試參考題庫(kù)附帶答案詳解
- 12、口腔科診療指南及技術(shù)操作規(guī)范
- 最易懂的杰普遜航圖學(xué)習(xí)課件
- 高速公路瀝青路面設(shè)計(jì)計(jì)算書(shū)(Word)
- 加油機(jī)拆卸安裝方案
- 國(guó)畫(huà)美術(shù)興趣小組活動(dòng)記錄(共9頁(yè))
- 馬清河灌區(qū)灌溉系統(tǒng)的規(guī)劃設(shè)計(jì)課程設(shè)計(jì)
- 環(huán)境隱患排查治理檔案臺(tái)賬
評(píng)論
0/150
提交評(píng)論