阅读从USB电源输入

阅读从USB电源输入

本文介绍了阅读从USB电源输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法读取从Android的USB连接?

Is there any way to read the power input from a USB connection in Android?

例如插上Micro USB数据线插入手机,无论是从电脑USB输出,一个电源充电器,或者类似的东西和读取的电压和放大器的输出?

For example plug in a micro usb lead into the phone from either a computer USB output, a mains charger, or something similar and read the voltage and amp output?

我不知道从哪里开始寻找这些信息,以及搜索我只能找到电池部件,或功耗的应用程序的时候 - 这是不是我要找的,我希望能读多少电正在经由所连接的USB接口发送。

I have no idea where to start looking for this information, and when searching I can only find battery widgets, or power consumption apps - this is not what I'm looking for, I want to be able to read how much power is being sent via the USB interface that is connected.

非常感谢。

推荐答案

也许,你应该开始的,参阅这个问题的一些用法示例。我相信BatteryManager提供的数据应该足以提供你想要什么(多大的权力是通过USB发送)近似计算。具有设备默认的电池容量和/或用户输入有关的能力和%的差异与时间间隔和电压可能是设备ID和表会给消费的近似计算

Probably, You should start with BatteryManager , refer to this question for some examples of usage. I believe the data provided by BatteryManager should be enough to provide approximate calculation of what You want to (how much power is being sent via the USB). Having device id and table of devices default batteries capacities or/and users input about capacity and % difference with time interval and voltage probably would give enough info for approximate calculation of consumption

另一个(脏)的方法可能是以下 - 挖的Andr​​oid源,如果那些有关于总容量/消费可以得到如任何信息用Java反射。我觉得<一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.1.1_r1/android/os/BatteryManager.java/"相对=nofollow> BatteryManager 和<一href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.1.1_r1/com/android/internal/os/BatteryStatsImpl.java#BatteryStatsImpl"相对=nofollow> BatteryStatsImpl 可能是合适的地方,从开始分析。

Another (dirty) way might be the following - dig android sources if ones have any info about total capacity / consumption You can obtain e.g. with java reflection. I think BatteryManager and BatteryStatsImpl could be appropriate places to start analysis from.

这篇关于阅读从USB电源输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:01