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

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/adb_commands.py

Issue 11187036: Android: start upstreaming some of our perf tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 # 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 def HasForwarder(adb): 122 def HasForwarder(adb):
123 return adb.FileExistsOnDevice('/data/local/tmp/forwarder') 123 return adb.FileExistsOnDevice('/data/local/tmp/device_forwarder')
124 124
125 def HowToInstallForwarder(): 125 def HowToInstallForwarder():
126 return 'adb push out/$BUILD_TYPE/forwarder %s' % ( 126 return 'adb push out/$BUILD_TYPE/device_forwarder %s' % (
127 '/data/local/tmp/forwarder') 127 '/data/local/tmp/device_forwarder')
128 128
129 class Forwarder(object): 129 class Forwarder(object):
130 def __init__(self, adb, host_port): 130 def __init__(self, adb, host_port):
131 assert HasForwarder(adb) 131 assert HasForwarder(adb)
132 132
133 port_pairs = [(host_port, host_port), ] 133 port_pairs = [(0, host_port), ]
134 tool = valgrind_tools.BaseTool() 134 tool = valgrind_tools.BaseTool()
135 135
136 self._host_port = host_port 136 self._host_port = host_port
137 137
138 # Currently, Forwarder requires that ../out/Debug/forwarder exists, 138 # Currently, Forwarder requires that ../out/Debug/forwarder exists,
139 # in case it needs to push it to the device. However, to get to here, 139 # in case it needs to push it to the device. However, to get to here,
140 # android_browser_finder has ensured that device HasForwarder, above. 140 # android_browser_finder has ensured that device HasForwarder, above.
141 # 141 #
142 # Therefore, here, we just need to instantiate the forwarder, no push 142 # Therefore, here, we just need to instantiate the forwarder, no push
143 # needed. 143 # needed.
144 # 144 #
145 # To do this, we monkey patch adb.PushIfNeeded to a noop. 145 # To do this, we monkey patch adb.PushIfNeeded to a noop.
146 # 146 #
147 # TODO(nduca): Fix build.android.pylib.Forwarder to not need this. 147 # TODO(nduca): Fix build.android.pylib.Forwarder to not need this.
148 real_push_if_needed = adb.Adb().PushIfNeeded 148 real_push_if_needed = adb.Adb().PushIfNeeded
149 def FakePush(_, device_path): 149 def FakePush(_, device_path):
150 assert adb.FileExistsOnDevice(device_path) 150 assert adb.FileExistsOnDevice(device_path)
151 try: 151 try:
152 adb.Adb().PushIfNeeded = FakePush 152 adb.Adb().PushIfNeeded = FakePush
153 self._forwarder = forwarder.Forwarder( 153 self._forwarder = forwarder.Forwarder(
154 adb.Adb(), port_pairs, 154 adb.Adb(), port_pairs,
155 tool, 'localhost', 'unused') 155 tool, '127.0.0.1', os.environ.get('BUILDTYPE', 'Debug'))
156 finally: 156 finally:
157 adb.Adb().PushIfNeeded = real_push_if_needed 157 adb.Adb().PushIfNeeded = real_push_if_needed
158 self._device_port = self._forwarder.DevicePortForHostPort(self._host_port) 158 self._device_port = self._forwarder.DevicePortForHostPort(self._host_port)
159 159
160 @property 160 @property
161 def url(self): 161 def url(self):
162 assert self._forwarder 162 assert self._forwarder
163 return 'http://localhost:%i' % self._device_port 163 return 'http://localhost:%i' % self._device_port
164 164
165 def Close(self): 165 def Close(self):
166 if self._forwarder: 166 if self._forwarder:
167 self._forwarder.Close() 167 self._forwarder.Close()
168 self._forwarder = None 168 self._forwarder = None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698