Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/android/mempressure.py

Issue 420273006: [Android] Fix DeviceUtils.__str__ when no serial is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import collections 6 import collections
7 import logging 7 import logging
8 import optparse 8 import optparse
9 import os 9 import os
10 import sys 10 import sys
11 11
12 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), 12 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__),
13 os.pardir, 13 os.pardir,
14 os.pardir, 14 os.pardir,
15 'build', 15 'build',
16 'android') 16 'android')
17 sys.path.append(BUILD_ANDROID_DIR) 17 sys.path.append(BUILD_ANDROID_DIR)
18 from pylib import android_commands
18 from pylib import constants 19 from pylib import constants
19 from pylib import flag_changer 20 from pylib import flag_changer
20 from pylib.device import device_utils 21 from pylib.device import device_utils
21 22
22 # Browser Constants 23 # Browser Constants
23 DEFAULT_BROWSER = 'chrome' 24 DEFAULT_BROWSER = 'chrome'
24 25
25 # Action Constants 26 # Action Constants
26 ACTION_PACKAGE = 'org.chromium.base' 27 ACTION_PACKAGE = 'org.chromium.base'
27 ACTION_TRIM = { 28 ACTION_TRIM = {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 sys.exit(1) 79 sys.exit(1)
79 80
80 if not options.browser in constants.PACKAGE_INFO.keys(): 81 if not options.browser in constants.PACKAGE_INFO.keys():
81 option_parser.error('Unknown browser option ' + options.browser) 82 option_parser.error('Unknown browser option ' + options.browser)
82 83
83 package_info = constants.PACKAGE_INFO[options.browser] 84 package_info = constants.PACKAGE_INFO[options.browser]
84 85
85 package = package_info.package 86 package = package_info.package
86 activity = package_info.activity 87 activity = package_info.activity
87 88
88 device = device_utils.DeviceUtils(None) 89 devices = android_commands.GetAttachedDevices()
90 if not len(devices):
frankf 2014/07/28 22:52:31 if not devices:
jbudorick 2014/07/28 23:05:40 Done.
91 logging.error('No devices attached.')
92 sys.exit(1)
93 elif len(devices) > 1:
94 logging.warning('Multiple devices attached. Using %s.' % devices[0])
95 device = device_utils.DeviceUtils(devices[0])
89 96
90 try: 97 try:
91 device.EnableRoot() 98 device.EnableRoot()
92 except device_errors.CommandFailedError as e: 99 except device_errors.CommandFailedError as e:
93 # Try to change the flags and start the activity anyway. 100 # Try to change the flags and start the activity anyway.
94 # TODO(jbudorick) Handle this exception appropriately after interface 101 # TODO(jbudorick) Handle this exception appropriately after interface
95 # conversions are finished. 102 # conversions are finished.
96 logging.error(str(e)) 103 logging.error(str(e))
97 flags = flag_changer.FlagChanger(device, package_info.cmdline_file) 104 flags = flag_changer.FlagChanger(device, package_info.cmdline_file)
98 if ENABLE_TEST_INTENTS_FLAG not in flags.Get(): 105 if ENABLE_TEST_INTENTS_FLAG not in flags.Get():
99 flags.AddFlags([ENABLE_TEST_INTENTS_FLAG]) 106 flags.AddFlags([ENABLE_TEST_INTENTS_FLAG])
100 107
101 device.StartActivity(intent.Intent(package=package, activity=activity, 108 device.StartActivity(intent.Intent(package=package, activity=activity,
102 action=action)) 109 action=action))
103 110
104 if __name__ == '__main__': 111 if __name__ == '__main__':
105 sys.exit(main(sys.argv)) 112 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698