Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Friday, September 11, 2015

GPU-emulation for Android Emulator on a headless Linux

Eventually Google've released GPU emulation to public with new SDK 24.3.4

With GPU-EMULATION  it is possible to move your Android test farm to clouds like AWS without pay lots of money for instances with GPU.

Here is a how-to configure a headless GNU/Linux for Android with GPU emulation.

# install packages for android sdk
dpkg --add-architecture i386
apt-get update
apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 lib32stdc++6 lib32z1 -y

# install Xorg (along with 32bit libs) for emulator to work with imaginary GPU
apt-get install xserver-xorg xserver-xorg-video-dummy x11-xserver-utils \
 x11vnc libgl1-mesa-dev libx11-6 libx11-dev libx11-6:i386 libx11-dev:i386 -y

# create config file /etc/X11/xorg.conf

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "dummy"
    VendorName     "Dummy Corporation"
    Option "NoDDC" "true"
    Option "IgnoreEDID" "true"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "NoLogo" "True"
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Virtual     1024 768
        Depth       24
    EndSubSection
EndSection

# start Xorg
Xorg :0


# get fresh SDK
wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
.....

# do not forget about environment variables
JAVA_HOME=...

ANDROID_HOME=/usr/local/android/android-sdk-linux

LD_LIBRARY_PATH=${ANDROID_HOME}/tools/lib/gles_mesa:${ANDROID_HOME}/tools/lib/:${LD_LIBRARY_PATH}

PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}

export JAVA_HOME ANDROID_HOME PATH LD_LIBRARY_PATH

# after creating android virtual device, add to config.ini :
hw.gpu.enabled=true
hw.gpu.mode=mesa


# start emulator
DISPLAY=:0 emulator -avd a442 -no-boot-anim -noaudio -no-jni -gpu mesa

# see in logs
emulator: Initializing hardware OpenGLES emulation support
emulator: OpenGL Vendor=[Google (VMware, Inc.)]
emulator: OpenGL Renderer=[Android Emulator OpenGL ES Translator (Gallium 0.4 on llvmpipe (LLVM 3.5, 256 bits))]
emulator: OpenGL Version=[OpenGL ES 2.0 (3.0 Mesa 10.4.2 (git-))]

Wednesday, July 22, 2015

Android remote control - Smartphone Test Farm

Really great piece of software for a QA engineer and even for a QA team!

Allows to control and manage real Android smartphone devices from your browser.


Thursday, April 9, 2015

Start Google Chrome on Android Emulator

Prepare Android emulator

  • Use Android emulator with enabled GPU - start emulator with -gpu on 
  • Use larger system and data partition - start emulator with -partition-size 1024


Get a binary of Chrome - I use apk from http://www.apkmirror.com/apk/google-inc/chrome/

adb install com.android.chrome...apk


For web test automation one can use appium bundled with chromedriver, as well as chromedriver solely.


Tuesday, August 5, 2014

auto install and upgrade Android SDK

Yo!

Say there is a need to install Android SDK automatically on a farm of headles Linux servers in clouds (Amazon AWS, whatever). Here is a nice script:

#!/bin/bash
set -x
cd ~

if [ -d android-sdk ]
then
  rm -rf android-sdk
fi

if [ ! -f android-sdk_r22.6.2-linux.tgz ]
then
fi

if [ ! -d android-sdk-linux ]
then
 tar -zxvf android-sdk_r22.6.2-linux.tgz
fi

ANDROID_HOME=~/android-sdk-linux/
PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}
export ANDROID_HOME PATH

components_to_install=`$ANDROID_HOME/tools/android list sdk -a |grep -E '(SDK Tools|Platform.*API 1[0-9]|Platform-tools|Build-tools|Intel x86|Web Driver|Support Library)'`
echo -e "Will install following components \n $components_to_install"
list_of_components_to_install=`echo "$components_to_install"| sed -e 's/^ \+//g' | grep -E '^[0-9]'|sed -rn 's/^([[:digit:]]+).*/\1/p' | perl -p -e 's/\n/,/' |sed -e 's/,$//g'`
echo "components to install in CSV $list_of_components_to_install"
android_cmd="$ANDROID_HOME/tools/android update sdk -u -a --filter $list_of_components_to_install"
(while :
do
  echo 'y'
  sleep 4
done) | bash -c "$android_cmd"


Wednesday, September 25, 2013

Capturing Screen shots on Android via ADB

Let's use screencap tool on Android to capture a screen shot and save it to a file on Android's internal /sdcard.

adb shell screencap -p /sdcard/myScreenShot.png

Ok, lets capture a series of screen shots - a movie.

adb shell mkdir -p /sdcard/moovie1; 
for i in `seq -w 1 1 155`; do \
  adb shell screencap -p /sdcard/moovie1/cap_$i.png && \
  echo -e "cap_$i.png"; \
done;

Now let's download the images:

for i in `seq -w 1 1 155`; do \
  adb pull /sdcard/moovie1/cap_$i.png && \
  adb shell rm /sdcard/moovie1/cap_$i.png && \
  echo -e "cap_$i.png\n"; \
done;

Ok, now let's make a movie with help of well-known imagemagick tool::
Scale images to 50% size and convert them to GIF format.

for i in `ls`; \
  do convert $i -scale 50% $i.gif; \
done;

convert -delay 100 -loop 0 cap*.gif animated_screen.gif

Also one could use following script to save captured images directly to computer

 adb shell screencap -p | sed 's/\r$//' > screen.png 
or 
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

to cat images directly to a file on a computer (src)
(but for series of screen shots that will be a bit slower).


adb shell screencap -h
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.


Monday, September 2, 2013

Reveal Developer options on OS Android >= 4.2

On devices with OS Android >= 4.2  menu item "Developer options" appears to be hidden.

If you ever want to enable "Developer options" on your device, please do the following:

1. Go to Settings -> About tablet 
2. Perform about 7 taps on item Build number (the last menu item on the list)

Then "{} Developer options" will appear.