在Linux3.0+Android4.0上面开发了电池驱动,启动Android后,在Settings里面的Battery选项上可以监测到电池充电放电及剩余电量等信息,但是界面上总是显示"无法获取电池使用数据"。我看了一下Battery相关的信息,Android实际上都是从/sys/class/power_supply/battery/下读取到的,可以看到如下信息:
capacity
current_now
device
health
power
present
status
subsystem
technology
temp
type
uevent
voltage_now在Android上层的Java中PowerUsageSummary.java中判断并打印了"无法获取电池使用数据",如下:
if (mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL) < 10) {
addNotAvailableMessage();
return;
}跟踪代码到PowerProfile.java中,找到了关于PowerProfile的定义如下:
public static final String POWER_SCREEN_FULL = "screen.full";但是不太清楚这个到底是什么意思?请问是否是Linux Battery底层驱动中还需要支持什么信息的读取?还是上层什么地方需要配置?请帮忙指点一下,谢谢!
capacity
current_now
device
health
power
present
status
subsystem
technology
temp
type
uevent
voltage_now在Android上层的Java中PowerUsageSummary.java中判断并打印了"无法获取电池使用数据",如下:
if (mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL) < 10) {
addNotAvailableMessage();
return;
}跟踪代码到PowerProfile.java中,找到了关于PowerProfile的定义如下:
public static final String POWER_SCREEN_FULL = "screen.full";但是不太清楚这个到底是什么意思?请问是否是Linux Battery底层驱动中还需要支持什么信息的读取?还是上层什么地方需要配置?请帮忙指点一下,谢谢!
解决方案 »
- Android界面 求一种控件!! 着急。。。。急
- 请问一下 如何设置一个VIEW的高度
- 关于ping 和消息回现
- android 1.6 如何自适应屏幕大小!!
- 新手关于两个简单问题的求教 谢谢回答~~~~~
- 社交app通信数据格式的选择:xml(json) or binary?
- svg中图形元素的点击事件,求教!!!!!!!
- 安卓怎么嵌入swf
- 在android编程的学习中,遇到一点关于Socket编程上的问题
- 求一个GridView(网格线)
- 请问执行createBindMounts()函数时用到的/mnt/secure/staging/android_secure目录是何时创建的?
- viewport 没有作用
if (sPowerMap.containsKey(type)) {
Object data = sPowerMap.get(type);
if (data instanceof Double[]) {
return ((Double[])data)[0];
} else {
return (Double) sPowerMap.get(type);
}
} else {
return 0;
}
}
也许是读的这个key:POWER_SCREEN_FULL 没有value。那sPowerMap打印出来看看都有什么key
if (sPowerMap.containsKey(type)) {
Object data = sPowerMap.get(type);
if (data instanceof Double[]) {
return ((Double[])data)[0];
} else {
return (Double) sPowerMap.get(type);
}
} else {
return 0;
}
}
在frameworks/base/core/res/res/xml/power_profile.xml
中有<item name="screen.full">0.1</item>
所以,在mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL)返回的应该是0.1,<10直接返回了,就显示了“无法获取电池使用数据”的情况了。不过,配置中的值,具体是什么涵义,应该如何修改,还不清楚。楼主搞懂了,也回复结贴呀。
/* if (mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL) < 10) {
addNotAvailableMessage();
return;
}*/ // if (!com.android.settings.Utils.isWifiOnly(getActivity())) {
addRadioUsage(uSecNow);
// }
设置应用的:PowerUsageSummary.java文件,会判断:if (mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL) < 10)即亮屏时的功耗。这边主要通过:power_profile.xml 进行配置,默认配置是一个很小的值,如0.1mA(这个值当然不对),而实际配置正常后,如屏亮度为:300mA,此功能即可正常。更详细的内容,请查看:power_profile.xml 的注释说明。