Wednesday, 10 June 2015

Android Battery Drain analysis via Qpython

Hello Everybody !

Hope my previous scripts helped you guys in understanding Monkey Runner Advanced Concepts !

Script description :

The below script helps to make a track on android device battery draining and charging
After every 10 degree change in battery level android device will speak and tell you what the current level

import time
import androidhelper
droid = androidhelper.Android()
droid.batteryStartMonitoring()
new = ''
neww = ''
print 'script start'
while True :
    batteryLevel = droid.batteryGetLevel()
    new = new + str(batteryLevel[1])
    time.sleep(2)
    NewLevel = droid.batteryGetLevel()
    neww = neww + str(NewLevel[1])
    if new == neww:
       continue
    else:
        print NewLevel[1],time.asctime()
        new = neww
        if NewLevel[1] % 10 == 0:
            print 'Speaking starts'
            droid.ttsSpeak('hi dheeraj.Your phone battery is' + str(NewLevel[1]))


No comments:

Post a Comment