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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 10693110: [android] Split top-level scripts and libraries from build/android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added __init__.py and enable_asserts.py. Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. 6 """Provides an interface to communicate with the device via the adb command.
7 7
8 Assumes adb binary is currently on system path. 8 Assumes adb binary is currently on system path.
9 9
10 Usage: 10 Usage:
11 python android_commands.py wait-for-pm 11 python android_commands.py wait-for-pm
12 """ 12 """
13 13
14 import collections 14 import collections
15 import datetime 15 import datetime
16 import logging 16 import logging
17 import optparse 17 import optparse
18 import os 18 import os
19 import pexpect 19 import pexpect
20 import re 20 import re
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 import tempfile 23 import tempfile
24 import time 24 import time
25 25
26 # adb_interface.py is under ../../third_party/android_testrunner/ 26 # adb_interface.py is under ../../../third_party/android_testrunner/
27 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 27 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..',
28 '..', 'third_party', 'android_testrunner')) 28 '..', '..', 'third_party', 'android_testrunner'))
29 import adb_interface 29 import adb_interface
30 import cmd_helper 30 import cmd_helper
31 import errors # is under ../../third_party/android_testrunner/errors.py 31 import errors # is under ../../third_party/android_testrunner/errors.py
32 from run_tests_helper import IsRunningAsBuildbot 32 from run_tests_helper import IsRunningAsBuildbot
33 33
34 34
35 # Pattern to search for the next whole line of pexpect output and capture it 35 # Pattern to search for the next whole line of pexpect output and capture it
36 # into a match group. We can't use ^ and $ for line start end with pexpect, 36 # into a match group. We can't use ^ and $ for line start end with pexpect,
37 # see http://www.noah.org/python/pexpect/#doc for explanation why. 37 # see http://www.noah.org/python/pexpect/#doc for explanation why.
38 PEXPECT_LINE_RE = re.compile('\n([^\r]*)\r') 38 PEXPECT_LINE_RE = re.compile('\n([^\r]*)\r')
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 def UnlockDevice(self): 748 def UnlockDevice(self):
749 """Unlocks the screen of the device.""" 749 """Unlocks the screen of the device."""
750 # Make sure a menu button event will actually unlock the screen. 750 # Make sure a menu button event will actually unlock the screen.
751 if IsRunningAsBuildbot(): 751 if IsRunningAsBuildbot():
752 assert self.RunShellCommand('getprop ro.test_harness')[0].strip() == '1' 752 assert self.RunShellCommand('getprop ro.test_harness')[0].strip() == '1'
753 # The following keyevent unlocks the screen if locked. 753 # The following keyevent unlocks the screen if locked.
754 self.SendKeyEvent(KEYCODE_MENU) 754 self.SendKeyEvent(KEYCODE_MENU)
755 # If the screen wasn't locked the previous command will bring up the menu, 755 # If the screen wasn't locked the previous command will bring up the menu,
756 # which this will dismiss. Otherwise this shouldn't change anything. 756 # which this will dismiss. Otherwise this shouldn't change anything.
757 self.SendKeyEvent(KEYCODE_BACK) 757 self.SendKeyEvent(KEYCODE_BACK)
758
759
760 def main(argv):
761 option_parser = optparse.OptionParser()
762 option_parser.add_option('-w', '--wait_for_pm', action='store_true',
763 default=False, dest='wait_for_pm',
764 help='Waits for Device Package Manager to become available')
765 option_parser.add_option('--enable_asserts', dest='set_asserts',
766 action='store_true', default=None,
767 help='Sets the dalvik.vm.enableassertions property to "all"')
768 option_parser.add_option('--disable_asserts', dest='set_asserts',
769 action='store_false', default=None,
770 help='Removes the dalvik.vm.enableassertions property')
771 options, args = option_parser.parse_args(argv)
772
773 commands = AndroidCommands(wait_for_pm=options.wait_for_pm)
774 if options.set_asserts != None:
775 if commands.SetJavaAssertsEnabled(options.set_asserts):
776 commands.Reboot(full_reboot=False)
777
778
779 if __name__ == '__main__':
780 main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698