提交 855e2391 编写于 作者: J John McCutchan 提交者: GitHub

Add intent for running from a script file (#2807)

上级 0df124f9
......@@ -407,7 +407,7 @@ public class FlutterView extends SurfaceView
mNativePlatformView = nativeAttach(engine.second.passHandle().releaseNativeHandle());
}
public void runFromBundle(String bundlePath, String snapshotPath) {
private void preRun() {
if (mPlatformServiceProviderBinding != null) {
mPlatformServiceProviderBinding.unbind().close();
mPlatformServiceProvider.unbindServices();
......@@ -443,6 +443,20 @@ public class FlutterView extends SurfaceView
mSkyEngine.setServices(services);
resetAccessibilityTree();
}
private void postRun() {
Core core = CoreImpl.getInstance();
// Connect to the ApplicationMessages service exported by the Flutter framework
Pair<ApplicationMessages.Proxy, InterfaceRequest<ApplicationMessages>> appMessages =
ApplicationMessages.MANAGER.getInterfaceRequest(core);
mDartServiceProvider.connectToService(ApplicationMessages.MANAGER.getName(),
appMessages.second.passHandle());
mFlutterAppMessages = appMessages.first;
}
public void runFromBundle(String bundlePath, String snapshotPath) {
preRun();
if (FlutterMain.isRunningPrecompiledCode()) {
mSkyEngine.runFromPrecompiledSnapshot(bundlePath);
......@@ -455,12 +469,13 @@ public class FlutterView extends SurfaceView
}
}
// Connect to the ApplicationMessages service exported by the Flutter framework
Pair<ApplicationMessages.Proxy, InterfaceRequest<ApplicationMessages>> appMessages =
ApplicationMessages.MANAGER.getInterfaceRequest(core);
mDartServiceProvider.connectToService(ApplicationMessages.MANAGER.getName(),
appMessages.second.passHandle());
mFlutterAppMessages = appMessages.first;
postRun();
}
public void runFromFile(String main, String packageRoot) {
preRun();
mSkyEngine.runFromFile(main, packageRoot, "");
postRun();
}
private static native long nativeAttach(int inputObserverHandle);
......
......@@ -135,11 +135,19 @@ public class SkyActivity extends Activity {
public boolean loadIntent(Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_RUN.equals(action)) {
mView.runFromBundle(intent.getDataString(),
intent.getStringExtra("snapshot"));
String file = intent.getStringExtra("file");
String packageRoot = intent.getStringExtra("packages");
String route = intent.getStringExtra("route");
// TODO(johnmccutchan): Remove the need for the runFromFile
// intent by launching an empty application at startup and
// reloading from within that.
if ((file != null) && (packageRoot != null)) {
mView.runFromFile(file, packageRoot);
} else {
mView.runFromBundle(intent.getDataString(),
intent.getStringExtra("snapshot"));
}
if (route != null)
mView.pushRoute(route);
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册