Add Apps.AppListSearchQueryLength UMA histogram.
[chromium-blink-merge.git] / build / android / gyp / get_device_configuration.py
blob390eb2ffcb855817a8a8fe91a40f4f22f31a1c4f
1 #!/usr/bin/env python
3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 """Gets and writes the configurations of the attached devices.
9 This configuration is used by later build steps to determine which devices to
10 install to and what needs to be installed to those devices.
11 """
13 import optparse
14 import sys
16 from util import build_utils
17 from util import build_device
20 def main(argv):
21 parser = optparse.OptionParser()
22 parser.add_option('--stamp', action='store')
23 parser.add_option('--output', action='store')
24 options, _ = parser.parse_args(argv)
26 devices = build_device.GetAttachedDevices()
28 device_configurations = []
29 for d in devices:
30 configuration, is_online, has_root = (
31 build_device.GetConfigurationForDevice(d))
33 if not is_online:
34 build_utils.PrintBigWarning(
35 '%s is not online. Skipping managed install for this device. '
36 'Try rebooting the device to fix this warning.' % d)
37 continue
39 if not has_root:
40 build_utils.PrintBigWarning(
41 '"adb root" failed on device: %s\n'
42 'Skipping managed install for this device.'
43 % configuration['description'])
44 continue
46 device_configurations.append(configuration)
48 if len(device_configurations) == 0:
49 build_utils.PrintBigWarning(
50 'No valid devices attached. Skipping managed install steps.')
51 elif len(devices) > 1:
52 # Note that this checks len(devices) and not len(device_configurations).
53 # This way, any time there are multiple devices attached it is
54 # explicitly stated which device we will install things to even if all but
55 # one device were rejected for other reasons (e.g. two devices attached,
56 # one w/o root).
57 build_utils.PrintBigWarning(
58 'Multiple devices attached. '
59 'Installing to the preferred device: '
60 '%(id)s (%(description)s)' % (device_configurations[0]))
63 build_device.WriteConfigurations(device_configurations, options.output)
66 if __name__ == '__main__':
67 sys.exit(main(sys.argv))