Merge pull request #622 from charithag/master-androidtryit

Adding Android-tryit tool
revert-dabc3590
Geeth 8 years ago committed by GitHub
commit bc7b77e07a

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. 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.
-->
<project name="create-geo-fence-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/"/>
<property name="src-dir" value="src/main/resources/android-tryit"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<zip destfile="${target-dir}/android-tryit.ZIP">
<zipfileset dir="src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/" includes="android-agent.apk" fullpath="resources/android-agent.apk"/>
<zipfileset dir="${src-dir}"/>
</zip>
</target>
</project>

@ -35,6 +35,23 @@
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<ant antfile="build.xml" target="zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>

@ -43,4 +43,14 @@
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
<files>
<file>
<source>
${basedir}/target/android-tryit.ZIP
</source>
<outputDirectory>/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/assets/</outputDirectory>
<filtered>true</filtered>
<fileMode>755</fileMode>
</file>
</files>
</assembly>

@ -0,0 +1,21 @@
Prerequisites
===============
1. You should have curl in your computer.
2. Java 7 or higher.
Instructions
=================
1. Run 'start' script in your terminal.
2. If you already have android sdk in your computer, please provide location of the sdk.
Otherwise this tool will download and install minimum SDK components which needs to run the emulator.
This is a one time process.
3. This tool will ask to create AVD if you don't have any in your computer.
Otherwise you can select existing AVD to try out IoT Agent.
Troubleshooting
==================
1. If your exisitng SDK doen't work or giving any errors, delete 'sdklocation' file and try agin without selecting the existing SDK path.
2. If your emulator does not start correctly, please remove all files and directories in $HOME/.android/avd/ directory. Then try again with a new emulator.

@ -0,0 +1,29 @@
avd.ini.encoding=UTF-8
abi.type=x86
disk.dataPartition.size=200M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=none
hw.camera.front=none
hw.cpu.arch=x86
hw.dPad=no
hw.device.hash2=MD5:6930e145748b87e87d3f40cabd140a41
hw.device.manufacturer=Google
hw.device.name=Galaxy Nexus
hw.gps=yes
hw.keyboard=yes
hw.lcd.density=320
hw.mainKeys=no
hw.ramSize=1024
hw.sdCard=no
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-24/default/x86/
skin.dynamic=no
skin.name=720x1280
skin.path=720x1280
tag.display=Default
tag.id=default
vm.heapSize=64

