Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge remote-tracking branch 'harness/master' into foo
  • Loading branch information
agrieve committed May 6, 2014
2 parents 886f865 + 1b91a06 commit 4d6ac3ed7d862b60d7973d59cf9f0a97d0ab4ee3
Showing 13 changed files with 1,967 additions and 0 deletions.
@@ -0,0 +1 @@
/CCAHarness
Binary file not shown.
@@ -0,0 +1,27 @@
Copyright (c) 2014 The Chromium Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,46 @@
# Chrome Apps Developer Tool for Mobile

This repository contains scripts and assets that will remix the
[Apache Cordova project](https://cordova.apache.org)'s
[App Harness](https://git-wip-us.apache.org/repos/asf/cordova-app-harness.git)
so that it can run Chrome Apps on mobile devices. This is based on the plugins
from the [cca](https://github.com/MobileChomeApps/mobile-chrome-apps) toolkit.

## Use a Pre-built APK
Pre-built APKs are available [here](https://github.com/MobileChromeApps/harness/releases).

## Creating a Project
Use `createproject.sh` to create a project. Example invocation:

PLATFORMS="android ios" ./createproject.sh ../../cordova/cordova-app-harness

For more info:

./createproject.sh --help

### Extra Steps

- Replace the default Cordova icons with your desired icons.
- `rm platforms/android/res/drawable-*/icon.png`
- `cp ../../mobile-chrome-apps/templates/default-app/assets/icons/icon128.png platforms/android/res/drawable/icon.png`
- Replace the title in index.html to "Chrome ADT vX.X.X"
- `vim www/cdvah/index.html`

### Cutting a Release

- Update the version in `config.xml`
- `vim config.xml`
- Update versionCode in `platforms/android/AndroidManifest.xml`
- `vim platforms/android/AndroidManifest.xml`
- Build apk
- `cd CCAHarness && ../buildharness.sh`
- Tag release
- `git tag -am "Tagged vX.X.X-alpha" vX.X.X-alpha`
- `git push origin master --tags`
- Upload apk to GitHub's releases page
- Attach the apk
- Write *short* release notes (download link should be visible without scrolling).

## TODO

- Add custom icon
@@ -0,0 +1,47 @@
#!/bin/bash

if [[ ! -e platforms/android ]]; then
echo "Use this script to build a signed ChromeADT.apk"
echo
echo "Usage:"
echo " Run it with your CWD set to the root of the project"
exit 1
fi

KEYSTORE_PATH="$(dirname $0)/CCAHarness-debug.keystore"
AAPT_PATH=$(which aapt)

if [[ -z "$AAPT_PATH" ]]; then
ANDROID_PATH=$(which android)
if [[ -z "$ANDROID_PATH" ]]; then
echo "aapt not found (nor android tool)"
exit 1
fi
BUILD_TOOLS=${ANDROID_PATH%/tools*}/build-tools
AAPT_PATH=$(find "$BUILD_TOOLS" -name "aapt" | tail -n1)
if [[ -z "$AAPT_PATH" ]]; then
echo "aapt not found"
exit 1
fi
fi

if [[ ! -e "$KEYSTORE_PATH" ]]; then
echo "Couldn't find keystore at: $KEYSTORE_PATH"
exit 1
fi

cordova build android || exit 1

# Remove previous signing artifacts
APK_PATH=$(ls platforms/android/ant-build/*-debug.apk)
"$AAPT_PATH" remove "$APK_PATH" META-INF/MANIFEST.MF || exit 1
"$AAPT_PATH" remove "$APK_PATH" META-INF/CERT.SF
"$AAPT_PATH" remove "$APK_PATH" META-INF/CERT.RSA

# Resign.
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore $KEYSTORE_PATH -storepass android "$APK_PATH" androiddebugkey || exit 1

# Verify signing
jarsigner -verify "$APK_PATH" || exit 1

echo "Build Complete. APK is at: $APK_PATH"
@@ -0,0 +1,66 @@
#!/bin/bash

if [[ $# -eq 0 || "$1" = "--help" ]]; then
echo "Use this script to create a Chrome ADT project"
echo
echo "Usage: createproject.sh path/to/cordova-app-harness"
echo 'Options via variables:'
echo ' PLATFORMS="android ios"'
echo ' CORDOVA="path/to/cordova"'
echo ' PLUGIN_SEARCH_PATH="path1:path2:path3"'
echo ' DIR_NAME="path/to/put/new/project" (default is "CCAHarness")'
echo ' CCA="path/to/cca"'
exit 1
fi

CCA="${CCA-cca}"
AH_PATH=$(cd "$1" && pwd)
H_PATH=$(cd $(dirname "$0") && pwd)
DIR_NAME=CCAHarness

if [[ -e "$CCA" ]]; then
CCA="$(cd $(dirname "$CCA") && pwd)/$(basename "$CCA")"
else
if ! which "$CCA"; then
echo "Could not find cca executable."
echo "Make sure it's in your path or set the \$CCA variable to its location"
exit 1
fi
fi

export APP_ID=org.chromium.ChromeADT
export APP_NAME="Chrome ADT"
export APP_VERSION="0.4.2"
"$AH_PATH/createproject.sh" "$DIR_NAME" || exit 1

cd "$DIR_NAME"

# Using CCA here to get the right search path.
echo "Installing Chromium plugins"
"$CCA" plugin add \
org.chromium.bootstrap \
org.chromium.bootstrap \
org.chromium.navigation \
org.chromium.fileSystem \
org.chromium.i18n \
org.chromium.identity \
org.chromium.idle \
org.chromium.notifications \
org.chromium.power \
org.chromium.socket \
org.chromium.syncFileSystem \
org.chromium.FileChooser \
org.chromium.polyfill.blob_constructor \
org.chromium.polyfill.CustomEvent \
org.chromium.polyfill.xhr_features \
org.apache.cordova.keyboard \
org.apache.cordova.statusbar \
org.apache.cordova.network-information \
"$H_PATH"/harness-push


if [[ $? != 0 ]]; then
echo "Plugin installation failed. Probably you need to set PLUGIN_SEARCH_PATH env variable so that it contains the plugin that failed to install."
exit 1
fi

@@ -0,0 +1,53 @@
# Licenses

This repository contains original Cordova plugin code, and NanoHTTPD.

The license of the original plugin code follows immediately, and the NanoHTTPD license is included after.
The NanoHTTPD license is also included in `src/android/nanohttpd/LICENSE.md`.

## License for original Cordova plugin code

Copyright (c) 2014 The Chromium Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


## License for NanoHTTPD

Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the NanoHttpd organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@@ -0,0 +1,52 @@
# App Harness Push

Allows pushing updates of apps to the App Harness.

## Installation

cordova plugin add https://github.com/MobileChromeApps/harness-push.git

## Use

**You must** press the "Start Listening" button on the main menu of the App Harness prior to using any of the requests below.

There are currently four kinds of requests you can make:

## Port Forwarding

If you are not on the same network, you can use adb to port forward:

adb forward tcp:2424 tcp:2424

When done:

adb forward --remove tcp:2424

### Push - `cordova serve`

Make a `POST` request on port 2424 to:

/push?type=serve&name=com.example.YourApp&url=http://192.168.1.101:8000

and this will cause the App Harness to return to the main menu, and fetch the app from `cordova serve`.

### Push - `.crx` files

Make a `POST` request on port 2424 to

/push?type=crx&name=appname

with the file passed as an HTTP form submission, with the key `file`. The following curl line will do it, for example:

curl -X POST "http://192.168.1.102:2424/push?type=crx&name=myapp" -F "file=@path/to/myapp.crx"

### Menu - Return to the App Harness menu

Sometimes, especially on emulators, it's hard or impossible to do the three-point touch that triggers the App Harness context menu. Sending a `POST` request on port 2424 to `/menu` will return to the App Harness main menu.

### Exec - Run arbitrary Javascript

This allows the sending of arbitrary Javascript. This is useful for debugging and may be removed later. Contact us with any interesting use-cases for this endpoint.

/exec?code=location='file:///android_asset/www/someotherpage.html'

@@ -0,0 +1,30 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var exec = require('cordova/exec');

exports.getListenAddress = function(win) {
chrome.socket.getNetworkList(function(interfaces) {
// Filter out ipv6 addresses.
var ret = interfaces.filter(function(i) {
return i.address.indexOf(':') === -1;
}).map(function(i) {
return i.address;
}).join(', ');
win(ret);
});
};

exports.listen = function(win, fail) {
exec(win, fail, 'HarnessPush', 'listen', []);
};

exports.listening = function(win, fail) {
exec(win, fail, 'HarnessPush', 'listening', []);
};

exports.pending = function(win, fail) {
exec(win, fail, 'HarnessPush', 'pending', []);
};

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
id="org.apache.appharness.push"
version="1.0.0">
<engines>
<engine name="cordova" version=">=3.0.0" />
</engines>

<name>App Harness Push Protocol</name>

<dependency id="org.chromium.socket" />

<platform name="android">
<source-file src="src/android/Push.java" target-dir="src/org/apache/appharness" />
<source-file src="src/android/nanohttpd/NanoHTTPD.java" target-dir="src/fi/iki/elonen" />

<js-module src="js/push.js" name="Push">
<clobbers target="appharness.push" />
</js-module>

<config-file target="res/xml/config.xml" parent="/widget">
<feature name="HarnessPush">
<param name="android-package" value="org.apache.appharness.Push"/>
</feature>
</config-file>
</platform>
</plugin>

0 comments on commit 4d6ac3e

Please sign in to comment.