OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 """Brings in Chrome Android's android_commands module, which itself is a | 4 """Brings in Chrome Android's android_commands module, which itself is a |
5 thin(ish) wrapper around adb.""" | 5 thin(ish) wrapper around adb.""" |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 # This is currently a thin wrapper around Chrome Android's | 9 # This is currently a thin wrapper around Chrome Android's |
10 # build scripts, located in chrome/build/android. This file exists mainly to | 10 # build scripts, located in chrome/build/android. This file exists mainly to |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 112 |
113 def Pull(self, remote, local): | 113 def Pull(self, remote, local): |
114 return self._adb.Adb().Pull(remote, local) | 114 return self._adb.Adb().Pull(remote, local) |
115 | 115 |
116 def FileExistsOnDevice(self, file_name): | 116 def FileExistsOnDevice(self, file_name): |
117 return self._adb.FileExistsOnDevice(file_name) | 117 return self._adb.FileExistsOnDevice(file_name) |
118 | 118 |
119 def IsRootEnabled(self): | 119 def IsRootEnabled(self): |
120 return self._adb.IsRootEnabled() | 120 return self._adb.IsRootEnabled() |
121 | 121 |
122 | |
122 def HasForwarder(adb, buildtype=None): | 123 def HasForwarder(adb, buildtype=None): |
123 if not buildtype: | 124 if not buildtype: |
124 return (HasForwarder(adb, buildtype='Release') or | 125 return (HasForwarder(adb, buildtype='Release') or |
125 HasForwarder(adb, buildtype='Debug')) | 126 HasForwarder(adb, buildtype='Debug')) |
126 return (os.path.exists(os.path.join('out', buildtype, 'device_forwarder')) and | 127 return (os.path.exists(os.path.join('out', buildtype, 'device_forwarder')) and |
127 os.path.exists(os.path.join('out', buildtype, 'host_forwarder'))) | 128 os.path.exists(os.path.join('out', buildtype, 'host_forwarder'))) |
128 | 129 |
130 | |
129 class Forwarder(object): | 131 class Forwarder(object): |
130 def __init__(self, adb, host_port): | 132 def __init__(self, adb, host_port): |
131 assert HasForwarder(adb) | 133 assert HasForwarder(adb) |
132 | 134 |
133 port_pairs = [(host_port, host_port), ] | 135 port_pairs = [(0, host_port), ] |
tonyg
2012/10/22 17:21:28
Are you sure this works? I wouldn't expect it to.
bulach
2012/10/22 17:29:02
that's a good point. it worked for me, but you con
| |
134 tool = valgrind_tools.BaseTool() | 136 tool = valgrind_tools.BaseTool() |
135 | 137 |
136 self._host_port = host_port | 138 self._host_port = host_port |
137 buildtype = 'Debug' | 139 buildtype = 'Debug' |
138 if HasForwarder(adb, 'Release'): | 140 if HasForwarder(adb, 'Release'): |
139 buildtype = 'Release' | 141 buildtype = 'Release' |
140 self._forwarder = forwarder.Forwarder( | 142 self._forwarder = forwarder.Forwarder( |
141 adb.Adb(), port_pairs, | 143 adb.Adb(), port_pairs, |
142 tool, '127.0.0.1', buildtype) | 144 tool, '127.0.0.1', buildtype) |
143 self._device_port = self._forwarder.DevicePortForHostPort(self._host_port) | 145 self._device_port = self._forwarder.DevicePortForHostPort(self._host_port) |
144 | 146 |
145 @property | 147 @property |
146 def url(self): | 148 def url(self): |
147 assert self._forwarder | 149 assert self._forwarder |
148 return 'http://localhost:%i' % self._device_port | 150 return 'http://localhost:%i' % self._device_port |
149 | 151 |
150 def Close(self): | 152 def Close(self): |
151 if self._forwarder: | 153 if self._forwarder: |
152 self._forwarder.Close() | 154 self._forwarder.Close() |
153 self._forwarder = None | 155 self._forwarder = None |
OLD | NEW |