@ -0,0 +1,243 @@
#!/bin/bash
#Make sure we have got everything we need
command -v curl >/dev/null || { echo "curl is not installed. Aborting." >&2; exit 1; }
command -v unzip >/dev/null || { echo "unzip is not installed. Aborting." >&2; exit 1; }
SCRIPT_HOME=$PWD
OS_SUFFIX="linux"
if [[ "$OSTYPE" == "darwin"* ]]; then
OS_SUFFIX="macosx"
fi
downloadArtifacts() {
curl -D headers -O $1
httpStatus=$(head -1 headers | awk '{print $2}')
[ "$httpStatus" != "200" ] && { echo "Download failed. Aborting." ; exit 1 ;}
rm headers
echo
}
setSDKPath () {
echo -n "Please provide Android SDK location (ex: /mnt/tools/android-sdk):"
read answer
emulator="$answer/tools/emulator"
if [ -f "$emulator" ]; then
echo "$answer" > sdklocation
else
echo "Invalid SDK location"
setSDKPath
fi
}
getAndroidSDK() {
echo
echo "Downloading Android SDK tools..."
mkdir android-sdk
cd android-sdk
downloadArtifacts "https://dl.google.com/android/repository/tools_r25.2.5-$OS_SUFFIX.zip"
echo -n "Configuring Android SDK tools..."
unzip -q tools_r25.2.5-$OS_SUFFIX.zip
rm tools_r25.2.5-$OS_SUFFIX.zip
echo " Done!"
echo
echo "Downloading Android platform tools..."
downloadArtifacts "http://dl.google.com/android/repository/platform-tools_r25.0.3-$OS_SUFFIX.zip"
echo -n "Configuring Android platform tools..."
unzip -q platform-tools_r25.0.3-$OS_SUFFIX.zip
rm platform-tools_r25.0.3-$OS_SUFFIX.zip
cd ..
echo "$PWD/android-sdk" > sdklocation
echo " Done!"
}
createAVD() {
if [ ! -d "$ANDROID_TRYIT_SDK_HOME/platforms/android-24" ]; then
echo
echo "Downloading Android platform..."
cd $ANDROID_TRYIT_SDK_HOME
downloadArtifacts "https://dl.google.com/android/repository/platform-24_r02.zip"
echo -n "Configuring Android platform..."
unzip -q platform-24_r02.zip
mkdir -p platforms/android-24
mv android-7.0/* platforms/android-24/
rm -r android-7.0
rm platform-24_r02.zip
cd ..
echo " Done!"
fi
if [ ! -d "$ANDROID_TRYIT_SDK_HOME/system-images/android-24/default" ]; then
echo "Downloading Android system image..."
cd $ANDROID_TRYIT_SDK_HOME
downloadArtifacts "https://dl.google.com/android/repository/sys-img/android/x86-24_r07.zip"
echo -n "Configuring Android system image..."
unzip -q x86-24_r07.zip
mkdir -p system-images/android-24/default
mv x86 system-images/android-24/default
rm x86-24_r07.zip
cd ..
echo " Done!"
fi
echo "Creating a new AVD device"
if [ -f "$ANDROID_TRYIT_SDK_HOME/tools/bin/avdmanager" ]; then
$ANDROID_TRYIT_SDK_HOME/tools/bin/avdmanager create avd -k 'system-images;android-24;default;x86' -n WSO2_AVD
else
$ANDROID_TRYIT_SDK_HOME/tools/android create avd -n WSO2_AVD -t android-24
fi
rm $HOME/.android/avd/WSO2_AVD.avd/resources/config.ini
cp $SCRIPT_HOME/resources/config.ini $HOME/.android/avd/WSO2_AVD.avd/
startAVD
}
startAVD() {
if [ ! -d "$HOME/.android/avd/WSO2_AVD.avd" ]; then
echo -n "Seems you don't have WSO2_AVD. Do you want to create WSO2_AVD with default configs (y/N)?: "
read answer
if echo "$answer" | grep -iq "^y" ;then
createAVD
return
fi
fi
echo
echo "------------------------------"
echo "Available AVDs in the system:"
echo "------------------------------"
devices=()
count=0
if [ ! -f "mypipe" ]; then
mkfifo mypipe
fi
$ANDROID_TRYIT_SDK_HOME/tools/emulator -list-avds > mypipe &
while IFS= read -r line
do
let count++
echo "$count) $line"
devices+=($line)
done < mypipe
rm mypipe
echo "------------------------------"
echo
if [ $count = 0 ]; then
echo -n "No AVDs found on your system. Do you want to create new AVD (Y/n)?: "
read answer
if echo "$answer" | grep -iq "^n" ;then
exit;
else
createAVD
fi
elif [ $count = 1 ]; then
runEmulator ${devices[0]}
else
echo -n "Enter AVD number to start (eg: 1): "
read answer
let answer--
runEmulator ${devices[$answer]}
fi
}
runEmulator(){
if [ $OS_SUFFIX = "macosx" -a ! -d $ANDROID_TRYIT_SDK_HOME/extras/intel/Hardware_Accelerated_Execution_Manager ]; then
cd $ANDROID_TRYIT_SDK_HOME
echo "Downloading intel HAXM..."
mkdir -p extras/intel/Hardware_Accelerated_Execution_Manager
cd extras/intel/Hardware_Accelerated_Execution_Manager
downloadArtifacts "https://dl.google.com/android/repository/extras/intel/haxm-macosx_r6_0_5.zip"
echo -n "Configuring HAXM..."
unzip -q haxm-macosx_r6_0_5.zip
rm haxm-macosx_r6_0_5.zip
./"HAXM installation" -m 2048 -log $SCRIPT_HOME/haxm_silent_run.log
echo " Done!"
echo
fi
cd $SCRIPT_HOME
$ANDROID_TRYIT_SDK_HOME/platform-tools/adb kill-server
echo "Starting AVD $1"
$ANDROID_TRYIT_SDK_HOME/tools/emulator -avd $1 > emulator.log &
while [ ! -f "$HOME/.android/avd/$1.avd/cache.img" ]
do
sleep 1
echo -n "."
done
count=0
while [ $count -lt 5 ]
do
sleep 1
echo -n "."
let count++
done
echo
}
echo "+----------------------------------------------------------------+"
echo "| WSO2 Android Tryit |"
echo "+----------------------------------------------------------------+"
echo "Detected OS: " $OSTYPE
if [ ! -f "sdklocation" ]; then
echo -n "Do you have Android SDK installed in your computer (Y/n)?: "
read answer
if echo "$answer" | grep -iq "^n" ;then
getAndroidSDK
else
setSDKPath
fi
fi
export ANDROID_TRYIT_SDK_HOME=$(<sdklocation)
if [ ! -d "$ANDROID_TRYIT_SDK_HOME/build-tools/25.0.2" ]; then
echo
echo "Downloading Android build tools..."
cd $ANDROID_TRYIT_SDK_HOME
downloadArtifacts "https://dl.google.com/android/repository/build-tools_r25.0.2-$OS_SUFFIX.zip"
echo -n "Configuring Android build tools..."
unzip -q build-tools_r25.0.2-$OS_SUFFIX.zip
mkdir -p build-tools/25.0.2
mv android-7.1.1/* build-tools/25.0.2/
rm -r android-7.1.1
rm build-tools_r25.0.2-$OS_SUFFIX.zip
echo " Done!"
fi
startAVD
while [ "`$ANDROID_TRYIT_SDK_HOME/platform-tools/adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; do sleep 1; done
echo "AVD Started!"
sleep 1
if [ ! -f "mypipe" ]; then
mkfifo mypipe
fi
app=$SCRIPT_HOME/resources/android-agent.apk
pkg=$($ANDROID_TRYIT_SDK_HOME/build-tools/25.0.2/aapt dump badging $app|awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}')
act=$($ANDROID_TRYIT_SDK_HOME/build-tools/25.0.2/aapt dump badging $app|awk -F" " '/launchable-activity/ {print $2}'|awk -F"'" '/name=/ {print $2}')
hasAgent=false
$ANDROID_TRYIT_SDK_HOME/platform-tools/adb shell pm list packages > mypipe &
while IFS= read -r line
do
if [ $line = "package:$pkg" ]; then
let hasAgent=true
fi
done < mypipe
rm mypipe
if [ $hasAgent = false ]; then
echo
echo "Installing agent..."
cd $SCRIPT_HOME/resources
$ANDROID_TRYIT_SDK_HOME/platform-tools/adb install android-agent.apk
fi
echo
echo "Staring agent..."
$ANDROID_TRYIT_SDK_HOME/platform-tools/adb shell am start -n $pkg/$act
echo
echo "Connected to device shell"
$ANDROID_TRYIT_SDK_HOME/platform-tools/adb shell
echo
echo "Good bye!"

@ -1,7 +1,8 @@
{
"deviceType": {
"label": "Android",
"category": "mobile",
"virtualLabel": "Android Emulator",
"category": "hybrid",
"analyticsEnabled": "false",
"groupingEnabled": "false",
"scopes" : [

@ -4,7 +4,11 @@
<div class="row">
<div class="col-lg-12">
{{#if isVirtual}}
<h1 class="grey ">DOWNLOAD ANDROID TRY-IT EMULATOR</h1>
{{else}}
<h1 class="grey ">DOWNLOAD THE ANDROID AGENT</h1>
{{/if}}
<hr>
</div>
</div>
@ -13,7 +17,14 @@
<!--<div class="col-xs-12 col-sm-4 col-md-3 col-lg-3 add-padding-top-2x">
<img src="{{@unit.publicUri}}/images/android-icon.png" class="img-responsive">
</div>-->
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 add-padding-top-2x">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 add-padding-top-2x add-padding-bottom-2x">
{{#if isVirtual}}
<h3 class="text-center add-padding-bottom-4x">Experience Android Device Management Agent with our Try-it Emulator</h3>
<div class="text-center"><a
href="{{@unit.publicUri}}/assets/android-tryit.ZIP"
class="btn-operations remove-margin download_agent">
<i class="fw fw-download fw-inverse fw-lg add-margin-1x"></i> Download Try-it Emulator</a></div>
{{else}}
<h3 class="text-center">Scan to download the Android Agent.</h3>
<div class="enrollment-qr-container text-center"></div>
<h3 class="text-center add-margin-bottom-2x add-margin-top-2x">or</h3>
@ -21,7 +32,8 @@
href="{{host}}/android-web-agent/public/mdm.page.enrollments.android.download-agent/asset/android-agent.apk"
class="btn-operations remove-margin download_agent">
<i class="fw fw-download fw-inverse fw-lg add-margin-1x"></i> Download APK</a></div>
{{/if}}
</div>
<!--<p class="doc-link">Please scan the QR code to download the APK on to your android device or click
<a href="{{host}}/android-web-agent/public/mdm.page.enrollments.android.download-agent/asset/android-agent.apk">here</a>
to save it to your computer.</p>
@ -36,34 +48,46 @@
href="https://docs.wso2.com/display/IoTS310/Android" target="_blank">WSO2
IoT Server documentation.</a></p>
{{/if}}
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-12 add-padding-top-2x ">
{{#if isVirtual}}
<h3 class="uppercase">TRY ANDROID AGENT WITH TRY-IT EMULATOR</h3>
{{else}}
<h3 class="uppercase">START ENROLLING YOUR DEVICE</h3>
{{/if}}
<hr>
</div>
</div>
{{#if isCloud}}
<div class="row grey-bg">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-md-offset-1 col-lg-offset-1 add-padding-top-2x add-padding-bottom-2x">
<h5><strong>Step 1</strong></h5>
{{#if isVirtual}}
<ol>
<li>Unzip the 'android-tryit.zip and run 'start' script in your terminal.</li>
<li>If you already have android sdk in your computer, please provide location of the sdk.
Otherwise this tool will download and install minimum SDK components which needs to run the emulator.
This is a one time process.</li>
<li>This tool will ask to create AVD if you don't have any in your computer.
Otherwise you can select existing AVD to try out IoT Agent.</li>
</ol>
<img src="{{@unit.publicUri}}/images/android-tryit.png" class="img-responsive">
{{else}}
<p>Let's start by installing the Android agent on your device. Open the downloaded file, and tap
<b>INSTALL</b>.</p>
<img src="{{@unit.publicUri}}/images/install_agent.png" class="img-responsive">
{{/if}}
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-md-offset-2 col-lg-offset-2 add-padding-top-2x add-padding-bottom-2x">
<h5><strong>Step 2</strong></h5>
<p>Enter your:
<p>
<p>Enter your:<p>
<ul>
<li>Username: username/email that you used to sign in.</li>
<li>Password: the WSO2 Cloud password.</li>
<li>Organization: the name of the organization.</li>
<li>Organization: <b>{{@user.domain}}</b></li>
<li>Username: <b>{{@user.username}}</b></li>
<li>Password: <i>The WSO2 Cloud password.</i></li>
</ul>
<img src="{{@unit.publicUri}}/images/login.png" class="img-responsive">
</div>
@ -158,8 +182,6 @@
</center>
</div>-->
<br/>
{{#zone "topCss"}}
{{css "css/styles.css"}}
{{/zone}}

@ -34,6 +34,7 @@ function onRequest(context){
// //do nothing.
// }
//);
viewModel["isVirtual"] = request.getParameter("type") == 'virtual';
viewModel["isCloud"] = devicemgtProps["isCloud"];
viewModel["hostName"] = devicemgtProps["httpsURL"];
viewModel["enrollmentURL"] = devicemgtProps["generalConfig"]["host"] + devicemgtProps["androidEnrollmentDir"];

Loading…
Cancel
Save