2012-07-09 13:11:57 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Enables dalvik vm asserts in the android device."""
|
|
|
|
|
2015-04-15 21:24:51 +03:00
|
|
|
from pylib import android_commands
|
2015-04-15 19:11:51 +03:00
|
|
|
from pylib.device import device_utils
|
2015-04-15 21:24:51 +03:00
|
|
|
import optparse
|
|
|
|
import sys
|
2015-04-15 19:11:51 +03:00
|
|
|
|
|
|
|
|
2015-04-15 21:24:51 +03:00
|
|
|
def main(argv):
|
|
|
|
option_parser = optparse.OptionParser()
|
|
|
|
option_parser.add_option('--enable_asserts', dest='set_asserts',
|
|
|
|
action='store_true', default=None,
|
2012-07-09 13:11:57 +04:00
|
|
|
help='Sets the dalvik.vm.enableassertions property to "all"')
|
2015-04-15 21:24:51 +03:00
|
|
|
option_parser.add_option('--disable_asserts', dest='set_asserts',
|
|
|
|
action='store_false', default=None,
|
2012-07-09 13:11:57 +04:00
|
|
|
help='Removes the dalvik.vm.enableassertions property')
|
2015-04-15 21:24:51 +03:00
|
|
|
options, _ = option_parser.parse_args(argv)
|
2012-07-09 13:11:57 +04:00
|
|
|
|
2014-04-24 03:28:00 +04:00
|
|
|
# TODO(jbudorick): Accept optional serial number and run only for the
|
|
|
|
# specified device when present.
|
2015-04-15 21:24:51 +03:00
|
|
|
devices = android_commands.GetAttachedDevices()
|
|
|
|
for device in [device_utils.DeviceUtils(serial) for serial in devices]:
|
|
|
|
if options.set_asserts != None:
|
|
|
|
if device.SetJavaAsserts(options.set_asserts):
|
|
|
|
# TODO(jbudorick) How to best do shell restarts after the
|
|
|
|
# android_commands refactor?
|
|
|
|
device.RunShellCommand('stop')
|
|
|
|
device.RunShellCommand('start')
|
2012-07-09 13:11:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-04-15 21:24:51 +03:00
|
|
|
main(sys.argv)
|