blob: b303edad9a578818fe4cac80305228629a0005c5 [file] [log] [blame]
Ben Murdoch342c50c2016-05-18 11:27:45 +01001#!/usr/bin/env python
2#
3# Copyright (c) 2012 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.
6
7"""Enables dalvik vm asserts in the android device."""
8
9import argparse
10import sys
11
12import devil_chromium
13from devil.android import device_blacklist
14from devil.android import device_utils
15
16
17def main():
18 parser = argparse.ArgumentParser()
19
20 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
21
22 set_asserts_group = parser.add_mutually_exclusive_group(required=True)
23 set_asserts_group.add_argument(
24 '--enable_asserts', dest='set_asserts', action='store_true',
25 help='Sets the dalvik.vm.enableassertions property to "all"')
26 set_asserts_group.add_argument(
27 '--disable_asserts', dest='set_asserts', action='store_false',
28 help='Removes the dalvik.vm.enableassertions property')
29
30 args = parser.parse_args()
31
32 devil_chromium.Initialize()
33
34 blacklist = (device_blacklist.Blacklist(args.blacklist_file)
35 if args.blacklist_file
36 else None)
37
38 # TODO(jbudorick): Accept optional serial number and run only for the
39 # specified device when present.
40 devices = device_utils.DeviceUtils.parallel(
41 device_utils.DeviceUtils.HealthyDevices(blacklist))
42
43 def set_java_asserts_and_restart(device):
44 if device.SetJavaAsserts(args.set_asserts):
45 device.RunShellCommand('stop')
46 device.RunShellCommand('start')
47
48 devices.pMap(set_java_asserts_and_restart)
49 return 0
50
51
52if __name__ == '__main__':
53 sys.exit(main())