3

I want to measure the current consumption of my device while running different test cases. (Have a tool to measure current consumption).

I have automated the test cases using UIAutomator. But for running the script I have to connect the device via USB or WiFi. In both cases current consumption of the device gets higher.

Is there any method by which I can stop the current coming from USB and run the script?

I have tried:

adb shell dumpsys battery set usb 0

This stops the charging through USB but the current reading is still more, because I think device is still getting the current it only stops the battery charging.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • I'd be interested to know if that's even possible. Can you not just take the "plugged in consumption" as a baseline and measure differences to that? – HomerPlata Feb 22 '17 at 09:28
  • What tool do you use to measure power consumption? The impact of adb over Wifi should be minimal anyway. – Sébastien Feb 22 '17 at 09:31
  • 1
    Well the difference is not fixed always. It depends on USB cable also. – Himanshu Rautela Feb 22 '17 at 09:32
  • 1
    I use Monsoon Power Monitor tool. It's a tool provided by Monsoon. I have automated the tool. But i have to run the test cases manually. I want to automate them also. – Himanshu Rautela Feb 22 '17 at 09:35
  • If you just want to use adb without cable, there is remote adb using socket. http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp – Shu Zhang Feb 22 '17 at 09:36
  • @ShuZhang Thanks for your reply. But i don't want to run the scripts using wifi connection. For this method i have to keep wifi on always. It will also consume some current. – Himanshu Rautela Feb 22 '17 at 11:00
  • The current consumption is going to be more if you're using USB or WiFi vs. not using them. Phones actively power off unused functionality, and/or stop the clock signal. Even if they don't do that, in CMOS chips, the vast majority of power is used in actually switching state. Thus, you *will* use more power by using additional functionality regardless if that power is sourced from the USB interface or the battery. For WiFi, there's additional power that's used to actually transmit that's in addition to any that's used for the logic that drives the transmit and receive sides of the interface. – Makyen Nov 20 '18 at 17:43

2 Answers2

0

Connect with ADB over wifi. Start a test case that doesn't do anything and measure current increase (consider doing this multiple times). That's your baseline. When you run the real test, however much the current increases above that is due to the test.

nasch
  • 5,330
  • 6
  • 31
  • 52
  • 1
    Thanks for your reply. But when we will run ADB commands using wifi, the current increase will not be same always. It will depend on WiFi signal strength. And after some time our phone will keep searching for nearby APs (routers) that will also increase the current consumption of phone. – Himanshu Rautela Feb 23 '17 at 05:10
  • 1
    I guess you could do the same over usb then. Set it to not charge like you described and measure a baseline? – nasch Feb 23 '17 at 05:13
  • 1
    hmm.. this is a good suggestion.. will try this.. but don't you think the readings may vary with different USB cables, different USB ports etc. But will still try doing this. By the way is there any solution on Hardware side, i mean can't i cut some wire or something in USB cable to stop the current coming from it ?? – Himanshu Rautela Feb 23 '17 at 07:58
  • Sure it will probably vary, so keep everything the same every time, and run everything many times and average it. I have no idea if there's a hardware solution. – nasch Feb 23 '17 at 15:52
0

My problem is solved. I used:

adb shell
uiautomator runtest projectname.jar -c pkg.cls &

Because of &, the script keeps running even when I disconnect the USB cable

TylerH
  • 20,799
  • 66
  • 75
  • 101