diff --git a/apk/demo/AndroidManifest.xml b/apk/demo/AndroidManifest.xml
index dc6b36921682453744674a8958aa1c389e0c0b49..9d0ed17c8b85cc54aa9985a085f9b1f72e3c2647 100644
--- a/apk/demo/AndroidManifest.xml
+++ b/apk/demo/AndroidManifest.xml
@@ -15,11 +15,6 @@
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java b/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
index fcc2a23d018eb93fd6753656d3c8316131a29c4c..0fff47c115ec2c9ba7f360379ed5c8aaa52a17e0 100644
--- a/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
+++ b/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java
@@ -5,8 +5,6 @@
package org.domokit.sky.demo;
import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
import org.domokit.sky.shell.SkyActivity;
@@ -14,28 +12,17 @@ import org.domokit.sky.shell.SkyActivity;
* Main activity for SkyDemo.
*/
public class SkyDemoActivity extends SkyActivity {
+ private static final String DEFAULT_URL = "https://domokit.github.io/home.dart";
- /**
- * @see android.app.Activity#onCreate(android.os.Bundle)
- */
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- String url = "https://domokit.github.io/home.dart";
+ protected void onSkyReady() {
Intent intent = getIntent();
- if (Intent.ACTION_VIEW.equals(intent.getAction())) {
- Uri skyUri = intent.getData();
- Uri httpsUri = skyUri.buildUpon().scheme("https").build();
- // This is a hack to disable https for local testing.
- // getHost may be null if we're passed a non-normalized url.
- if (skyUri.getHost() != null
- && skyUri.getHost().equals("localhost")) {
- httpsUri = skyUri.buildUpon().scheme("http").build();
- }
- url = httpsUri.toString();
- }
+ String action = intent.getAction();
- loadUrl(url);
+ if (Intent.ACTION_MAIN.equals(action)) {
+ loadUrl(DEFAULT_URL);
+ } else if (Intent.ACTION_VIEW.equals(action)) {
+ loadUrl(intent.getDataString());
+ }
}
}
diff --git a/sdk/home.dart b/sdk/home.dart
index c3c37f2a964c389d5fd012f9ad0e0941c5c42569..782648134b5a67588371760e19e3c3dac7f6d551 100644
--- a/sdk/home.dart
+++ b/sdk/home.dart
@@ -21,11 +21,14 @@ import 'package:sky/widgets/tool_bar.dart';
void launch(String relativeUrl) {
Uri url = Uri.base.resolve(relativeUrl);
- url = url.replace(scheme: 'sky');
ActivityManagerProxy activityManager = new ActivityManagerProxy.unbound();
+ ComponentName component = new ComponentName()
+ ..packageName = 'org.domokit.sky.demo'
+ ..className = 'org.domokit.sky.demo.SkyDemoActivity';
Intent intent = new Intent()
..action = 'android.intent.action.VIEW'
+ ..component = component
..url = url.toString();
shell.requestService(null, activityManager);
activityManager.ptr.startActivity(intent);
diff --git a/services/intents/intents.mojom b/services/intents/intents.mojom
index accaf7e35a5055f429f395cb485669e06300eb04..33cdb927286ddc63d21e234411d3e540bdca9d76 100644
--- a/services/intents/intents.mojom
+++ b/services/intents/intents.mojom
@@ -4,9 +4,15 @@
module intents;
+struct ComponentName {
+ string package_name;
+ string class_name;
+};
+
struct Intent {
string action;
string url;
+ ComponentName? component;
};
// TODO(abarth): This interface seems very specific to Android. Do we want to
diff --git a/services/intents/src/org/domokit/intents/ActivityManagerImpl.java b/services/intents/src/org/domokit/intents/ActivityManagerImpl.java
index ad9871ea225ebb6580dc0893304fad1434162499..51ca4ca2971dcc50fabe77287d2485a29c742ecb 100644
--- a/services/intents/src/org/domokit/intents/ActivityManagerImpl.java
+++ b/services/intents/src/org/domokit/intents/ActivityManagerImpl.java
@@ -11,6 +11,7 @@ import android.util.Log;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojom.intents.ActivityManager;
+import org.chromium.mojom.intents.ComponentName;
import org.chromium.mojom.intents.Intent;
/**
@@ -34,6 +35,14 @@ public class ActivityManagerImpl implements ActivityManager {
public void startActivity(Intent intent) {
final android.content.Intent androidIntent = new android.content.Intent(
intent.action, Uri.parse(intent.url));
+
+ if (intent.component != null) {
+ ComponentName component = intent.component;
+ android.content.ComponentName androidComponent =
+ new android.content.ComponentName(component.packageName, component.className);
+ androidIntent.setComponent(androidComponent);
+ }
+
androidIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
try {
diff --git a/shell/android/org/domokit/sky/shell/SkyActivity.java b/shell/android/org/domokit/sky/shell/SkyActivity.java
index 84a08af0672fb1ef10e6b597abd4cde2d1d1d246..0724ebf9a1d4efcfafaafdb4538ff2ce4af1f106 100644
--- a/shell/android/org/domokit/sky/shell/SkyActivity.java
+++ b/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/tools/shelldb b/tools/shelldb
index 0eb49187a79aff439bd399ce23ef4657362667ee..48420db3e814ccea2142fa069a18bb6827a430c2 100755
--- a/tools/shelldb
+++ b/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