Add feature to deploy sibon devices
Devices running Fairphone Open need a differently signed proxy apk.
Change-Id: I73cc5fc698b3b39e8122ca721edfa2af1699443b
diff --git a/deploy.py b/deploy.py
index 0db59e0..7a8b5d9 100755
--- a/deploy.py
+++ b/deploy.py
@@ -10,9 +10,13 @@
PREBUILTS_PATH = '../../vendor/smartviser/viser/prebuilts/apk'
+PREBUILT_PROXY_APKS = {
+ 'gms': 'com.lunarlabs.panda.proxy.apk',
+ 'sibon': 'com.lunarlabs.panda.proxy-sibon.apk',
+}
+
PREBUILT_APKS = [
'com.smartviser.demogame.apk',
- 'com.lunarlabs.panda.proxy.apk',
'com.lunarlabs.panda.apk',
]
@@ -67,6 +71,39 @@
universal_newlines=True)
+def getprop(serial, key):
+ """Get system property of device.
+
+ Example:
+ >>> getprop('167eb6e8', 'ro.build.id')
+ 'FP2-gms-18.02.0'
+
+ :param str serial:
+ Identifier for ADB connection to device.
+ :param str key:
+ Key of property to get.
+ :returns str:
+ Value of system property.
+ """
+ process = adb('shell', 'getprop', key, serial=serial)
+ return process.stdout.strip()
+
+
+def is_gms_device(serial):
+ """Test if device runs GMS or sibon.
+
+ Example:
+ >>> is_gms_device('167eb6e8')
+ True
+
+ :param str serial:
+ Identifier for ADB connection to device.
+ :returns bool:
+ True if device runs GMS, false otherwise.
+ """
+ return getprop(serial, 'ro.build.id').startswith('FP2-gms-')
+
+
def uninstall_apk(serial, filename, prebuilts_dir):
"""Uninstall apk from prebuilts_dir on device."""
ret = aapt('dump', 'badging', '{}/{}'.format(prebuilts_dir, filename))
@@ -110,8 +147,10 @@
# Prepare the DUT
def prepare_dut(serial, scenarios_dir, data_dir, prebuilts_dir):
+ flavour = 'gms' if is_gms_device(serial) else 'sibon'
+
# Uninstall the smartviser apps
- for app in PREBUILT_APKS:
+ for app in PREBUILT_APKS + [PREBUILT_PROXY_APKS[flavour]]:
uninstall_apk(serial, app, prebuilts_dir)
# Copy the scenarios
@@ -130,8 +169,8 @@
else:
print('Scenarios data pushed.')
- # Install the smartviser apps
- for app in PREBUILT_APKS:
+ # Install the smartviser apps (starting with the proxy app)
+ for app in [PREBUILT_PROXY_APKS[flavour]] + PREBUILT_APKS:
install_apk(serial, app, prebuilts_dir)