我如何能找出多少电池我的Andr​​oid应用程序消耗用户的设备?我的、应用程序、消耗、电池

2023-09-07 08:45:31 作者:素手浣椛⌒

我在写一个应用程序,以评估对Android的蓝牙P2P网络的可行性。

I am writing an app to evaluate the feasibility of a Bluetooth P2P network on Android.

我注意到,在Galaxy Nexus的,它使用非常小的电池,而在一台Nexus S,它消耗电池电量,速度非常快。这是直接由于蓝牙引起的高CPU负载。

I noticed that on a Galaxy Nexus, it uses very little battery, while on a Nexus S, it drains the battery very quickly. This is directly caused by high CPU load due to Bluetooth.

现在,我想收集多少电池耗尽我的应用程序上的原因是所安装的设备的信息。只需登录时间与电池电量是无用的,因为我不知道什么时候该设备正在使用中,即使我登录,我不知道如果用户玩3D游戏,同时Torrenting通过WiFi或在阅读电子书黯淡的画面。

Now, I would like to collect information about how much battery drain my app causes on the devices it is installed upon. Simply logging time vs. battery level is useless since I don't know when the device is in use, and even if I logged that, I would not know if the user is playing 3D games while Torrenting over WiFi or reading an eBook on a dimmed screen.

为使问题变得更糟,没有引起我的应用程序的所有电池的使用,是因为它在电池屏幕 - 一些被列为蓝牙,比如(再次提示,依赖于设备的)

To make the problem worse, not all battery usage caused by my app is attributed to it in the battery screen - some is listed as "Bluetooth", for example (again, device-dependent).

有没有简单的,与隐私preserving的方式来获得在非root权限的设备有用的信息?的设备不归我管。我不能简单地去看看菜单,我不能用ADB。

Is there any easy, privacy-preserving way to get useful information on non-rooted devices? The devices are not under my control. I cannot simply go look in the menu, I cannot use ADB.

推荐答案

Android的API不支持此当前。唯一可用文档是一个描述如何使用 BatteryManager 的广播,只提供整体的电池电量和无每-application细节。

The Android API doesn't support this currently. The only available documentation is the one describing how to use BatteryManager's broadcasts, which only supply the overall battery level and no per-application details.

我想,即使有无证的方法来模拟一下系统设置电池管理器显示,它们需要生根。

I suppose that even if there are undocumented ways to emulate what the System Settings battery manager shows, they would require rooting.