How to check battery consumption caused by Bluetooth Scans

岁酱吖の 提交于 2019-12-14 03:03:38

问题


I have an Android application to detect Eddystone beacons using the Android Beacon Library. I would like to test the battery consumption caused by the application to find the optimal background and foreground scan rates. In Settings > Apps > MyBeaconDetectorApp, it shows 0% battery usage after having the bluetooth On for more than an hour. I think the application is in background and hence it is 0%. However, how do I check the battery consumption caused by Bluetooth scans. I have set my BackgroundBetweenScanPeriod as 1 minute.

Thanks


回答1:


While it is difficult to measure the battery consumption directly, here is the technique I use:

  1. Use a test device with a limited number of apps installed that will be running in the background. A stock Nexus device after factory reset is ideal.

  2. Charge the battery to 100%

  3. Put the device into airplane mode and put bluetooth on.

  4. Install your app start it running in the background. Turn off the screen, and disconnect the device's USB connector.

  5. Note the start time.

  6. Let the app run in the background for at least 8 hours, ideally in the presence of at least one beacon.

  7. Measure the battery level. The delta from 100% is the percentage drain. Note this number and the end time.

  8. Look up how many mAH your battery has for your phone model. Multiply the percentage drain by the mAH and divide by the time of the test in hours. This tells you how many mA the phone uses when running your app.

Next, uninstall your app, and repeat the procedure above. This will give you a baseline battery drain for your device without your app running.

Finally, subtract the mAH baseline from the mAH with your app running to measure the additional mAH used by your app.

One final note: if you are really scanning every minute in the background (the default is every five minutes to save battery), I would expect this may cause a significant additional battery drain. Testing using the procedure above will tell you for sure. I'd love to hear your results!



来源:https://stackoverflow.com/questions/38753978/how-to-check-battery-consumption-caused-by-bluetooth-scans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!