You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/10/25 03:26:19 UTC
[01/17] git commit: Add filesystem location to
config.xml
Repository: cordova-app-harness
Updated Branches:
refs/heads/master 1ddda0fcd -> 54cd7bbaa
Add filesystem location <preferences> to config.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/5b77a1cb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/5b77a1cb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/5b77a1cb
Branch: refs/heads/master
Commit: 5b77a1cb4b2540cbc4c1af10b4284eaad58c8a0f
Parents: 1ddda0f
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Sep 25 16:02:31 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:42:39 2014 -0400
----------------------------------------------------------------------
template-overrides/config.xml | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/5b77a1cb/template-overrides/config.xml
----------------------------------------------------------------------
diff --git a/template-overrides/config.xml b/template-overrides/config.xml
index 5eb4f0d..c5e52c9 100644
--- a/template-overrides/config.xml
+++ b/template-overrides/config.xml
@@ -21,4 +21,8 @@
<name>{NAME}</name>
<content src="cdvah/harnessmenu.html" />
<access origin="*" />
+ <preference name="webView" value="org.apache.cordova.AndroidWebView" />
+ <preference name="android-minSdkVersion" value="14" />
+ <preference name="iosPersistentFileLocation" value="Library" />
+ <preference name="AndroidPersistentFileLocation" value="Internal" />
</widget>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[10/17] git commit: Added a reload function.
Posted by ag...@apache.org.
Added a reload function.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/da46492f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/da46492f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/da46492f
Branch: refs/heads/master
Commit: da46492fc073c16858f42d1bbe6625f6c7b646a5
Parents: bc764cb
Author: Max Woghiren <ma...@gmail.com>
Authored: Mon Oct 6 15:26:33 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
AppHarnessUI/AppHarnessUI.m | 8 ++++++++
AppHarnessUI/android/AppHarnessUI.java | 21 +++++++++++++++++++++
AppHarnessUI/appharnessui.js | 4 ++++
www/cdvah/js/AppHarnessUI.js | 5 +++++
4 files changed, 38 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/AppHarnessUI.m
----------------------------------------------------------------------
diff --git a/AppHarnessUI/AppHarnessUI.m b/AppHarnessUI/AppHarnessUI.m
index 3d7dafc..f795061 100644
--- a/AppHarnessUI/AppHarnessUI.m
+++ b/AppHarnessUI/AppHarnessUI.m
@@ -128,6 +128,14 @@
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
+- (void)reload:(CDVInvokedUrlCommand*)command {
+ if (_slaveCordovaViewController == nil) {
+ NSLog(@"AppHarnessUI.reload: no url to reload");
+ } else {
+ [[_slaveCordovaViewController webView] reload];
+ }
+}
+
- (void)destroy:(CDVInvokedUrlCommand*)command {
if (_slaveCordovaViewController == nil) {
NSLog(@"AppHarnessUI.destroy: already destroyed.");
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/android/AppHarnessUI.java
----------------------------------------------------------------------
diff --git a/AppHarnessUI/android/AppHarnessUI.java b/AppHarnessUI/android/AppHarnessUI.java
index f5dadc5..7ca74a2 100644
--- a/AppHarnessUI/android/AppHarnessUI.java
+++ b/AppHarnessUI/android/AppHarnessUI.java
@@ -53,6 +53,7 @@ public class AppHarnessUI extends CordovaPlugin {
boolean slaveVisible;
CallbackContext eventsCallback;
LinearLayoutSoftKeyboardDetect layoutView;
+ String startUrl;
public boolean isSlaveVisible() {
return slaveVisible;
@@ -76,6 +77,12 @@ public class AppHarnessUI extends CordovaPlugin {
create(url, pluginIdWhitelistAsSet, callbackContext);
}
});
+ } else if ("reload".equals(action)) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ reload(callbackContext);
+ }
+ });
} else if ("destroy".equals(action)) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
@@ -122,6 +129,7 @@ public class AppHarnessUI extends CordovaPlugin {
}
private void create(String url, Set<String> pluginIdWhitelist, CallbackContext callbackContext) {
+ startUrl = url;
CordovaActivity activity = (CordovaActivity)cordova.getActivity();
if (slaveWebView != null) {
@@ -149,6 +157,18 @@ public class AppHarnessUI extends CordovaPlugin {
callbackContext.success();
}
+ private void reload(CallbackContext callbackContext) {
+ if (slaveWebView == null) {
+ Log.w(LOG_TAG, "reload: no webview exists");
+ } else if (startUrl == null) {
+ Log.w(LOG_TAG, "reload: no recorded start url");
+ } else {
+ slaveWebView.clearCache(true);
+ slaveWebView.loadUrl(startUrl);
+ }
+ callbackContext.success();
+ }
+
private void destroy(CallbackContext callbackContext) {
if (slaveWebView == null) {
Log.w(LOG_TAG, "destroy: already destroyed");
@@ -162,6 +182,7 @@ public class AppHarnessUI extends CordovaPlugin {
slaveWebView.getView().setScaleY(1.0f);
slaveWebView.setStealTapEvents(false);
slaveVisible = false;
+ startUrl = null;
sendEvent("destroyed");
}
if (eventsCallback != null) {
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/appharnessui.js
----------------------------------------------------------------------
diff --git a/AppHarnessUI/appharnessui.js b/AppHarnessUI/appharnessui.js
index db46720..7335ffb 100644
--- a/AppHarnessUI/appharnessui.js
+++ b/AppHarnessUI/appharnessui.js
@@ -30,6 +30,10 @@ exports.create = function(url, serviceNameWhitelist, win) {
exec(win, null, 'AppHarnessUI', 'create', [url, serviceNameWhitelist]);
};
+exports.reload = function(win) {
+ exec(win, null, 'AppHarnessUI', 'reload', []);
+}
+
exports.destroy = function(win) {
exec(win, null, 'AppHarnessUI', 'destroy', []);
};
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/www/cdvah/js/AppHarnessUI.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppHarnessUI.js b/www/cdvah/js/AppHarnessUI.js
index dfd84c7..5137c83 100644
--- a/www/cdvah/js/AppHarnessUI.js
+++ b/www/cdvah/js/AppHarnessUI.js
@@ -49,6 +49,11 @@
cordova.plugins.appharnessui.destroy(deferred.resolve);
return deferred.promise;
},
+ reload: function() {
+ var deferred = $q.defer();
+ cordova.plugins.appharnessui.reload(deferred.resolve);
+ return deferred.promise;
+ },
setVisible: function(value) {
var deferred = $q.defer();
cordova.plugins.appharnessui.setVisible(value, deferred.resolve);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[12/17] git commit: Fix createproject.sh to work with hard-coded
activity.java filename
Posted by ag...@apache.org.
Fix createproject.sh to work with hard-coded activity.java filename
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/bbefd2ae
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/bbefd2ae
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/bbefd2ae
Branch: refs/heads/master
Commit: bbefd2aeb60b19e18f65f5caff3032d21a98b996
Parents: d9b8c49
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Oct 21 15:47:03 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
createproject.sh | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/bbefd2ae/createproject.sh
----------------------------------------------------------------------
diff --git a/createproject.sh b/createproject.sh
index 2e29065..ef16c40 100755
--- a/createproject.sh
+++ b/createproject.sh
@@ -114,6 +114,9 @@ set +x
if [[ "$PLATFORMS" = *android* ]]; then
echo 'var fs = require("fs");
var fname = "platforms/android/src/org/apache/appharness/CordovaAppHarness.java";
+ if (!fs.existsSync(fname)) {
+ fname = "platforms/android/src/org/apache/appharness/MainActivity.java";
+ }
var tname = "'$AH_PATH'/template-overrides/Activity.java";
var orig = fs.readFileSync(fname, "utf8");
var templ = fs.readFileSync(tname, "utf8");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[05/17] git commit: Prevented launching an app that hasn't changed.
Posted by ag...@apache.org.
Prevented launching an app that hasn't changed.
Also added an option to force a launch. Sometimes, such as when an app is pushed for the first time, we want to launch the app even if it hasn't changed since the last time it was launched (in a previous session).
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/6ce27408
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/6ce27408
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/6ce27408
Branch: refs/heads/master
Commit: 6ce27408c50bea9eb123fb883ebcb593f8aa0444
Parents: 4c0ac66
Author: Max Woghiren <ma...@gmail.com>
Authored: Tue Sep 30 15:01:06 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:44:03 2014 -0400
----------------------------------------------------------------------
.../node_modules/cordova-harness-client/pushsession.js | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/6ce27408/harness-push/node_modules/cordova-harness-client/pushsession.js
----------------------------------------------------------------------
diff --git a/harness-push/node_modules/cordova-harness-client/pushsession.js b/harness-push/node_modules/cordova-harness-client/pushsession.js
index d878198..05681b2 100644
--- a/harness-push/node_modules/cordova-harness-client/pushsession.js
+++ b/harness-push/node_modules/cordova-harness-client/pushsession.js
@@ -217,7 +217,7 @@ PushSession.prototype.initialize = function(opts) {
});
};
-PushSession.prototype.push = function() {
+PushSession.prototype.push = function(forceLaunch) {
var self = this;
return Q.when(this.platformId_ || this.initialize())
.then(function() {
@@ -234,7 +234,7 @@ PushSession.prototype.push = function() {
var pushList = buildPushList(self.assetManifest_ || {}, assetMap);
if (deleteList.length === 0 && pushList.length === 0) {
console.log('Application already up-to-date.');
- return;
+ return false; // appChanged
}
var p;
// TODO: It might be faster to use Zip even when some files exist.
@@ -245,9 +245,13 @@ PushSession.prototype.push = function() {
}
return p.then(function() {
return self.deleteFiles_(deleteList);
+ }).then(function() {
+ return true; // appChanged
});
- }).then(function() {
- if (self.launchAfterPush) {
+ }).then(function(appChanged) {
+ // Determine whether we should launch the app.
+ shouldLaunch = forceLaunch || (self.launchAfterPush && appChanged);
+ if (shouldLaunch) {
return self.harnessClient_.launch(self.appId_);
}
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[17/17] git commit: Add a /getfile endpoing to HarnessServer + Fixes
for pipeFileToResponse.
Posted by ag...@apache.org.
Add a /getfile endpoing to HarnessServer + Fixes for pipeFileToResponse.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/bc764cb5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/bc764cb5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/bc764cb5
Branch: refs/heads/master
Commit: bc764cb59a40390fdd610e3b778c1413946ea16a
Parents: c7bb0ef
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Oct 3 13:00:17 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/HarnessServer.js | 45 ++++++++++++++++++++++++++++++++-
www/cdvah/js/ResourcesLoader.js | 48 ++++++++++++++++++++++++++++++++++--
2 files changed, 90 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/bc764cb5/www/cdvah/js/HarnessServer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/HarnessServer.js b/www/cdvah/js/HarnessServer.js
index fe87938..6085789 100644
--- a/www/cdvah/js/HarnessServer.js
+++ b/www/cdvah/js/HarnessServer.js
@@ -106,6 +106,32 @@
return req.readChunk().then(handleChunk);
}
+ function pipeFileToResponse(srcUrl, resp) {
+ // TODO: HttpServer needs to expose a "readyForWrite" event, and we need to use FileReader
+ // so that we can stream this.
+ // Might also be able to get the file as a Blob via an XHR,
+ // but that doesn't help us to send it to socket (needs an arraybuffer).
+ return ResourcesLoader.resolveFileAsBlob(srcUrl)
+ .then(function(blob) {
+ resp.headers['Content-Type'] = blob.type || 'application/octet-stream';
+ resp.headers['Content-Length'] = '' + blob.size;
+ var readFunc = ResourcesLoader.readBlobInChunks(blob);
+ return readFunc()
+ .then(function writeChunk(arrayBuffer) {
+ // End of file.
+ if (!arrayBuffer) {
+ resp.close();
+ return;
+ }
+ // TODO: Read next chunk while writing current chunk.
+ return resp.writeChunk(arrayBuffer)
+ .then(function() {
+ return readFunc().then(writeChunk);
+ });
+ });
+ });
+ }
+
function handleExec(req, resp) {
var js = req.getQueryParam('code');
return AppHarnessUI.evalJs(js)
@@ -335,6 +361,22 @@
});
}
+ function handleGetFile(req, resp) {
+ var appId = req.getQueryParam('appId');
+ var path = req.getQueryParam('path');
+ // Strip beginning /, and any ../ (attempt at security)
+ path = path.replace(/^\/+/, '').replace(/\/\.+\//g, '/');
+
+ return AppsService.getAppById(appId)
+ .then(function(app) {
+ var filePath = app.directoryManager.rootURL + path;
+ return pipeFileToResponse(filePath, resp)
+ .then(null, function() {
+ throw new HttpServer.ResponseException(404, 'File not found. Tried: ' + filePath);
+ });
+ });
+ }
+
function handleInfo(req, resp) {
var activeApp = AppsService.getActiveApp();
var json = {
@@ -364,7 +406,8 @@
.addRoute('/deletefiles', ensureMethodDecorator('POST', handleDeleteFiles))
.addRoute('/putfile', ensureMethodDecorator('PUT', handlePutFile))
.addRoute('/zippush', ensureMethodDecorator('POST', handleZipPush))
- .addRoute('/deleteapp', ensureMethodDecorator('POST', handleDeleteApp));
+ .addRoute('/deleteapp', ensureMethodDecorator('POST', handleDeleteApp))
+ .addRoute('/getfile', ensureMethodDecorator('GET', handleGetFile));
return server.start();
}
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/bc764cb5/www/cdvah/js/ResourcesLoader.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/ResourcesLoader.js b/www/cdvah/js/ResourcesLoader.js
index b3e582a..f7c58e8 100644
--- a/www/cdvah/js/ResourcesLoader.js
+++ b/www/cdvah/js/ResourcesLoader.js
@@ -57,6 +57,12 @@
return deferred.promise;
}
+ function filePromisified(entry) {
+ var deferred = $q.defer();
+ entry.file(deferred.resolve, deferred.reject);
+ return deferred.promise;
+ }
+
function dirName(path) {
return path.replace(/\/[^\/]+\/?$/, '/');
}
@@ -121,6 +127,25 @@
});
}
+ function createFileReaderGenerator(blob, chunkSize) {
+ var reader = new FileReader();
+ var curOffset = 0;
+ // Returns a promise for the next chunk.
+ return function() {
+ if (curOffset >= blob.size) {
+ return $q.when(null);
+ }
+ var deferred = $q.defer();
+ reader.onloadend = function() {
+ deferred.resolve(reader.result);
+ };
+ var curBlob = blob.slice(curOffset, curOffset + chunkSize);
+ curOffset += chunkSize;
+ reader.readAsArrayBuffer(curBlob);
+ return deferred.promise;
+ };
+ }
+
var ResourcesLoader = {
createTmpFileUrl: function(extension) {
return TEMP_DIR + Math.floor(Math.random()* 100000000) + (extension || '');
@@ -143,13 +168,32 @@
return ResourcesLoader.xhrGet(url);
},
+ //returns a promise with the contents of the file
+ readBinaryFileContents: function(url) {
+ return ResourcesLoader.xhrGet(url, false, true);
+ },
+
+ resolveFileAsBlob: function(url) {
+ return resolveURL(url)
+ .then(function(fileEntry) {
+ return filePromisified(fileEntry);
+ });
+ },
+
+ //returns a promise with a function that returns promises of array buffers.
+ readBlobInChunks: function(blob, chunkSize) {
+ chunkSize = chunkSize || 256 * 1024;
+ return createFileReaderGenerator(blob, chunkSize);
+ },
+
//returns a promise with the json contents of the file
readJSONFileContents: function(url) {
return ResourcesLoader.xhrGet(url, true);
},
- xhrGet: function(url, json) {
- var opts = json ? null : {transformResponse: []};
+ xhrGet: function(url, json, binary) {
+ var opts = binary ? {responseType: 'arraybuffer'} :
+ json ? null : {transformResponse: []};
return $http.get(url, opts)
.then(function(response, status) {
if (!response) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[16/17] git commit: Enable cordova-android's App plugin (e.g.
navigator.app.exitApp())
Posted by ag...@apache.org.
Enable cordova-android's App plugin (e.g. navigator.app.exitApp())
fixes MobileChromeApps/mobile-chrome-apps#383
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/dc55639a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/dc55639a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/dc55639a
Branch: refs/heads/master
Commit: dc55639a0d1c0454097024c6f94ef18ef173101b
Parents: 7f7279a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Oct 24 09:25:11 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
AppHarnessUI/android/AppHarnessUI.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/dc55639a/AppHarnessUI/android/AppHarnessUI.java
----------------------------------------------------------------------
diff --git a/AppHarnessUI/android/AppHarnessUI.java b/AppHarnessUI/android/AppHarnessUI.java
index 48dd225..2975bf5 100644
--- a/AppHarnessUI/android/AppHarnessUI.java
+++ b/AppHarnessUI/android/AppHarnessUI.java
@@ -238,6 +238,9 @@ public class AppHarnessUI extends CordovaPlugin {
}
}
slaveWebView.getPluginManager().setPluginEntries(pluginEntries);
+ // This is added by cordova-android in code, so we need to re-add it likewise.
+ // Note that we re-route navigator.app.exitApp() in JS to close the webview rather than close the Activity.
+ slaveWebView.getPluginManager().addService("App", "org.apache.cordova.CoreAndroid");
}
private void initWebView(final CustomCordovaWebView newWebView, Set<String> pluginIdWhitelist) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[15/17] git commit: Removed unnecessary checks.
Posted by ag...@apache.org.
Removed unnecessary checks.
By default, on Android, if a "system" webview type is specified, then we use the system webview; anything else and we use Crosswalk.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/d9b8c499
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/d9b8c499
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/d9b8c499
Branch: refs/heads/master
Commit: d9b8c499e918f8aa62e454ba2b9802664308af65
Parents: 634b3c4
Author: Max Woghiren <ma...@gmail.com>
Authored: Thu Oct 9 11:39:30 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
AppHarnessUI/appharnessui.js | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/d9b8c499/AppHarnessUI/appharnessui.js
----------------------------------------------------------------------
diff --git a/AppHarnessUI/appharnessui.js b/AppHarnessUI/appharnessui.js
index 0a19dcf..7d26496 100644
--- a/AppHarnessUI/appharnessui.js
+++ b/AppHarnessUI/appharnessui.js
@@ -31,9 +31,6 @@ exports.create = function(url, serviceNameWhitelist, win) {
};
exports.reload = function(url, serviceNameWhitelist, webViewType, win) {
- if (webViewType != "system" && webViewType != "crosswalk") {
- return;
- }
exec(win, null, 'AppHarnessUI', 'reload', [url, serviceNameWhitelist, webViewType]);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[04/17] git commit: Delete manifest.json if it causes an exception
Posted by ag...@apache.org.
Delete manifest.json if it causes an exception
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/4c0ac66f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/4c0ac66f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/4c0ac66f
Branch: refs/heads/master
Commit: 4c0ac66f83a1eb5be9ce5c54b5f871b0273077a2
Parents: b0ec606
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 26 16:19:12 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:43:37 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/DirectoryManager.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/4c0ac66f/www/cdvah/js/DirectoryManager.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/DirectoryManager.js b/www/cdvah/js/DirectoryManager.js
index da39c82..15484e3 100644
--- a/www/cdvah/js/DirectoryManager.js
+++ b/www/cdvah/js/DirectoryManager.js
@@ -82,8 +82,15 @@
}
this._assetManifestEtag = Math.floor(Math.random() * 0xFFFFFFFF);
this._lazyWriteAssetManifest();
+ var self = this;
if (etag !== null && this.onFileAdded) {
- return this.onFileAdded(relativePath, etag);
+ return this.onFileAdded(relativePath, etag)
+ .then(null, function(err) {
+ // If there was an error with the file, delete it so that clients will
+ // send it again.
+ return self.deleteFile(relativePath)
+ .then(function() { throw err; }, function() { throw err; });
+ });
}
};
@@ -133,10 +140,10 @@
DirectoryManager.prototype.deleteFile = function(relativePath) {
if (!this._assetManifest[relativePath]) {
console.warn('Tried to delete non-existing file: ' + relativePath);
- } else {
- this._updateManifest(relativePath, null);
- return ResourcesLoader.delete(this.rootURL + relativePath);
+ return $q.when();
}
+ this._updateManifest(relativePath, null);
+ return ResourcesLoader.delete(this.rootURL + relativePath);
};
return DirectoryManager;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[08/17] git commit: Stopped destroying the webview on every launch.
Posted by ag...@apache.org.
Stopped destroying the webview on every launch.
If we're relaunching the same app, we reload the webview. This handles the most annoying `cca push --watch` case.
If a new app is being launched, though, the webview is still destroyed and recreated (for now).
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/7c884d15
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/7c884d15
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/7c884d15
Branch: refs/heads/master
Commit: 7c884d15369dd33897db72ef94f80c75ffd55a63
Parents: da46492
Author: Max Woghiren <ma...@gmail.com>
Authored: Mon Oct 6 15:34:11 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/AppsService.js | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/7c884d15/www/cdvah/js/AppsService.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppsService.js b/www/cdvah/js/AppsService.js
index 14b8c5c..9c25391 100644
--- a/www/cdvah/js/AppsService.js
+++ b/www/cdvah/js/AppsService.js
@@ -139,8 +139,21 @@
},
launchApp : function(installer) {
- return AppsService.quitApp()
+ // Determine whether we're relaunching the same app as is already active.
+ var relaunch = activeInstaller && activeInstaller.appId;
+ relaunch = installer && installer.appId;
+ relaunch = relaunch && (activeInstaller.appId === installer.appId);
+
+ return $q.when()
.then(function() {
+ // If we're relaunching the active app, move on.
+ // Otherwise, quit the active app.
+ if (relaunch) {
+ return $q.when();
+ } else {
+ return AppsService.quitApp();
+ }
+ }).then(function() {
activeInstaller = installer;
return installer.launch();
}).then(function(launchUrl) {
@@ -152,7 +165,14 @@
return installer.getPluginMetadata();
}).then(function(pluginMetadata) {
$location.path('/inappmenu');
- return AppHarnessUI.create(launchUrl, pluginMetadata);
+ // If we're relaunching the active app, just reload the existing webview.
+ // Otherwise, create a new one.
+ // TODO(maxw): Use the existing webview all the time.
+ if (relaunch) {
+ return AppHarnessUI.reload();
+ } else {
+ return AppHarnessUI.create(launchUrl, pluginMetadata);
+ }
}).then(function() {
if (AppsService.onAppListChange) {
AppsService.onAppListChange();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[11/17] git commit: Change config.xml-derived properties in installer
into getters
Posted by ag...@apache.org.
Change config.xml-derived properties in installer into getters
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/c7bb0ef1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/c7bb0ef1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/c7bb0ef1
Branch: refs/heads/master
Commit: c7bb0ef1cdbb2ca63eb239458c60491beb4dead4
Parents: 9f5a427
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Oct 3 12:56:08 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/Installer.js | 102 +++++++++++++++++++++++++++---------
www/cdvah/views/inappmenu.html | 2 +-
www/cdvah/views/list.html | 3 +-
3 files changed, 80 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/c7bb0ef1/www/cdvah/js/Installer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/Installer.js b/www/cdvah/js/Installer.js
index 44d5d07..fb00d07 100644
--- a/www/cdvah/js/Installer.js
+++ b/www/cdvah/js/Installer.js
@@ -28,13 +28,11 @@
Installer.prototype.init = function(installPath, /* optional */ appId) {
var ret = this;
ret.appType = ret.constructor.type;
- ret.updatingStatus = null;
+ ret.appId = appId || 'default'; // Stored in apps.json. May be different from id within config.xml.
ret.lastUpdated = null;
- // Asset manifest is a cache of what files have been downloaded along with their etags.
- ret.appId = null; // Read from config.xml
- ret.appName = null; // Read from config.xml
- ret.iconURL = null; // Read from config.xml
- ret.startPage = null; // Read from config.xml
+ // Derived values:
+ ret.updatingStatus = null;
+ ret.configXmlDom = null; // Read from config.xml
ret.plugins = {}; // Read from orig-cordova_plugins.js
ret.appId = appId;
ret.directoryManager = new DirectoryManager();
@@ -50,7 +48,7 @@
return this.init(json['installPath'], json['appId'])
.then(function(ret) {
ret.lastUpdated = json['lastUpdated'] && new Date(json['lastUpdated']);
- return self.readConfigXml();
+ return self.readConfigXml_();
});
};
@@ -63,27 +61,77 @@
};
};
- Installer.prototype.readConfigXml = function() {
+ Installer.prototype.readConfigXml_ = function() {
var self = this;
return ResourcesLoader.readFileContents(this.directoryManager.rootURL + 'config.xml')
.then(function(configStr) {
- function lastEl(els) {
- return els[els.length - 1];
- }
- var xmlDoc = new DOMParser().parseFromString(configStr, 'text/xml');
- self.appId = xmlDoc.firstChild.getAttribute('id');
- var el = lastEl(xmlDoc.getElementsByTagName('content'));
- self.startPage = el ? el.getAttribute('src') : 'index.html';
- el = lastEl(xmlDoc.getElementsByTagName('icon'));
- self.iconURL = el ? el.getAttribute('src') : null;
- if (self.iconURL) {
- self.iconURL = self.directoryManager.rootURL + self.iconURL;
- }
- el = lastEl(xmlDoc.getElementsByTagName('name'));
- self.appName = el ? el.textContent : null;
+ self.configXmlDom = new DOMParser().parseFromString(configStr, 'text/xml');
});
};
+ function lastEl(els) {
+ return els[els.length - 1];
+ }
+
+ Installer.prototype.getAppName = function() {
+ if (!this.configXmlDom) {
+ return '';
+ }
+ var el = lastEl(this.configXmlDom.getElementsByTagName('name'));
+ return el && el.textContent;
+ };
+
+ Installer.prototype.getIconUrl = function() {
+ if (!this.configXmlDom) {
+ return '';
+ }
+ var el = lastEl(this.configXmlDom.getElementsByTagName('icon'));
+ var ret = el && el.getAttribute('src');
+ // Don't set icon until the file exists.
+ if (!ret || !this.directoryManager.getAssetEtag(ret)) {
+ return '';
+ }
+ ret = this.directoryManager.rootURL + ret;
+ return ret;
+ };
+
+ Installer.prototype.getStartPage = function() {
+ var el = lastEl(this.configXmlDom.getElementsByTagName('content'));
+ var ret = el ? el.getAttribute('src') : 'index.html';
+ return ret;
+ };
+
+ Installer.prototype.getVersion = function() {
+ if (!this.configXmlDom) {
+ return '';
+ }
+ var widgetEl = this.configXmlDom.lastChild;
+ return widgetEl.getAttribute('version');
+ };
+
+ Installer.prototype.getConfigXmlId = function() {
+ if (!this.configXmlDom) {
+ return '';
+ }
+ var widgetEl = this.configXmlDom.lastChild;
+ return widgetEl.getAttribute('id');
+ };
+
+ Installer.prototype.getAndroidVersionCode = function() {
+ // copied from android_parser.js
+ function defaultVersionCode(version) {
+ var nums = version.split('-')[0].split('.').map(Number);
+ var versionCode = nums[0] * 10000 + nums[1] * 100 + nums[2];
+ return versionCode;
+ }
+
+ var versionCode = this.configXmlDom.lastChild.getAttribute('android-versionCode');
+ if (versionCode) {
+ return +versionCode;
+ }
+ return defaultVersionCode(this.getVersion() || '0.0.1');
+ };
+
Installer.prototype.updateCordovaPluginsFile = function(etag) {
var self = this;
return $q.when(self.getPluginMetadata())
@@ -97,7 +145,7 @@
Installer.prototype.onFileAdded = function(path) {
if (path == 'config.xml') {
- return this.readConfigXml();
+ return this.readConfigXml_();
}
};
@@ -118,14 +166,18 @@
return $q.when();
};
+ Installer.prototype.getWwwDir = function() {
+ return this.directoryManager.rootURL + 'www/';
+ };
+
Installer.prototype.launch = function() {
var self = this;
return $q.when(this._prepareForLaunch())
.then(function() {
var urlutil = cordova.require('cordova/urlutil');
var harnessWwwUrl = urlutil.makeAbsolute(location.pathname).replace(/\/[^\/]*\/[^\/]*$/, '/');
- var appWwwUrl = self.directoryManager.rootURL + 'www/';
- var startLocation = urlutil.makeAbsolute(self.startPage).replace('/cdvah/', '/');
+ var appWwwUrl = self.getWwwDir();
+ var startLocation = urlutil.makeAbsolute(self.getStartPage()).replace('/cdvah/', '/');
var realStartLocation = startLocation.replace(harnessWwwUrl, appWwwUrl);
var useRemapper = platformId == 'android';
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/c7bb0ef1/www/cdvah/views/inappmenu.html
----------------------------------------------------------------------
diff --git a/www/cdvah/views/inappmenu.html b/www/cdvah/views/inappmenu.html
index 2b0fd4c..c520b23 100644
--- a/www/cdvah/views/inappmenu.html
+++ b/www/cdvah/views/inappmenu.html
@@ -17,7 +17,7 @@
under the License.
-->
<div class="in-app-menu-container">
- <h1>{{app.appName || app.appId}}</h1>
+ <h1>{{app.getAppName() || app.getConfigXmlId() || app.appId}}</h1>
<button ng-click="restartApp()">Restart App</button><br>
<button ng-click="quitApp()">Quit App</button>
</div>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/c7bb0ef1/www/cdvah/views/list.html
----------------------------------------------------------------------
diff --git a/www/cdvah/views/list.html b/www/cdvah/views/list.html
index ac4c1df..7d74ad2 100644
--- a/www/cdvah/views/list.html
+++ b/www/cdvah/views/list.html
@@ -23,7 +23,7 @@
<h3 class="topcoat-list__header">Installed Apps</h3>
<ul class="topcoat-list">
<li class="topcoat-list__item" ng-repeat="app in appList">
- <div>{{app.appId}}</div>
+ <div>{{app.getAppName() || app.getConfigXmlId() || app.appId}}</div>
<div ng-show="app.updatingStatus === null">Last updated: <span am-time-ago="app.lastUpdated"></span></div>
<div ng-show="app.updatingStatus !== null">Update in progress: {{app.updatingStatus}}%</div>
<div ng-show="app.plugins.missing.length + app.plugins.newer.length + app.plugins.older.length > 0">
@@ -39,6 +39,7 @@
<button ng-click="showDetails($index)">Details</button>
</li>
</ul>
+ </div>
</div>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[07/17] git commit: Fixed missing declaration.
Posted by ag...@apache.org.
Fixed missing declaration.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/9f5a4276
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/9f5a4276
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/9f5a4276
Branch: refs/heads/master
Commit: 9f5a4276489dd01a82c9b53cce7be83ac5e9d36a
Parents: 55cf7bd
Author: Max Woghiren <ma...@gmail.com>
Authored: Thu Oct 2 15:04:14 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:44:20 2014 -0400
----------------------------------------------------------------------
harness-push/node_modules/cordova-harness-client/pushsession.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9f5a4276/harness-push/node_modules/cordova-harness-client/pushsession.js
----------------------------------------------------------------------
diff --git a/harness-push/node_modules/cordova-harness-client/pushsession.js b/harness-push/node_modules/cordova-harness-client/pushsession.js
index ae5aa31..e0bc686 100644
--- a/harness-push/node_modules/cordova-harness-client/pushsession.js
+++ b/harness-push/node_modules/cordova-harness-client/pushsession.js
@@ -254,7 +254,7 @@ PushSession.prototype.push = function(forceLaunch) {
}).then(function(appChanged) {
// Determine whether we should launch the app.
// We want to launch the app if we've been told to force it or if the app has changed.
- shouldLaunch = forceLaunch || (self.launchAfterPush && appChanged);
+ var shouldLaunch = forceLaunch || (self.launchAfterPush && appChanged);
if (shouldLaunch) {
return self.harnessClient_.launch(self.appId_);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[02/17] git commit: Make ResourcesLoader functions not depend on
"this"
Posted by ag...@apache.org.
Make ResourcesLoader functions not depend on "this"
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/33fcb529
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/33fcb529
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/33fcb529
Branch: refs/heads/master
Commit: 33fcb5299d951b5f547be79a2d85f1272c34a9d0
Parents: 5b77a1c
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 26 16:03:27 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:42:56 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/ResourcesLoader.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/33fcb529/www/cdvah/js/ResourcesLoader.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/ResourcesLoader.js b/www/cdvah/js/ResourcesLoader.js
index 2376ed9..b3e582a 100644
--- a/www/cdvah/js/ResourcesLoader.js
+++ b/www/cdvah/js/ResourcesLoader.js
@@ -121,7 +121,7 @@
});
}
- return {
+ var ResourcesLoader = {
createTmpFileUrl: function(extension) {
return TEMP_DIR + Math.floor(Math.random()* 100000000) + (extension || '');
},
@@ -140,12 +140,12 @@
//returns a promise with the contents of the file
readFileContents: function(url) {
- return this.xhrGet(url);
+ return ResourcesLoader.xhrGet(url);
},
//returns a promise with the json contents of the file
readJSONFileContents: function(url) {
- return this.xhrGet(url, true);
+ return ResourcesLoader.xhrGet(url, true);
},
xhrGet: function(url, json) {
@@ -234,5 +234,6 @@
});
}
};
+ return ResourcesLoader;
}]);
})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[13/17] git commit: Updated webview reload to take arguments.
Posted by ag...@apache.org.
Updated webview reload to take arguments.
It now takes and obeys the same arguments as `create` does...
...except Android doesn't switch webview types yet.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/634b3c4e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/634b3c4e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/634b3c4e
Branch: refs/heads/master
Commit: 634b3c4e3775577bdf9b9b183076701f976aa554
Parents: 7c884d1
Author: Max Woghiren <ma...@gmail.com>
Authored: Mon Oct 6 16:50:32 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
AppHarnessUI/AppHarnessUI.m | 8 +++++--
AppHarnessUI/android/AppHarnessUI.java | 37 ++++++++++++++++++-----------
AppHarnessUI/appharnessui.js | 9 ++++---
www/cdvah/js/AppHarnessUI.js | 5 ++--
www/cdvah/js/AppsService.js | 9 +++----
5 files changed, 43 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/634b3c4e/AppHarnessUI/AppHarnessUI.m
----------------------------------------------------------------------
diff --git a/AppHarnessUI/AppHarnessUI.m b/AppHarnessUI/AppHarnessUI.m
index f795061..006f2c1 100644
--- a/AppHarnessUI/AppHarnessUI.m
+++ b/AppHarnessUI/AppHarnessUI.m
@@ -129,10 +129,14 @@
}
- (void)reload:(CDVInvokedUrlCommand*)command {
+ NSString* url = [command argumentAtIndex:0];
if (_slaveCordovaViewController == nil) {
- NSLog(@"AppHarnessUI.reload: no url to reload");
+ NSLog(@"AppHarnessUI.reload: no webview exists");
} else {
- [[_slaveCordovaViewController webView] reload];
+ [_slaveCordovaViewController setStartPage:url];
+ NSURL *urlObj = [NSURL URLWithString:url];
+ NSURLRequest *requestObj = [NSURLRequest requestWithURL:urlObj];
+ [[_slaveCordovaViewController webView] loadRequest:requestObj];
}
}
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/634b3c4e/AppHarnessUI/android/AppHarnessUI.java
----------------------------------------------------------------------
diff --git a/AppHarnessUI/android/AppHarnessUI.java b/AppHarnessUI/android/AppHarnessUI.java
index 7ca74a2..48dd225 100644
--- a/AppHarnessUI/android/AppHarnessUI.java
+++ b/AppHarnessUI/android/AppHarnessUI.java
@@ -53,7 +53,6 @@ public class AppHarnessUI extends CordovaPlugin {
boolean slaveVisible;
CallbackContext eventsCallback;
LinearLayoutSoftKeyboardDetect layoutView;
- String startUrl;
public boolean isSlaveVisible() {
return slaveVisible;
@@ -67,20 +66,19 @@ public class AppHarnessUI extends CordovaPlugin {
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
if ("create".equals(action)) {
final String url = args.getString(0);
- JSONArray pluginIdWhitelist = args.getJSONArray(1);
- final Set<String> pluginIdWhitelistAsSet = new HashSet<String>(pluginIdWhitelist.length());
- for (int i = 0; i < pluginIdWhitelist.length(); ++i) {
- pluginIdWhitelistAsSet.add(pluginIdWhitelist.getString(i));
- }
+ final Set<String> pluginIdWhitelistAsSet = jsonArrayToSet(args.getJSONArray(1));
this.cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
create(url, pluginIdWhitelistAsSet, callbackContext);
}
});
} else if ("reload".equals(action)) {
+ final String url = args.getString(0);
+ final Set<String> pluginIdWhitelistAsSet = jsonArrayToSet(args.getJSONArray(1));
+ final String webViewType = args.getString(2);
this.cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
- reload(callbackContext);
+ reload(url, pluginIdWhitelistAsSet, webViewType, callbackContext);
}
});
} else if ("destroy".equals(action)) {
@@ -111,6 +109,14 @@ public class AppHarnessUI extends CordovaPlugin {
return true;
}
+ private Set<String> jsonArrayToSet(JSONArray jsonArray) throws JSONException {
+ final Set<String> set = new HashSet<String>(jsonArray.length());
+ for (int i = 0; i < jsonArray.length(); ++i) {
+ set.add(jsonArray.getString(i));
+ }
+ return set;
+ }
+
public void sendEvent(String eventName) {
if (eventsCallback != null) {
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, eventName);
@@ -129,7 +135,6 @@ public class AppHarnessUI extends CordovaPlugin {
}
private void create(String url, Set<String> pluginIdWhitelist, CallbackContext callbackContext) {
- startUrl = url;
CordovaActivity activity = (CordovaActivity)cordova.getActivity();
if (slaveWebView != null) {
@@ -157,14 +162,14 @@ public class AppHarnessUI extends CordovaPlugin {
callbackContext.success();
}
- private void reload(CallbackContext callbackContext) {
+ private void reload(String url, Set<String> pluginIdWhitelist, String webViewType, CallbackContext callbackContext) {
if (slaveWebView == null) {
Log.w(LOG_TAG, "reload: no webview exists");
- } else if (startUrl == null) {
- Log.w(LOG_TAG, "reload: no recorded start url");
} else {
+ // TODO(maxw): If the webview type has changed, create a new webview.
+ setPluginEntries(pluginIdWhitelist);
slaveWebView.clearCache(true);
- slaveWebView.loadUrl(startUrl);
+ slaveWebView.loadUrl(url);
}
callbackContext.success();
}
@@ -182,7 +187,6 @@ public class AppHarnessUI extends CordovaPlugin {
slaveWebView.getView().setScaleY(1.0f);
slaveWebView.setStealTapEvents(false);
slaveVisible = false;
- startUrl = null;
sendEvent("destroyed");
}
if (eventsCallback != null) {
@@ -222,7 +226,7 @@ public class AppHarnessUI extends CordovaPlugin {
}
}
- private void initWebView(final CustomCordovaWebView newWebView, Set<String> pluginIdWhitelist) {
+ private void setPluginEntries(Set<String> pluginIdWhitelist) {
CordovaActivity activity = (CordovaActivity)cordova.getActivity();
ConfigXmlParser parser = new ConfigXmlParser();
// TODO: Parse the app's config.xml rather than our own config.xml.
@@ -234,7 +238,12 @@ public class AppHarnessUI extends CordovaPlugin {
}
}
slaveWebView.getPluginManager().setPluginEntries(pluginEntries);
+ }
+ private void initWebView(final CustomCordovaWebView newWebView, Set<String> pluginIdWhitelist) {
+ setPluginEntries(pluginIdWhitelist);
+
+ CordovaActivity activity = (CordovaActivity)cordova.getActivity();
if (contentView == null) {
contentView = (ViewGroup)activity.findViewById(android.R.id.content);
origMainView = contentView.getChildAt(0);
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/634b3c4e/AppHarnessUI/appharnessui.js
----------------------------------------------------------------------
diff --git a/AppHarnessUI/appharnessui.js b/AppHarnessUI/appharnessui.js
index 7335ffb..0a19dcf 100644
--- a/AppHarnessUI/appharnessui.js
+++ b/AppHarnessUI/appharnessui.js
@@ -30,9 +30,12 @@ exports.create = function(url, serviceNameWhitelist, win) {
exec(win, null, 'AppHarnessUI', 'create', [url, serviceNameWhitelist]);
};
-exports.reload = function(win) {
- exec(win, null, 'AppHarnessUI', 'reload', []);
-}
+exports.reload = function(url, serviceNameWhitelist, webViewType, win) {
+ if (webViewType != "system" && webViewType != "crosswalk") {
+ return;
+ }
+ exec(win, null, 'AppHarnessUI', 'reload', [url, serviceNameWhitelist, webViewType]);
+};
exports.destroy = function(win) {
exec(win, null, 'AppHarnessUI', 'destroy', []);
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/634b3c4e/www/cdvah/js/AppHarnessUI.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppHarnessUI.js b/www/cdvah/js/AppHarnessUI.js
index 5137c83..f16fbfb 100644
--- a/www/cdvah/js/AppHarnessUI.js
+++ b/www/cdvah/js/AppHarnessUI.js
@@ -49,9 +49,10 @@
cordova.plugins.appharnessui.destroy(deferred.resolve);
return deferred.promise;
},
- reload: function() {
+ reload: function(url, pluginMetadata, webViewType) {
var deferred = $q.defer();
- cordova.plugins.appharnessui.reload(deferred.resolve);
+ var serviceNames = createServiceNameWhitelist(pluginMetadata);
+ cordova.plugins.appharnessui.reload(url, serviceNames, webViewType, deferred.resolve);
return deferred.promise;
},
setVisible: function(value) {
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/634b3c4e/www/cdvah/js/AppsService.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppsService.js b/www/cdvah/js/AppsService.js
index 9c25391..2dd55c8 100644
--- a/www/cdvah/js/AppsService.js
+++ b/www/cdvah/js/AppsService.js
@@ -140,14 +140,15 @@
launchApp : function(installer) {
// Determine whether we're relaunching the same app as is already active.
- var relaunch = activeInstaller && activeInstaller.appId;
- relaunch = installer && installer.appId;
- relaunch = relaunch && (activeInstaller.appId === installer.appId);
+ var activeAppId = activeInstaller && activeInstaller.appId;
+ var newAppId = installer && installer.appId;
+ var relaunch = activeAppId && newAppId && activeAppId === newAppId;
return $q.when()
.then(function() {
// If we're relaunching the active app, move on.
// Otherwise, quit the active app.
+ // TODO(maxw): Determine whether we actually ever need to quit the app.
if (relaunch) {
return $q.when();
} else {
@@ -169,7 +170,7 @@
// Otherwise, create a new one.
// TODO(maxw): Use the existing webview all the time.
if (relaunch) {
- return AppHarnessUI.reload();
+ return AppHarnessUI.reload(launchUrl, pluginMetadata, 'system');
} else {
return AppHarnessUI.create(launchUrl, pluginMetadata);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[14/17] git commit: Fix android launch now that UrlRemapper doesn't
apply to main webview
Posted by ag...@apache.org.
Fix android launch now that UrlRemapper doesn't apply to main webview
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/54cd7bba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/54cd7bba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/54cd7bba
Branch: refs/heads/master
Commit: 54cd7bbaa1d575bd05057565794fb8ae9d27c495
Parents: dc55639
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Oct 24 21:24:02 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/AppsService.js | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/54cd7bba/www/cdvah/js/AppsService.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppsService.js b/www/cdvah/js/AppsService.js
index 2dd55c8..00443d5 100644
--- a/www/cdvah/js/AppsService.js
+++ b/www/cdvah/js/AppsService.js
@@ -158,13 +158,8 @@
activeInstaller = installer;
return installer.launch();
}).then(function(launchUrl) {
- // Don't just use ResourcesLoader.doesFileExist because remaps might make it exist.
- return ResourcesLoader.xhrGet(launchUrl)
- .then(null, function() {
- throw new Error('Start file does not exist: ' + launchUrl.replace(/.*?\/www\//, 'www/'));
- }).then(function() {
- return installer.getPluginMetadata();
- }).then(function(pluginMetadata) {
+ return installer.getPluginMetadata()
+ .then(function(pluginMetadata) {
$location.path('/inappmenu');
// If we're relaunching the active app, just reload the existing webview.
// Otherwise, create a new one.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[03/17] git commit: Make UrlRemap not apply to the main webview
Posted by ag...@apache.org.
Make UrlRemap not apply to the main webview
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/b0ec6069
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/b0ec6069
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/b0ec6069
Branch: refs/heads/master
Commit: b0ec60698743ba8c1f9a8db22e3be7cf71b0a23d
Parents: 33fcb52
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 26 15:52:30 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:43:03 2014 -0400
----------------------------------------------------------------------
UrlRemap/src/android/UrlRemap.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/b0ec6069/UrlRemap/src/android/UrlRemap.java
----------------------------------------------------------------------
diff --git a/UrlRemap/src/android/UrlRemap.java b/UrlRemap/src/android/UrlRemap.java
index fc6bf19..a6a2ea4 100644
--- a/UrlRemap/src/android/UrlRemap.java
+++ b/UrlRemap/src/android/UrlRemap.java
@@ -42,6 +42,16 @@ public class UrlRemap extends CordovaPlugin {
// Shared routing for all webviews.
private static RouteParams resetUrlParams;
private static List<RouteParams> rerouteParams = new ArrayList<RouteParams>();
+ private static boolean hasMaster;
+ private boolean isMaster;
+
+ @Override
+ protected void pluginInitialize() {
+ if (!hasMaster) {
+ hasMaster = true;
+ isMaster = true;
+ }
+ }
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
@@ -90,6 +100,10 @@ public class UrlRemap extends CordovaPlugin {
@Override
public boolean onOverrideUrlLoading(String url) {
+ // Don't remap for the main webview.
+ if (isMaster) {
+ return false;
+ }
synchronized (rerouteParams) {
if (resetUrlParams != null && resetUrlParams.matchRegex.matcher(url).find()) {
resetMappings();
@@ -128,6 +142,10 @@ public class UrlRemap extends CordovaPlugin {
@Override
public Uri remapUri(Uri uri) {
+ // Don't remap for the main webview.
+ if (isMaster) {
+ return null;
+ }
synchronized (rerouteParams) {
String uriAsString = uri.toString();
RouteParams params = getChosenParams(uriAsString, false);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[09/17] git commit: Fix /deletefiles not working when deleting more
than ~10 files.
Posted by ag...@apache.org.
Fix /deletefiles not working when deleting more than ~10 files.
HttpRequest.readEntireBody() was completely broken :(
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/7f7279a1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/7f7279a1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/7f7279a1
Branch: refs/heads/master
Commit: 7f7279a1278c0fc35ff7119487f3566b930cff2b
Parents: bbefd2a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Oct 21 15:47:30 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400
----------------------------------------------------------------------
www/cdvah/js/HttpServer.js | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/7f7279a1/www/cdvah/js/HttpServer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/HttpServer.js b/www/cdvah/js/HttpServer.js
index 2d7244c..ed9a30e 100644
--- a/www/cdvah/js/HttpServer.js
+++ b/www/cdvah/js/HttpServer.js
@@ -85,20 +85,27 @@
};
HttpRequest.prototype.readEntireBody = function() {
+ var self = this;
var byteArray = null;
var soFar = 0;
- var self = this;
function handleChunk(chunk) {
- if (byteArray) {
- byteArray.set(chunk, soFar);
- soFar += chunk.byteLength;
- }
+ byteArray.set(new Uint8Array(chunk), soFar);
+ soFar += chunk.byteLength;
+
if (self.bytesRemaining === 0) {
- return byteArray ? byteArray.buffer : chunk;
+ return byteArray.buffer;
}
return self.readChunk().then(handleChunk);
}
- return this.readChunk().then(handleChunk);
+ return this.readChunk().then(function(chunk) {
+ // Avoid array copy if there's only one chunk.
+ if (self.bytesRemaining === 0) {
+ return chunk;
+ }
+ // Otherwise, allocate the buffer based on Content-Length.
+ byteArray = new Uint8Array(self.bytesRemaining + chunk.byteLength);
+ return handleChunk(chunk);
+ });
};
HttpRequest.prototype.readChunk = function(/* optional */maxChunkSize) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[06/17] git commit: Added comments explaining launch handling.
Posted by ag...@apache.org.
Added comments explaining launch handling.
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/55cf7bdc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/55cf7bdc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/55cf7bdc
Branch: refs/heads/master
Commit: 55cf7bdcc248c699ef956302e036a5395eb15f6c
Parents: 6ce2740
Author: Max Woghiren <ma...@gmail.com>
Authored: Tue Sep 30 15:50:25 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Oct 24 20:44:14 2014 -0400
----------------------------------------------------------------------
.../node_modules/cordova-harness-client/pushsession.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/55cf7bdc/harness-push/node_modules/cordova-harness-client/pushsession.js
----------------------------------------------------------------------
diff --git a/harness-push/node_modules/cordova-harness-client/pushsession.js b/harness-push/node_modules/cordova-harness-client/pushsession.js
index 05681b2..ae5aa31 100644
--- a/harness-push/node_modules/cordova-harness-client/pushsession.js
+++ b/harness-push/node_modules/cordova-harness-client/pushsession.js
@@ -234,7 +234,9 @@ PushSession.prototype.push = function(forceLaunch) {
var pushList = buildPushList(self.assetManifest_ || {}, assetMap);
if (deleteList.length === 0 && pushList.length === 0) {
console.log('Application already up-to-date.');
- return false; // appChanged
+ // The app hasn't changed, so resolve the promise saying so.
+ // It won't be launched unless `forceLaunch` is true.
+ return false;
}
var p;
// TODO: It might be faster to use Zip even when some files exist.
@@ -246,10 +248,12 @@ PushSession.prototype.push = function(forceLaunch) {
return p.then(function() {
return self.deleteFiles_(deleteList);
}).then(function() {
- return true; // appChanged
+ // The app has changed, so resolve the promise saying so. The app will be launched with the changes.
+ return true;
});
}).then(function(appChanged) {
// Determine whether we should launch the app.
+ // We want to launch the app if we've been told to force it or if the app has changed.
shouldLaunch = forceLaunch || (self.launchAfterPush && appChanged);
if (shouldLaunch) {
return self.harnessClient_.launch(self.appId_);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org