From 2a94ecc6788a25932e3edd9922871c23a55ae342 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Wed, 17 Sep 2014 15:26:00 -0700 Subject: [PATCH 01/16] added some handling of the Build button click event --- ide/web/spark.dart | 69 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/ide/web/spark.dart b/ide/web/spark.dart index f5f514934..90823096e 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2160,7 +2160,7 @@ class FocusMainMenuAction extends SparkAction { } } -class BuildApkAction extends SparkActionWithDialog { +class BuildApkAction extends SparkActionWithProgressDialog { BuildApkAction(Spark spark, Element dialog) : super(spark, "application-build", "Build APK…", dialog) { getElement('#choosePrivateKey').onClick.listen((_) { @@ -2179,13 +2179,76 @@ class BuildApkAction extends SparkActionWithDialog { }); } + InputElement _pushUrlElement; + ProgressMonitor _monitor; + ws.Container deployContainer; + ws.Resource _resource; + void _invoke([context]) { - _show(); + if (context == null) { + _resource = spark.focusManager.currentResource; + } else { + _resource = context.first; + } + + deployContainer = getAppContainerFor(_resource); + + if (deployContainer == null) { + spark.showErrorMessage( + 'Unable to Build the APK', + message: 'Unable to build the current selection; ' + 'please select a Chrome App to build.'); + } else if (!MobileDeploy.isAvailable()) { + spark.showErrorMessage( + 'Unable to Build', message: 'No USB devices available.'); + } else { + _pushUrlElement = getElement('#buildTargetUrl'); + _toggleProgressVisible(false); + _show(); + } } void _commit() { super._commit(); - //TODO(albualexandru): add here the binding to the build class + + _setProgressMessage("Deploying…"); + _toggleProgressVisible(true); + /*_deployButton.disabled = true; + // TODO(ussuri): BUG #2252. + _deployButton.deliverChanges();*/ + + //build the app.json + Map mobileAppManifest = {}; + mobileAppManifest["appName"] = getElement('#appName').value; + mobileAppManifest["packageName"] = getElement('#packageName').value; + mobileAppManifest["versionName"] = getElement('#versionName').value; + print(JSON.encode(mobileAppManifest).toString()); + + _monitor = new ProgressMonitorImpl(this); + + String type = getElement('input[name="mobileBuildType"]:checked').id; + bool useAdb = type == 'buildTargetADB'; + String url = _pushUrlElement.value; + + MobileDeploy deployer = new MobileDeploy(deployContainer, spark.localPrefs); + + // Invoke the deployer methods in Futures in order to capture exceptions. + Future f = new Future(() { + return useAdb ? + deployer.pushAdb(_monitor) : deployer.pushToHost(url, _monitor); + }); + /* + _monitor.runCancellableFuture(f).then((_) { + _hide(); + spark.showSuccessMessage('Successfully pushed'); + }).catchError((e) { + if (e is! UserCancelledException) { + spark.showMessage('Push Failure', e.toString()); + } + }).whenComplete(() { + //_restoreDialog(); + _monitor = null; + });*/ } } From acb2a0b1fbcee5accf44e303cf1a5a165f891980 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 18 Sep 2014 13:25:56 -0700 Subject: [PATCH 02/16] added the arhiving capability to the build command --- ide/web/lib/mobile/deploy.dart | 54 +++++++++++++++++++++++++++++++- ide/web/lib/workspace_utils.dart | 35 +++++++++++++++++++++ ide/web/spark.dart | 54 ++++++++++++++++++++++---------- ide/web/spark_polymer_ui.html | 2 +- 4 files changed, 127 insertions(+), 18 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index bf71accd4..3241bbdd5 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -48,9 +48,11 @@ class MobileDeploy { final Container appContainer; final PreferenceStore _prefs; + List _knownDevices = []; + MobileBuildInfo _appInfo; - MobileDeploy(this.appContainer, this._prefs) { + MobileDeploy(this.appContainer, this._prefs, [this._appInfo]) { if (appContainer == null) { throw new ArgumentError('must provide an app to push'); } @@ -103,6 +105,36 @@ class MobileDeploy { }); } + Future buildWithHost(String target, ProgressMonitor monitor) { + monitor.start('Building…', maxWork: 10); + + _logger.info('building application to ip host'); + HttpDeployer dep = new HttpDeployer(appContainer, _prefs, target); + return dep.build(monitor, _appInfo); + } + + + Future buildWithAdb(ProgressMonitor monitor) { + monitor.start('Building…', maxWork: 10); + + // Try to find a local ADB server. If we fail, try to use USB. + return AdbClientTcp.createClient().then((AdbClientTcp client) { + _logger.info('building application via adb server'); + return client.forwardTcp(DEPLOY_PORT, DEPLOY_PORT).then((_) { + // Push the app binary on DEPLOY_PORT. + ADBDeployer dep = new ADBDeployer(appContainer, _prefs); + return dep.build(monitor, _appInfo); + }); + }, onError: (_) { + _logger.info('building application via ADB over USB'); + USBDeployer dep = new USBDeployer(appContainer, _prefs); + return dep.init().then((_) { + return dep.build(monitor, _appInfo); + }); + }); + + } + Future _pushToAdbServer(AdbClientTcp client, ProgressMonitor monitor) { // Start ADT on the device. // TODO: a SocketException, code == -100 here often means that the App Dev @@ -310,6 +342,20 @@ abstract class AbstractDeployer { /// that the used resources are disposed void _doWhenComplete(); + Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { + return archiveContainerForBuild(appContainer, appInfo).then((List bytes) { + chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( + type: chrome.ChooseEntryType.SAVE_FILE); + return chrome.fileSystem.chooseEntry(options).then( + (chrome.ChooseEntryResult res) { + chrome.ChromeFileEntry r = res.entry; + r.writeBytes(new chrome.ArrayBuffer.fromBytes(bytes)); + return new Future.error("Not implemented"); + }); +// return new Future.error("Not implemented"); + }); + } + /// Implements the deployement flow Future deploy(ProgressMonitor monitor) { List httpRequest; @@ -474,3 +520,9 @@ class LiveDeployManager { }); } } + +class MobileBuildInfo { + Map mobileAppManifest = {}; + chrome.ChromeFileEntry publicKey; + chrome.ChromeFileEntry privateKey; +} diff --git a/ide/web/lib/workspace_utils.dart b/ide/web/lib/workspace_utils.dart index d2a5b99e3..2bd3ea076 100644 --- a/ide/web/lib/workspace_utils.dart +++ b/ide/web/lib/workspace_utils.dart @@ -15,6 +15,7 @@ import 'package_mgmt/bower.dart'; import 'package_mgmt/bower_properties.dart'; import 'package_mgmt/pub.dart'; import 'workspace.dart'; +import 'mobile/deploy.dart'; Future archiveContainer(Container container, [bool addZipManifest = false]) { archive.Archive arch = new archive.Archive(); @@ -29,6 +30,40 @@ Future archiveContainer(Container container, [bool addZipManifest = false]) { }); } +Future archiveContainerForBuild(Container container, + MobileBuildInfo appData) { + String appJson = JSON.encode(appData.mobileAppManifest); + archive.ZipEncoder encoder = new archive.ZipEncoder(); + + archive.Archive arch = new archive.Archive(); + archive.Archive appInfo = new archive.Archive(); + + appInfo.addFile(new archive.ArchiveFile('app.json', + appJson.codeUnits.length, + appJson.codeUnits)); + + return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { + appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, + bytes.getBytes().length, + bytes.getBytes())); + return appData.privateKey.readBytes().then((chrome.ArrayBuffer bytes) { + appInfo.addFile(new archive.ArchiveFile(appData.privateKey.name, + bytes.getBytes().length, + bytes.getBytes())); + List encoded = encoder.encode(appInfo); + arch.addFile(new archive.ArchiveFile('app.zip',encoded.length, encoded)); + return _recursiveArchive(arch, container, 'www/').then((_) { + String zipAssetManifestString = buildAssetManifest(container); + arch.addFile(new archive.ArchiveFile('zipassetmanifest.json', + zipAssetManifestString.codeUnits.length, + zipAssetManifestString.codeUnits)); + return new archive.ZipEncoder().encode(arch); + }); + }); + }); +} + + /// The [toAddList] List contains the files that need to be mandatory /// pushed to the device Future archiveModifiedFilesInContainer(Container container, [bool addZipManifest = false, diff --git a/ide/web/spark.dart b/ide/web/spark.dart index 90823096e..b5676b8a0 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2163,6 +2163,11 @@ class FocusMainMenuAction extends SparkAction { class BuildApkAction extends SparkActionWithProgressDialog { BuildApkAction(Spark spark, Element dialog) : super(spark, "application-build", "Build APK…", dialog) { + _appNameElement = getElement('#appName'); + _packageNameElement = getElement('#packageName'); + _versionNameElement = getElement('#versionName'); + _privateKeyElement = getElement('#privateKey'); + _publicKeyElement = getElement('#publicKey'); getElement('#choosePrivateKey').onClick.listen((_) { _selectKey('privateKey'); }); @@ -2173,6 +2178,11 @@ class BuildApkAction extends SparkActionWithProgressDialog { void _selectKey(String outputField) { spark.chooseFileEntry().then((ChromeFileEntry entry) { + if (outputField == 'publicKey') { + _appInfo.publicKey = entry; + } else { + _appInfo.privateKey = entry; + } filesystem.fileSystemAccess.getDisplayPath(entry).then((String path) { getElement('#$outputField').text = path; }); @@ -2183,6 +2193,13 @@ class BuildApkAction extends SparkActionWithProgressDialog { ProgressMonitor _monitor; ws.Container deployContainer; ws.Resource _resource; + MobileBuildInfo _appInfo; + InputElement _appNameElement; + InputElement _packageNameElement; + InputElement _versionNameElement; + SpanElement _publicKeyElement; + SpanElement _privateKeyElement; + void _invoke([context]) { if (context == null) { @@ -2204,25 +2221,28 @@ class BuildApkAction extends SparkActionWithProgressDialog { } else { _pushUrlElement = getElement('#buildTargetUrl'); _toggleProgressVisible(false); + _appInfo = new MobileBuildInfo(); _show(); } } + SparkDialogButton get _buildButton => getElement("#buildButton"); + void _commit() { super._commit(); - _setProgressMessage("Deploying…"); + _setProgressMessage("Building…"); _toggleProgressVisible(true); - /*_deployButton.disabled = true; - // TODO(ussuri): BUG #2252. - _deployButton.deliverChanges();*/ + _buildButton.disabled = true; + _buildButton.deliverChanges(); //build the app.json - Map mobileAppManifest = {}; - mobileAppManifest["appName"] = getElement('#appName').value; - mobileAppManifest["packageName"] = getElement('#packageName').value; - mobileAppManifest["versionName"] = getElement('#versionName').value; - print(JSON.encode(mobileAppManifest).toString()); + + _appInfo.mobileAppManifest["appName"] = _appNameElement.value; + _appInfo.mobileAppManifest["packageName"] = _packageNameElement.value; + _appInfo.mobileAppManifest["versionName"] = _versionNameElement.value; + _appInfo.mobileAppManifest["publicKey"] = _publicKeyElement.text; + _appInfo.mobileAppManifest["privateKey"] = _privateKeyElement.text; _monitor = new ProgressMonitorImpl(this); @@ -2230,25 +2250,27 @@ class BuildApkAction extends SparkActionWithProgressDialog { bool useAdb = type == 'buildTargetADB'; String url = _pushUrlElement.value; - MobileDeploy deployer = new MobileDeploy(deployContainer, spark.localPrefs); + MobileDeploy deployer = new MobileDeploy(deployContainer, + spark.localPrefs, _appInfo); // Invoke the deployer methods in Futures in order to capture exceptions. + Future f = new Future(() { return useAdb ? - deployer.pushAdb(_monitor) : deployer.pushToHost(url, _monitor); + deployer.buildWithAdb(_monitor) : deployer.pushToHost(url, _monitor); }); - /* _monitor.runCancellableFuture(f).then((_) { _hide(); - spark.showSuccessMessage('Successfully pushed'); + spark.showSuccessMessage('Successfully built'); }).catchError((e) { if (e is! UserCancelledException) { - spark.showMessage('Push Failure', e.toString()); + spark.showMessage('Build Failure', e.toString()); } }).whenComplete(() { - //_restoreDialog(); + _buildButton.disabled = false; + _buildButton.deliverChanges(); _monitor = null; - });*/ + }); } } diff --git a/ide/web/spark_polymer_ui.html b/ide/web/spark_polymer_ui.html index 9f1f246cd..4e48bed42 100644 --- a/ide/web/spark_polymer_ui.html +++ b/ide/web/spark_polymer_ui.html @@ -429,7 +429,7 @@ Cancel - Build + Build From 9b3c42545cb9b5579febd4724a105cdd43dfecfb Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 18 Sep 2014 13:38:50 -0700 Subject: [PATCH 03/16] some minor changes --- ide/web/lib/mobile/deploy.dart | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index 3241bbdd5..48ab050ac 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -159,6 +159,7 @@ abstract class AbstractDeployer { static const int DEPLOY_PORT = 2424; static Duration REGULAR_REQUEST_TIMEOUT = new Duration(seconds: 2); static Duration PUSH_REQUEST_TIMEOUT = new Duration(seconds: 60); + static Duration BUILD_REQUEST_TIMEOUT = new Duration(seconds: 120); final Container appContainer; final PreferenceStore _prefs; @@ -214,6 +215,12 @@ abstract class AbstractDeployer { payload: archivedData); } + List _makeBuildRequest(String target, List archivedData) { + return _buildHttpRequest("POST" ,target, + "build?appId=${appContainer.project.name}&appType=chrome", + payload: archivedData); + } + List _buildDeleteRequest(String target, List archivedData) { return _buildHttpRequest("POST" ,target, "deletefiles?appId=${appContainer.project.name}", @@ -343,16 +350,17 @@ abstract class AbstractDeployer { void _doWhenComplete(); Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { - return archiveContainerForBuild(appContainer, appInfo).then((List bytes) { + return archiveContainerForBuild(appContainer, appInfo).then((List archivedData) { + List httpRequest = _buildPushRequest(_getTarget(), archivedData); + chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( type: chrome.ChooseEntryType.SAVE_FILE); - return chrome.fileSystem.chooseEntry(options).then( - (chrome.ChooseEntryResult res) { - chrome.ChromeFileEntry r = res.entry; - r.writeBytes(new chrome.ArrayBuffer.fromBytes(bytes)); - return new Future.error("Not implemented"); - }); -// return new Future.error("Not implemented"); + return chrome.fileSystem.chooseEntry(options).then( + (chrome.ChooseEntryResult res) { + chrome.ChromeFileEntry r = res.entry; + r.writeBytes(new chrome.ArrayBuffer.fromBytes(archivedData)); + return new Future.error("Not implemented"); + }); }); } From 9626845df547c3f22fd3eac0685b6f4ed1f67240 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 18 Sep 2014 14:16:19 -0700 Subject: [PATCH 04/16] some minor changes --- ide/web/spark.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ide/web/spark.dart b/ide/web/spark.dart index 0a584c89f..5a506beb8 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2247,8 +2247,9 @@ class BuildApkAction extends SparkActionWithProgressDialog { _appInfo.mobileAppManifest["appName"] = _appNameElement.value; _appInfo.mobileAppManifest["packageName"] = _packageNameElement.value; _appInfo.mobileAppManifest["versionName"] = _versionNameElement.value; - _appInfo.mobileAppManifest["publicKey"] = _publicKeyElement.text; - _appInfo.mobileAppManifest["privateKey"] = _privateKeyElement.text; + _appInfo.mobileAppManifest["keyPassword"] = "android"; + _appInfo.mobileAppManifest["publicKeyName"] = _appInfo.publicKey.name; + _appInfo.mobileAppManifest["privateKeyName"] = _appInfo.privateKey.name; _monitor = new ProgressMonitorImpl(this); From 7e218b9153fc8b4cf9fd4f490198f3a0e369ae87 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 18 Sep 2014 15:23:12 -0700 Subject: [PATCH 05/16] some minor changes --- ide/web/spark.dart | 4 +++- ide/web/spark_polymer_ui.html | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ide/web/spark.dart b/ide/web/spark.dart index 5a506beb8..50f3fdf3c 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2174,6 +2174,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { _versionNameElement = getElement('#versionName'); _privateKeyElement = getElement('#privateKey'); _publicKeyElement = getElement('#publicKey'); + _privatePasswordElement = getElement('#privateKeyPassword'); getElement('#choosePrivateKey').onClick.listen((_) { _selectKey('privateKey'); }); @@ -2203,6 +2204,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { InputElement _appNameElement; InputElement _packageNameElement; InputElement _versionNameElement; + InputElement _privatePasswordElement; SpanElement _publicKeyElement; SpanElement _privateKeyElement; @@ -2247,7 +2249,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { _appInfo.mobileAppManifest["appName"] = _appNameElement.value; _appInfo.mobileAppManifest["packageName"] = _packageNameElement.value; _appInfo.mobileAppManifest["versionName"] = _versionNameElement.value; - _appInfo.mobileAppManifest["keyPassword"] = "android"; + _appInfo.mobileAppManifest["keyPassword"] = _privatePasswordElement.value; _appInfo.mobileAppManifest["publicKeyName"] = _appInfo.publicKey.name; _appInfo.mobileAppManifest["privateKeyName"] = _appInfo.privateKey.name; diff --git a/ide/web/spark_polymer_ui.html b/ide/web/spark_polymer_ui.html index 4e48bed42..2c41896b4 100644 --- a/ide/web/spark_polymer_ui.html +++ b/ide/web/spark_polymer_ui.html @@ -377,6 +377,12 @@ placeholder="1.0" spellcheck="false" autosave focused> +
+ + +
Date: Mon, 22 Sep 2014 10:13:02 -0700 Subject: [PATCH 06/16] added the app info required for deployment into the manifest.json --- ide/web/lib/apps/app_utils.dart | 1 + ide/web/lib/workspace_utils.dart | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ide/web/lib/apps/app_utils.dart b/ide/web/lib/apps/app_utils.dart index a9832359a..47a983873 100644 --- a/ide/web/lib/apps/app_utils.dart +++ b/ide/web/lib/apps/app_utils.dart @@ -42,3 +42,4 @@ Container getAppContainerFor(Resource resource) { bool _hasManifest(Container container) { return container.getChild('manifest.json') is File; } + diff --git a/ide/web/lib/workspace_utils.dart b/ide/web/lib/workspace_utils.dart index 2bd3ea076..ec77a3688 100644 --- a/ide/web/lib/workspace_utils.dart +++ b/ide/web/lib/workspace_utils.dart @@ -42,6 +42,14 @@ Future archiveContainerForBuild(Container container, appJson.codeUnits.length, appJson.codeUnits)); + chrome.ChromeFileEntry manifest = container.getChild('manifest.json').entry; + manifest.readText().then((String manifestJson) { + Map map = JSON.decode(manifestJson); + map["mobile"] = appData.mobileAppManifest; + String newValue = JSON.encode(map); + manifest.writeText(newValue); + }); + return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, bytes.getBytes().length, From 7cb6fbd956896e485bb3b8259e7ae929958d273a Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Tue, 23 Sep 2014 10:00:54 -0700 Subject: [PATCH 07/16] refactored the backend of the build apk process --- ide/web/lib/mobile/deploy.dart | 44 +++++++++++++++++++++++++++++--- ide/web/lib/workspace_utils.dart | 34 ++++++++++++++++++------ ide/web/spark.dart | 28 +++++++++++++++++--- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index 48ab050ac..69f3fcb9d 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -221,6 +221,11 @@ abstract class AbstractDeployer { payload: archivedData); } + List _makeBuildRequest2(String target) { + return _buildHttpRequest("POST" ,target, "build?appId=${appContainer.project.name}"); + } + + List _buildDeleteRequest(String target, List archivedData) { return _buildHttpRequest("POST" ,target, "deletefiles?appId=${appContainer.project.name}", @@ -350,19 +355,50 @@ abstract class AbstractDeployer { void _doWhenComplete(); Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { - return archiveContainerForBuild(appContainer, appInfo).then((List archivedData) { - List httpRequest = _buildPushRequest(_getTarget(), archivedData); + List httpRequest; + List ad; + httpRequest = _buildAssetManifestRequest(_getTarget()); + return _setTimeout(_pushRequestToDevice(httpRequest, REGULAR_REQUEST_TIMEOUT)) + .then((msg) { + return _expectHttpOkResponse(msg); + }).then((String result) { + return _deleteObsoleteFiles(result); + }).then((msg) { + if (msg != null) { + return _expectHttpOkResponse(msg); + } + }).then((_) { + return archiveModifiedFilesInContainer(appContainer, true, fileToAdd) + .then((List archivedData) { + ad = archivedData; + httpRequest = _buildPushRequest(_getTarget(), archivedData); + return _setTimeout(_pushRequestToDevice(httpRequest, PUSH_REQUEST_TIMEOUT)); + }).then((msg) { + return _expectHttpOkResponse(msg); + }).then((String response) { + _updateContainerEtag(response); + return archiveDataForBuild(appContainer, appInfo); + }).then((List archivedData) { + ad = archivedData; + httpRequest = _makeBuildRequest(_getTarget(), archivedData); + //return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); + return new Future.value("bla"); + }).then((_) { + //need to prompt for save as to save the APK chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( type: chrome.ChooseEntryType.SAVE_FILE); return chrome.fileSystem.chooseEntry(options).then( (chrome.ChooseEntryResult res) { chrome.ChromeFileEntry r = res.entry; - r.writeBytes(new chrome.ArrayBuffer.fromBytes(archivedData)); + r.writeBytes(new chrome.ArrayBuffer.fromBytes(ad)); return new Future.error("Not implemented"); }); }); - } + }).whenComplete(() { + _doWhenComplete(); + }); +} /// Implements the deployement flow Future deploy(ProgressMonitor monitor) { diff --git a/ide/web/lib/workspace_utils.dart b/ide/web/lib/workspace_utils.dart index ec77a3688..bc79c83af 100644 --- a/ide/web/lib/workspace_utils.dart +++ b/ide/web/lib/workspace_utils.dart @@ -42,14 +42,6 @@ Future archiveContainerForBuild(Container container, appJson.codeUnits.length, appJson.codeUnits)); - chrome.ChromeFileEntry manifest = container.getChild('manifest.json').entry; - manifest.readText().then((String manifestJson) { - Map map = JSON.decode(manifestJson); - map["mobile"] = appData.mobileAppManifest; - String newValue = JSON.encode(map); - manifest.writeText(newValue); - }); - return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, bytes.getBytes().length, @@ -71,6 +63,32 @@ Future archiveContainerForBuild(Container container, }); } +Future archiveDataForBuild(Container container, + MobileBuildInfo appData) { + String appJson = JSON.encode(appData.mobileAppManifest); + archive.ZipEncoder encoder = new archive.ZipEncoder(); + + archive.Archive arch = new archive.Archive(); + archive.Archive appInfo = new archive.Archive(); + + appInfo.addFile(new archive.ArchiveFile('app.json', + appJson.codeUnits.length, + appJson.codeUnits)); + + return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { + appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, + bytes.getBytes().length, + bytes.getBytes())); + return appData.privateKey.readBytes().then((chrome.ArrayBuffer bytes) { + appInfo.addFile(new archive.ArchiveFile(appData.privateKey.name, + bytes.getBytes().length, + bytes.getBytes())); + return new archive.ZipEncoder().encode(appInfo); + }); + }); +} + + /// The [toAddList] List contains the files that need to be mandatory /// pushed to the device diff --git a/ide/web/spark.dart b/ide/web/spark.dart index 50f3fdf3c..d6e3dda4b 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2175,6 +2175,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { _privateKeyElement = getElement('#privateKey'); _publicKeyElement = getElement('#publicKey'); _privatePasswordElement = getElement('#privateKeyPassword'); + _appInfo = new MobileBuildInfo(); getElement('#choosePrivateKey').onClick.listen((_) { _selectKey('privateKey'); }); @@ -2229,13 +2230,35 @@ class BuildApkAction extends SparkActionWithProgressDialog { } else { _pushUrlElement = getElement('#buildTargetUrl'); _toggleProgressVisible(false); - _appInfo = new MobileBuildInfo(); + _updateViewFromManifest(deployContainer); _show(); } } SparkDialogButton get _buildButton => getElement("#buildButton"); + void _updateViewFromManifest(Container container) { + chrome.ChromeFileEntry manifest = container.getChild('manifest.json').entry; + manifest.readText().then((String manifestJson) { + Map map = JSON.decode(manifestJson); + _appNameElement.value = map["name"]; + _packageNameElement.value = map["short_name"]; + _versionNameElement.value = map["version"]; + }); + } + + void _updateManifestFromView(Container container) { + chrome.ChromeFileEntry manifest = container.getChild('manifest.json').entry; + manifest.readText().then((String manifestJson) { + Map map = JSON.decode(manifestJson); + map["name"] = _appNameElement.value; + map["short_name"] = _packageNameElement.value; + map["version"] = _versionNameElement.value; + String newValue = JSON.encode(map); + manifest.writeText(newValue); + }); + } + void _commit() { super._commit(); @@ -2261,8 +2284,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { MobileDeploy deployer = new MobileDeploy(deployContainer, spark.localPrefs, _appInfo); - - // Invoke the deployer methods in Futures in order to capture exceptions. + _updateManifestFromView(deployContainer); Future f = new Future(() { return useAdb ? From 5bd8764a053c0085888151838de40b9735fd2d1e Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Tue, 23 Sep 2014 10:41:11 -0700 Subject: [PATCH 08/16] style changes --- ide/web/lib/apps/app_utils.dart | 1 - ide/web/lib/mobile/deploy.dart | 12 +++-------- ide/web/lib/workspace_utils.dart | 34 -------------------------------- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/ide/web/lib/apps/app_utils.dart b/ide/web/lib/apps/app_utils.dart index 47a983873..a9832359a 100644 --- a/ide/web/lib/apps/app_utils.dart +++ b/ide/web/lib/apps/app_utils.dart @@ -42,4 +42,3 @@ Container getAppContainerFor(Resource resource) { bool _hasManifest(Container container) { return container.getChild('manifest.json') is File; } - diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index 69f3fcb9d..3d17859b7 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -48,7 +48,6 @@ class MobileDeploy { final Container appContainer; final PreferenceStore _prefs; - List _knownDevices = []; MobileBuildInfo _appInfo; @@ -221,11 +220,6 @@ abstract class AbstractDeployer { payload: archivedData); } - List _makeBuildRequest2(String target) { - return _buildHttpRequest("POST" ,target, "build?appId=${appContainer.project.name}"); - } - - List _buildDeleteRequest(String target, List archivedData) { return _buildHttpRequest("POST" ,target, "deletefiles?appId=${appContainer.project.name}", @@ -380,9 +374,9 @@ abstract class AbstractDeployer { _updateContainerEtag(response); return archiveDataForBuild(appContainer, appInfo); }).then((List archivedData) { - ad = archivedData; - httpRequest = _makeBuildRequest(_getTarget(), archivedData); - //return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); + ad = archivedData; + httpRequest = _makeBuildRequest(_getTarget(), archivedData); + //return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); return new Future.value("bla"); }).then((_) { //need to prompt for save as to save the APK diff --git a/ide/web/lib/workspace_utils.dart b/ide/web/lib/workspace_utils.dart index bc79c83af..c9a5fb597 100644 --- a/ide/web/lib/workspace_utils.dart +++ b/ide/web/lib/workspace_utils.dart @@ -30,45 +30,11 @@ Future archiveContainer(Container container, [bool addZipManifest = false]) { }); } -Future archiveContainerForBuild(Container container, - MobileBuildInfo appData) { - String appJson = JSON.encode(appData.mobileAppManifest); - archive.ZipEncoder encoder = new archive.ZipEncoder(); - - archive.Archive arch = new archive.Archive(); - archive.Archive appInfo = new archive.Archive(); - - appInfo.addFile(new archive.ArchiveFile('app.json', - appJson.codeUnits.length, - appJson.codeUnits)); - - return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { - appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, - bytes.getBytes().length, - bytes.getBytes())); - return appData.privateKey.readBytes().then((chrome.ArrayBuffer bytes) { - appInfo.addFile(new archive.ArchiveFile(appData.privateKey.name, - bytes.getBytes().length, - bytes.getBytes())); - List encoded = encoder.encode(appInfo); - arch.addFile(new archive.ArchiveFile('app.zip',encoded.length, encoded)); - return _recursiveArchive(arch, container, 'www/').then((_) { - String zipAssetManifestString = buildAssetManifest(container); - arch.addFile(new archive.ArchiveFile('zipassetmanifest.json', - zipAssetManifestString.codeUnits.length, - zipAssetManifestString.codeUnits)); - return new archive.ZipEncoder().encode(arch); - }); - }); - }); -} - Future archiveDataForBuild(Container container, MobileBuildInfo appData) { String appJson = JSON.encode(appData.mobileAppManifest); archive.ZipEncoder encoder = new archive.ZipEncoder(); - archive.Archive arch = new archive.Archive(); archive.Archive appInfo = new archive.Archive(); appInfo.addFile(new archive.ArchiveFile('app.json', From 1ea8d8a92b1a36a8299366744ff82bbd7c30f38a Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Tue, 23 Sep 2014 11:54:31 -0700 Subject: [PATCH 09/16] encode manifest with indentation --- ide/web/spark.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ide/web/spark.dart b/ide/web/spark.dart index d6e3dda4b..f42a2385c 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -5,7 +5,7 @@ library spark; import 'dart:async'; -import 'dart:convert' show JSON; +import 'dart:convert'; import 'dart:html' hide File; import 'package:chrome/chrome_app.dart' as chrome; @@ -2254,8 +2254,8 @@ class BuildApkAction extends SparkActionWithProgressDialog { map["name"] = _appNameElement.value; map["short_name"] = _packageNameElement.value; map["version"] = _versionNameElement.value; - String newValue = JSON.encode(map); - manifest.writeText(newValue); + var encoder = new JsonEncoder.withIndent(" "); + manifest.writeText(encoder.convert(map)); }); } From 3055e2336d9ac1c27d0af09c6e323e553a292de2 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Tue, 23 Sep 2014 14:51:14 -0700 Subject: [PATCH 10/16] refactoring --- ide/web/lib/mobile/deploy.dart | 5 ++++- ide/web/spark.dart | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index 3d17859b7..d77faccdd 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -376,9 +376,12 @@ abstract class AbstractDeployer { }).then((List archivedData) { ad = archivedData; httpRequest = _makeBuildRequest(_getTarget(), archivedData); + //TODO(albualexandru): make the request and save the file //return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); return new Future.value("bla"); - }).then((_) { +// }).then((msg) { +// return _expectHttpOkResponse(msg); + }).then((String response) { //need to prompt for save as to save the APK chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( type: chrome.ChooseEntryType.SAVE_FILE); diff --git a/ide/web/spark.dart b/ide/web/spark.dart index f42a2385c..c1d2c7c0a 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2211,6 +2211,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { void _invoke([context]) { + print("test"); if (context == null) { _resource = spark.focusManager.currentResource; } else { From 1a7f2547375814f39ca3c1d4d3ff7d56ef6d4bad Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Mon, 29 Sep 2014 08:54:57 -0700 Subject: [PATCH 11/16] changed to send the zip file --- ide/web/lib/mobile/deploy.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index d77faccdd..da53c9bfe 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -377,11 +377,12 @@ abstract class AbstractDeployer { ad = archivedData; httpRequest = _makeBuildRequest(_getTarget(), archivedData); //TODO(albualexandru): make the request and save the file - //return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); - return new Future.value("bla"); -// }).then((msg) { -// return _expectHttpOkResponse(msg); + return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); + //return new Future.value("bla"); + }).then((msg) { + return _expectHttpOkResponse(msg); }).then((String response) { + print(response); //need to prompt for save as to save the APK chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( type: chrome.ChooseEntryType.SAVE_FILE); From 9a450046ec29e0ab8ba1d506e2393ac79686484a Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Wed, 1 Oct 2014 09:58:33 -0700 Subject: [PATCH 12/16] changes --- ide/web/lib/mobile/deploy.dart | 57 +++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index da53c9bfe..f6e45ab8a 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -216,7 +216,7 @@ abstract class AbstractDeployer { List _makeBuildRequest(String target, List archivedData) { return _buildHttpRequest("POST" ,target, - "build?appId=${appContainer.project.name}&appType=chrome", + "buildapk?appId=${appContainer.project.name}&appType=chrome", payload: archivedData); } @@ -348,6 +348,10 @@ abstract class AbstractDeployer { /// that the used resources are disposed void _doWhenComplete(); + Future sleep1() { + return new Future.delayed(const Duration(seconds: 10), () => "1"); + } + Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { List httpRequest; List ad; @@ -363,7 +367,7 @@ abstract class AbstractDeployer { return _expectHttpOkResponse(msg); } }).then((_) { - return archiveModifiedFilesInContainer(appContainer, true, fileToAdd) + return archiveModifiedFilesInContainer(appContainer, true, []) .then((List archivedData) { ad = archivedData; httpRequest = _buildPushRequest(_getTarget(), archivedData); @@ -374,8 +378,53 @@ abstract class AbstractDeployer { _updateContainerEtag(response); return archiveDataForBuild(appContainer, appInfo); }).then((List archivedData) { - ad = archivedData; - httpRequest = _makeBuildRequest(_getTarget(), archivedData); + return sleep1(); + }).then((_) { + + Map signInfo = new Map(); + + signInfo['storePassword']= 'android'; + signInfo['keyAlias']= 'AndroidDebugKey'; + signInfo['keyPassword'] = 'android'; + signInfo['storeData']="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"; + httpRequest = _makeBuildRequest(_getTarget(), JSON.encode(signInfo).codeUnits); //TODO(albualexandru): make the request and save the file return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); //return new Future.value("bla"); From 2aa5daff5be637ffae76b8ce98257070ce189b2e Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 2 Oct 2014 11:00:10 -0700 Subject: [PATCH 13/16] integration with CADT --- ide/web/lib/mobile/deploy.dart | 59 +++++++------------------------- ide/web/lib/workspace_utils.dart | 27 --------------- ide/web/spark.dart | 10 +----- 3 files changed, 13 insertions(+), 83 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index f6e45ab8a..d82bcfa6d 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -13,6 +13,7 @@ import 'dart:convert'; import 'package:chrome/chrome_app.dart' as chrome; import 'package:chrome_net/tcp.dart'; import 'package:logging/logging.dart'; +import 'package:crypto/crypto.dart' as crypto; import 'adb.dart'; import 'adb_client_tcp.dart'; @@ -349,12 +350,13 @@ abstract class AbstractDeployer { void _doWhenComplete(); Future sleep1() { - return new Future.delayed(const Duration(seconds: 10), () => "1"); + return new Future.delayed(const Duration(seconds: 3), () => "1"); } Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { List httpRequest; List ad; + Map signInfo = new Map(); httpRequest = _buildAssetManifestRequest(_getTarget()); return _setTimeout(_pushRequestToDevice(httpRequest, REGULAR_REQUEST_TIMEOUT)) @@ -376,54 +378,17 @@ abstract class AbstractDeployer { return _expectHttpOkResponse(msg); }).then((String response) { _updateContainerEtag(response); - return archiveDataForBuild(appContainer, appInfo); - }).then((List archivedData) { return sleep1(); }).then((_) { + return appInfo.publicKey.readBytes(); + }).then((chrome.ArrayBuffer data) { + signInfo['publicKeyData'] = crypto.CryptoUtils.bytesToBase64(data.getBytes()); + return appInfo.privateKey.readBytes(); + }).then((chrome.ArrayBuffer data) { + signInfo['privateKeyData'] = crypto.CryptoUtils.bytesToBase64(data.getBytes()); + signInfo['keyPassword'] = appInfo.keyPassword; + print(appInfo.keyPassword); - Map signInfo = new Map(); - - signInfo['storePassword']= 'android'; - signInfo['keyAlias']= 'AndroidDebugKey'; - signInfo['keyPassword'] = 'android'; - signInfo['storeData']="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"; httpRequest = _makeBuildRequest(_getTarget(), JSON.encode(signInfo).codeUnits); //TODO(albualexandru): make the request and save the file return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); @@ -613,7 +578,7 @@ class LiveDeployManager { } class MobileBuildInfo { - Map mobileAppManifest = {}; chrome.ChromeFileEntry publicKey; chrome.ChromeFileEntry privateKey; + String keyPassword; } diff --git a/ide/web/lib/workspace_utils.dart b/ide/web/lib/workspace_utils.dart index c9a5fb597..d2a5b99e3 100644 --- a/ide/web/lib/workspace_utils.dart +++ b/ide/web/lib/workspace_utils.dart @@ -15,7 +15,6 @@ import 'package_mgmt/bower.dart'; import 'package_mgmt/bower_properties.dart'; import 'package_mgmt/pub.dart'; import 'workspace.dart'; -import 'mobile/deploy.dart'; Future archiveContainer(Container container, [bool addZipManifest = false]) { archive.Archive arch = new archive.Archive(); @@ -30,32 +29,6 @@ Future archiveContainer(Container container, [bool addZipManifest = false]) { }); } -Future archiveDataForBuild(Container container, - MobileBuildInfo appData) { - String appJson = JSON.encode(appData.mobileAppManifest); - archive.ZipEncoder encoder = new archive.ZipEncoder(); - - archive.Archive appInfo = new archive.Archive(); - - appInfo.addFile(new archive.ArchiveFile('app.json', - appJson.codeUnits.length, - appJson.codeUnits)); - - return appData.publicKey.readBytes().then((chrome.ArrayBuffer bytes) { - appInfo.addFile(new archive.ArchiveFile(appData.publicKey.name, - bytes.getBytes().length, - bytes.getBytes())); - return appData.privateKey.readBytes().then((chrome.ArrayBuffer bytes) { - appInfo.addFile(new archive.ArchiveFile(appData.privateKey.name, - bytes.getBytes().length, - bytes.getBytes())); - return new archive.ZipEncoder().encode(appInfo); - }); - }); -} - - - /// The [toAddList] List contains the files that need to be mandatory /// pushed to the device Future archiveModifiedFilesInContainer(Container container, [bool addZipManifest = false, diff --git a/ide/web/spark.dart b/ide/web/spark.dart index 2a6cd4025..db36526a2 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2211,7 +2211,6 @@ class BuildApkAction extends SparkActionWithProgressDialog { void _invoke([context]) { - print("test"); if (context == null) { _resource = spark.focusManager.currentResource; } else { @@ -2268,14 +2267,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { _buildButton.disabled = true; _buildButton.deliverChanges(); - //build the app.json - - _appInfo.mobileAppManifest["appName"] = _appNameElement.value; - _appInfo.mobileAppManifest["packageName"] = _packageNameElement.value; - _appInfo.mobileAppManifest["versionName"] = _versionNameElement.value; - _appInfo.mobileAppManifest["keyPassword"] = _privatePasswordElement.value; - _appInfo.mobileAppManifest["publicKeyName"] = _appInfo.publicKey.name; - _appInfo.mobileAppManifest["privateKeyName"] = _appInfo.privateKey.name; + _appInfo.keyPassword = _privatePasswordElement.value; _monitor = new ProgressMonitorImpl(this); From 11bc0d10b4f13ace860cc61a8bbf7490299a3759 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 2 Oct 2014 14:26:16 -0700 Subject: [PATCH 14/16] cleaned the code --- ide/web/lib/mobile/deploy.dart | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index d82bcfa6d..8e07a7b0b 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -355,7 +355,6 @@ abstract class AbstractDeployer { Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { List httpRequest; - List ad; Map signInfo = new Map(); httpRequest = _buildAssetManifestRequest(_getTarget()); @@ -371,7 +370,6 @@ abstract class AbstractDeployer { }).then((_) { return archiveModifiedFilesInContainer(appContainer, true, []) .then((List archivedData) { - ad = archivedData; httpRequest = _buildPushRequest(_getTarget(), archivedData); return _setTimeout(_pushRequestToDevice(httpRequest, PUSH_REQUEST_TIMEOUT)); }).then((msg) { @@ -387,25 +385,13 @@ abstract class AbstractDeployer { }).then((chrome.ArrayBuffer data) { signInfo['privateKeyData'] = crypto.CryptoUtils.bytesToBase64(data.getBytes()); signInfo['keyPassword'] = appInfo.keyPassword; - print(appInfo.keyPassword); httpRequest = _makeBuildRequest(_getTarget(), JSON.encode(signInfo).codeUnits); - //TODO(albualexandru): make the request and save the file return _setTimeout(_pushRequestToDevice(httpRequest, BUILD_REQUEST_TIMEOUT)); - //return new Future.value("bla"); }).then((msg) { return _expectHttpOkResponse(msg); }).then((String response) { - print(response); - //need to prompt for save as to save the APK - chrome.ChooseEntryOptions options = new chrome.ChooseEntryOptions( - type: chrome.ChooseEntryType.SAVE_FILE); - return chrome.fileSystem.chooseEntry(options).then( - (chrome.ChooseEntryResult res) { - chrome.ChromeFileEntry r = res.entry; - r.writeBytes(new chrome.ArrayBuffer.fromBytes(ad)); return new Future.error("Not implemented"); - }); }); }).whenComplete(() { _doWhenComplete(); From 2966e8872cd7cad751cc8cfb0d8b05e1e8df0754 Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Thu, 2 Oct 2014 14:27:33 -0700 Subject: [PATCH 15/16] cleaned the code --- ide/web/lib/mobile/deploy.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ide/web/lib/mobile/deploy.dart b/ide/web/lib/mobile/deploy.dart index 8e07a7b0b..b7da7311c 100644 --- a/ide/web/lib/mobile/deploy.dart +++ b/ide/web/lib/mobile/deploy.dart @@ -349,10 +349,6 @@ abstract class AbstractDeployer { /// that the used resources are disposed void _doWhenComplete(); - Future sleep1() { - return new Future.delayed(const Duration(seconds: 3), () => "1"); - } - Future build(ProgressMonitor monitor, MobileBuildInfo appInfo) { List httpRequest; Map signInfo = new Map(); @@ -376,8 +372,6 @@ abstract class AbstractDeployer { return _expectHttpOkResponse(msg); }).then((String response) { _updateContainerEtag(response); - return sleep1(); - }).then((_) { return appInfo.publicKey.readBytes(); }).then((chrome.ArrayBuffer data) { signInfo['publicKeyData'] = crypto.CryptoUtils.bytesToBase64(data.getBytes()); From fd8fd04a723d3633f9115851388c9a13dd7f4cdc Mon Sep 17 00:00:00 2001 From: Alexandru Albu Date: Fri, 3 Oct 2014 09:41:16 -0700 Subject: [PATCH 16/16] review changes --- ide/web/spark.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/web/spark.dart b/ide/web/spark.dart index db36526a2..2e7c06285 100644 --- a/ide/web/spark.dart +++ b/ide/web/spark.dart @@ -2283,7 +2283,7 @@ class BuildApkAction extends SparkActionWithProgressDialog { return useAdb ? deployer.buildWithAdb(_monitor) : deployer.pushToHost(url, _monitor); }); - _monitor.runCancellableFuture(f).then((_) { + _monitor.runCancellableFuture(f).then((_) { _hide(); spark.showSuccessMessage('Successfully built'); }).catchError((e) {