From f79a49bbf9cde6a7ab399c3e5f6b28a87f1b4477 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 2 Jul 2015 15:41:45 -0700 Subject: [PATCH] SkyDemo should use explicit intents This CL switches SkyDemo over to using explicit intents for deciding which Sky apps to run. This change lets us get rid of the hacky "sky" URI scheme. Instead, we use normal URLs but we require the sender of the intent to be explicit in directing the VIEW intent to us. TBR=eseidel@google.com Review URL: https://codereview.chromium.org/1221123003. --- .../org/domokit/sky/shell/SkyActivity.java | 7 +++++-- engine/src/flutter/tools/shelldb | 16 +++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java index 84a08af067..0724ebf9a1 100644 --- a/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java +++ b/engine/src/flutter/shell/android/org/domokit/sky/shell/SkyActivity.java @@ -41,7 +41,7 @@ public class SkyActivity extends Activity { setContentView(mView); mTracingController = new TracingController(this); - loadSnapshotIfAvailable(); + onSkyReady(); } /** @@ -65,7 +65,10 @@ public class SkyActivity extends Activity { super.onBackPressed(); } - private void loadSnapshotIfAvailable() { + /** + * Override this function to customize startup behavior. + */ + protected void onSkyReady() { File dataDir = new File(PathUtils.getDataDirectory(this)); File snapshot = new File(dataDir, SkyApplication.SNAPSHOT); if (snapshot.exists()) { diff --git a/engine/src/flutter/tools/shelldb b/engine/src/flutter/tools/shelldb index 0eb49187a7..48420db3e8 100755 --- a/engine/src/flutter/tools/shelldb +++ b/engine/src/flutter/tools/shelldb @@ -26,11 +26,12 @@ SRC_ROOT = os.path.dirname(SKY_ROOT) GDB_PORT = 8888 SKY_SERVER_PORT = 9888 OBSERVATORY_PORT = 8181 -DEFAULT_URL = "sky://domokit.github.io/home.dart" +DEFAULT_URL = "https://domokit.github.io/home.dart" APK_NAME = 'SkyDemo.apk' ADB_PATH = os.path.join(SRC_ROOT, 'third_party/android_tools/sdk/platform-tools/adb') ANDROID_PACKAGE = "org.domokit.sky.demo" +ANDROID_COMPONENT = '%s/%s.SkyDemoActivity' % (ANDROID_PACKAGE, ANDROID_PACKAGE) SHA1_PATH = '/sdcard/%s/%s.sha1' % (ANDROID_PACKAGE, APK_NAME) PID_FILE_PATH = "/tmp/skydemo.pids" @@ -104,12 +105,6 @@ class Pids(object): logging.warn('Failed to write pid file: %s' % path) -def _convert_to_sky_url(url): - parts = urlparse.urlsplit(url) - parts = parts._replace(scheme='sky') - return parts.geturl() - - # A free function for possible future sharing with a 'load' command. def _url_from_args(args, pids): if urlparse.urlparse(args.url_or_path).scheme: @@ -117,9 +112,8 @@ def _url_from_args(args, pids): # The load happens on the remote device, use the remote port. remote_sky_server_port = pids.get('remote_sky_server_port', pids['sky_server_port']) - url = SkyServer.url_for_path(remote_sky_server_port, + return SkyServer.url_for_path(remote_sky_server_port, pids['sky_server_root'], args.url_or_path) - return _convert_to_sky_url(url) def dev_packages_root(build_dir): @@ -235,11 +229,11 @@ class StartSky(object): ]) pids['remote_sky_server_port'] = sky_server.port - subprocess.check_call([ADB_PATH, 'shell', 'am', 'start', '-a', 'android.intent.action.VIEW', - '-d', _url_from_args(args, pids)]) + '-d', _url_from_args(args, pids), + ANDROID_COMPONENT]) if not args.gdb: return