1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
30 def install (extraArgs = [], printPrefix=""):
31 print printPrefix + "Removing old dEQP Package...\n",
32 common.execArgsInDirectory([common.ADB_BIN] + extraArgs + [
34 'com.drawelements.deqp'
35 ], common.ANDROID_DIR, printPrefix)
36 print printPrefix + "Remove complete\n",
38 print printPrefix + "Installing dEQP Package...\n",
39 common.execArgsInDirectory([common.ADB_BIN] + extraArgs + [
42 'package/bin/dEQP-debug.apk'
43 ], common.ANDROID_DIR, printPrefix)
44 print printPrefix + "Install complete\n",
46 def installToDevice (device, printPrefix=""):
47 if len(printPrefix) == 0:
48 print "Installing to %s (%s)...\n" % (device.serial, device.model),
50 print printPrefix + "Installing to %s\n" % device.serial,
52 install(['-s', device.serial], printPrefix)
54 def installToAllDevices (doParallel):
55 devices = common.getDevices(common.ADB_BIN)
56 padLen = max([len(device.model) for device in devices])+1
58 common.parallelApply(installToDevice, [(device, ("(%s):%s" % (device.model, ' ' * (padLen - len(device.model))))) for device in devices]);
60 common.serialApply(installToDevice, [(device, ) for device in devices]);
62 if __name__ == "__main__":
64 if sys.argv[1] == '-a':
65 doParallel = '-p' in sys.argv[1:]
66 installToAllDevices(doParallel)
70 devices = common.getDevices(common.ADB_BIN)
72 common.die('No devices connected')
73 elif len(devices) == 1:
74 installToDevice(devices[0])
76 print "More than one device connected:"
77 for i in range(0, len(devices)):
78 print "%3d: %16s %s" % ((i+1), devices[i].serial, devices[i].model)
80 deviceNdx = int(raw_input("Choose device (1-%d): " % len(devices)))
81 installToDevice(devices[deviceNdx-1])