aboutsummaryrefslogtreecommitdiffstats
path: root/Android/cordova/lib/install-device
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-07-12 09:09:00 +0100
committerStruan Donald <struan@exo.org.uk>2013-07-12 09:09:00 +0100
commit4c2206c97250b7f72eb04d13ae886a7fb4f4086a (patch)
treea81d2649bd2bf4eb0fe2e2acb64815d383fe8dd1 /Android/cordova/lib/install-device
parent8c81bd47bbe3ed65a55a2c5fd376bfd726bd6777 (diff)
update android to phonegap 2.9
Diffstat (limited to 'Android/cordova/lib/install-device')
-rwxr-xr-xAndroid/cordova/lib/install-device49
1 files changed, 49 insertions, 0 deletions
diff --git a/Android/cordova/lib/install-device b/Android/cordova/lib/install-device
new file mode 100755
index 0000000..e70bef7
--- /dev/null
+++ b/Android/cordova/lib/install-device
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PROJECT_PATH=$( cd "$DIR/../.." && pwd )
+device_list=$("$DIR/list-devices")
+if [ $? != 0 ]; then
+ echo "No devices found to deploy to. Please make sure your device is connected"
+ echo " and you can view it using the 'cordova/lib/list-devices' command."
+ exit 2
+fi
+
+apks=`find $PROJECT_PATH/bin -type f -maxdepth 1 | egrep '\.apk$'`
+apk_list=($apks)
+if [[ ${#apk_list[@]} > 0 ]] ; then
+ # handle target
+ read -ra device_array <<< "$device_list"
+ if [[ "$#" -eq 1 ]] ; then
+ # deploy to given target
+ target=${1/--target=/}
+ else
+ # delete trailing space and 'device' after device ID
+ target=${device_array[0]}
+ fi
+ echo "Installing ${apk_list[0]} onto device $target..."
+ adb -s $target install -r ${apk_list[0]};
+ echo "Launching application..."
+ launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
+ adb -s $target shell am start -W -a android.intent.action.MAIN -n $launch_str
+else
+ echo "Application package not found, could not install to device"
+ echo " make sure your application is built before deploying."
+ exit 2
+fi