Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 'adb get-serialno' to obtain serial number in case there's only

one device.

- Fixed error message
- Check existence of qemu property
  • Loading branch information...
commit 4267a3e42fd72f2af1731d732c8aa97a7920abc0 1 parent 45aa68e
@dtmilano authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 AndroidViewClient/src/com/dtmilano/android/viewclient.py
View
11 AndroidViewClient/src/com/dtmilano/android/viewclient.py
@@ -874,7 +874,7 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
if adb:
if not os.access(adb, os.X_OK):
- raise Exception('adb="%s" is not executable')
+ raise Exception('adb="%s" is not executable' % adb)
else:
adb = ViewClient.__obtainAdbPath()
@@ -1018,11 +1018,18 @@ def __obtainDeviceSerialNumber(device):
if not serialno:
serialno = device.shell('getprop ro.serialno')[:-2]
if not serialno:
- if int(device.shell('getprop ro.kernel.qemu')[:-2]) == 1:
+ qemu = device.shell('getprop ro.kernel.qemu')[:-2]
+ if qemu and int(qemu) == 1:
# FIXME !!!!!
# this must be calculated from somewhere, though using a fixed serialno for now
warnings.warn("Running on emulator but no serial number was specified then 'emulator-5554' is used")
serialno = 'emulator-5554'
+ if not serialno:
+ # If there's only one device connected get its serialno
+ adb = ViewClient.__obtainAdbPath()
+ s = subprocess.Popen([adb, 'get-serialno'], stdout=subprocess.PIPE).communicate()[0][:-1]
+ if s != 'unknown':
+ serialno = s
return serialno
@staticmethod
Please sign in to comment.
Something went wrong with that request. Please try again.