Skip to content

Commit

Permalink
Add adb.uptime and adb.boot_time
Browse files Browse the repository at this point in the history
  • Loading branch information
zachriggle committed Nov 8, 2016
1 parent 483adb8 commit fa402ce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pwnlib/adb/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ def reboot_bootloader():
with Client() as c:
c.reboot_bootloader()

@with_device
def uptime():
"""boot_time() -> float
Returns:
Uptime of the device, in seconds
"""
up, idle = map(float, read('/proc/uptime').split())
return up

@with_device
def boot_time():
"""boot_time() -> int
Returns:
Boot time of the device, in Unix time, rounded to the
nearest second.
"""
for line in read('/proc/stat').splitlines():
name, value = line.split(None, 1)
if name == 'btime':
return int(value)

class AdbDevice(Device):
"""Encapsulates information about a connected device."""
def __init__(self, serial, type, port=None, product='unknown', model='unknown', device='unknown', features=None, **kw):
Expand Down

0 comments on commit fa402ce

Please sign in to comment.