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

Unified Diff: mojo/tools/mopy/android.py

Issue 963713003: Support --origin in android_mojo_shell. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move atexit.register(StopShell) to StartShell. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/tools/apptest_runner.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/tools/mopy/android.py
diff --git a/mojo/tools/mopy/android.py b/mojo/tools/mopy/android.py
index d9928d7cadc5ac2efbdee35f474b044cc4c511ff..edfdcc548f9b0307df4c370be2607710bec390fb 100644
--- a/mojo/tools/mopy/android.py
+++ b/mojo/tools/mopy/android.py
@@ -151,22 +151,24 @@ def StartHttpServerForDirectory(path):
return 'http://127.0.0.1:%d/' % _MapPort(0, httpd.server_address[1])
-def PrepareShellRun(config):
- """
- Prepares for StartShell. Returns an origin arg with the forwarded device port.
+def PrepareShellRun(config, origin=None):
+ """ Prepares for StartShell: runs adb as root and installs the apk. If no
+ --origin is specified, local http server will be set up to serve files from
+ the build directory along with port forwarding.
- Start an internal http server to serve mojo applications, forward a local port
- on the device to this http server, and install the latest mojo shell version.
- """
+ Returns arguments that should be appended to shell argument list."""
build_dir = Paths(config).build_dir
+
subprocess.check_call([ADB_PATH, 'root'])
apk_path = os.path.join(build_dir, 'apks', 'MojoShell.apk')
subprocess.check_call(
[ADB_PATH, 'install', '-r', apk_path, '-i', MOJO_SHELL_PACKAGE_NAME])
- atexit.register(StopShell)
+ extra_shell_args = []
+ origin_url = origin if origin else StartHttpServerForDirectory(build_dir)
+ extra_shell_args.append("--origin=" + origin_url)
- return '--origin=' + StartHttpServerForDirectory(build_dir)
+ return extra_shell_args
def _StartHttpServerForOriginMapping(mapping):
@@ -220,13 +222,15 @@ def StartShell(arguments, stdout=None, on_application_stop=None):
subprocess.check_call([ADB_PATH, 'shell', 'rm', STDOUT_PIPE])
parameters.append('--fifo-path=%s' % STDOUT_PIPE)
_ReadFifo(STDOUT_PIPE, stdout, on_application_stop)
- assert any("--origin=http://127.0.0.1:" in arg for arg in arguments)
+ # The origin has to be specified whether it's local or external.
+ assert any("--origin=" in arg for arg in arguments)
parameters += [_StartHttpServerForOriginMappings(arg) for arg in arguments]
if parameters:
encodedParameters = json.dumps(parameters)
cmd += [ '--es', 'encodedParameters', encodedParameters]
+ atexit.register(StopShell)
with open(os.devnull, 'w') as devnull:
subprocess.Popen(cmd, stdout=devnull).wait()
« no previous file with comments | « mojo/tools/apptest_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698