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)
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)
44 print printPrefix + "Install complete\n",
46 def installToDevice (device, printPrefix=""):
47 print printPrefix + "Installing to %s (%s)...\n" % (device.serial, device.model),
48 install(['-s', device.serial], printPrefix)
50 def installToAllDevices (doParallel):
51 devices = common.getDevices(common.ADB_BIN)
52 padLen = max([len(device.model) for device in devices])+1
54 common.parallelApply(installToDevice, [(device, ("(%s):%s" % (device.model, ' ' * (padLen - len(device.model))))) for device in devices]);
56 common.serialApply(installToDevice, [(device, ) for device in devices]);
58 if __name__ == "__main__":
60 if sys.argv[1] == '-a':
61 doParallel = '-p' in sys.argv[1:]
62 installToAllDevices(doParallel)
66 devices = common.getDevices(common.ADB_BIN)
68 common.die('No devices connected')
69 elif len(devices) == 1:
70 installToDevice(devices[0])
72 print "More than one device connected:"
73 for i in range(0, len(devices)):
74 print "%3d: %16s %s" % ((i+1), devices[i].serial, devices[i].model)
76 deviceNdx = int(raw_input("Choose device (1-%d): " % len(devices)))
77 installToDevice(devices[deviceNdx-1])