One of the big concern with the WiFi Direct API usage is that you might get your battery drained really fast. Have not seen any data on this, thus to figure out how big the problem is, we need to do some testing with it.
Also somebody suggested that Peer discovery would be consuming less power than doing full Service discovery, so we needed to check that out as well.
With the tests I was using my WifiPowerTest application, and with different tests I was simply commenting parts that were not needed out. Also some additional tests will be carries out using the same app, thus it likely will be modified to suit more testing in the future.
With first tests I was doing “normal” discovery, i.e. first doing peer discovery, and once I get Peers changed event, the logic would kick the service discovery on. Then there is timer to collect services discovered, thus each Services got event actually can have 1 to many services discovered.
First lets see how out Peers discovered, and Service discovery start events look for the test:
The main issue here to see is that Lollipop devices appears to be discovering both peers as well as services a lot less than the Kitkat counterparts. And as we can see from the next image, this corresponds directly to the services discovered.
From the image we can also see that,the less discovered peers & servies, also appears to mean less battery usage. Then lets look into the actual battery consumption be the test devices
The left part of the image shows the timings when the battery level went under the percentage value. The read values with gray background are estimates, since the test only lasted a bit less than 24 hours.
The right side of the image then shows how many hours it took to drop each 10% of the battery status. And to take out any chance than the devices were not actually 100% charged in the beginning, the values are calculated only from the 90% charge.
For the Nexus 4 device we would need to do longer tests to get more accurate values, but if we get general estimate from the values gotten we could say:
- With Nexus 5 device using 5.01 Lollipop we expect that doing full service discovery, the battery would drop 10% for each 5.2 hours of discovery.
- With Nexus 5 using 4.4.X Kitkat we expect that doing full service discovery, the battery would drop 10% for each 2.5 hours of discovery.
And then lets see how the situation changes, if we would only do Peer discovery, and not start any service discoveries. Following image shows the Peer discovery data on top, and the data from the test done previously with Peers & service discovery in the bottom:
So we did expect to get less battery drainage, but instead we got the battery drained faster. And as we can see from the image, we also get more Peers changed events, thus it appears that doing service discovery will slow the Peer discovery down a bit, as well as it will make the discovery to consume less power.
And here’s the timings for the Peer only discovery:
So we would see that now the 10% battery drop with Kitkat takes only 2.2 hours, but more interestingly, the Lollipop power savings we saw earlier are now gone, and the battery is drained with same speed also when using Lollipop.
The values shown here are estimates, the accuracy is really a question-mark, due the estimations used with Lollipop. Thus longer testing time will be needed for next test, but before we get better values, I will be researching for ways to reduce the power consumption on the discovery stage.