diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/build.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/build.xml new file mode 100644 index 0000000000..9fbdb7899e --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/build.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml index b85ba71056..eb27680b3c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml @@ -35,6 +35,23 @@ + + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + process-resources + + + + + + + run + + + + maven-assembly-plugin 2.5.5 diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml index b76e367060..e363afd1f3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/assembly/src.xml @@ -43,4 +43,14 @@ true + + + + ${basedir}/target/android-tryit.ZIP + + /devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/assets/ + true + 755 + + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/README.md b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/README.md new file mode 100644 index 0000000000..e9c1f11234 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/README.md @@ -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. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/resources/config.ini b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/resources/config.ini new file mode 100755 index 0000000000..b86c5fc3eb --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/resources/config.ini @@ -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 diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/start b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/start new file mode 100755 index 0000000000..a8e1c71eeb --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/android-tryit/start @@ -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=$( 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!" diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json index 19c89fd378..d63751c8f8 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json @@ -1,7 +1,8 @@ { "deviceType": { "label": "Android", - "category": "mobile", + "virtualLabel": "Android Emulator", + "category": "hybrid", "analyticsEnabled": "false", "groupingEnabled": "false", "scopes" : [ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css index 56dc06903e..519c650595 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/css/styles.css @@ -59,5 +59,5 @@ hr { color: #006eff; } .enrollment-qr-container canvas { - width: 24%; + width: 14%; } \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/images/android-tryit.png b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/images/android-tryit.png new file mode 100644 index 0000000000..4da14f77b6 Binary files /dev/null and b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/images/android-tryit.png differ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs index 0bb9bcf5fd..bf0a44e451 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.hbs @@ -4,7 +4,11 @@
-

DOWNLOAD THE ANDROID AGENT

+ {{#if isVirtual}} +

DOWNLOAD ANDROID TRY-IT EMULATOR

+ {{else}} +

DOWNLOAD THE ANDROID AGENT

+ {{/if}}
@@ -13,16 +17,24 @@ -
-

Scan to download the Android Agent.

-
-

or

- - - -
- {{#zone "topCss"}} {{css "css/styles.css"}} {{/zone}} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js index ec164b6579..00f113e411 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/type-view.js @@ -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"];