Thursday, August 1, 2013

Android screenshots using SDK + adb

Before using adb set the device in debugging mode
Settings -> Applications -> Development -> USB debugging
Carry out the following steps to enable the Android device (GTA02) to connect to the laptop (where SDK is already installed)

- Connect the USB                                                                        

o/p of ifconfig(after the USB is connected)
ranjit@ranjit-laptop:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:24:54:ba:c7:01 
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:18

eth1      Link encap:Ethernet  HWaddr e8:39:df:6a:42:c8 
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ea39:dfff:fe6a:42c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10799 errors:0 dropped:0 overruns:0 frame:21795
          TX packets:10798 errors:6 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11622726 (11.6 MB)  TX bytes:1805301 (1.8 MB)
          Interrupt:16

eth2      Link encap:Ethernet  HWaddr 00:1f:11:01:81:cb 
          inet6 addr: fe80::21f:11ff:fe01:81cb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:2178 (2.1 KB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3356 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3356 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:430799 (430.7 KB)  TX bytes:430799 (430.7 KB) 

o/p of lsusb
ranjit@ranjit-laptop:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 1457:5122 First International Computer, Inc. OpenMoko Neo1973 / Neo Freerunner kernel cdc_ether USB network
Bus 003 Device 002: ID 0a5c:219c Broadcom Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0ac8:c33f Z-Star Microelectronics Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
ranjit@ranjit-laptop:~$

ranjit@ranjit-laptop:~$ ps -Al| grep adb
ranjit@ranjit-laptop:~$

- Issue the following commands                                                    

GTA02 is connected to eth2(it could be eth1, usb0)
ranjit@ranjit-laptop:~$ sudo ifconfig eth2 192.168.0.200 netmask 255.255.255.0

o/p of ifconfig(after setting the address of the network device(GTA02) )
ranjit@ranjit-laptop:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:24:54:ba:c7:01 
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:18

eth1      Link encap:Ethernet  HWaddr e8:39:df:6a:42:c8 
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ea39:dfff:fe6a:42c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12101 errors:0 dropped:0 overruns:0 frame:24507
          TX packets:11566 errors:6 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:13425369 (13.4 MB)  TX bytes:1872549 (1.8 MB)
          Interrupt:16

eth2      Link encap:Ethernet  HWaddr 00:1f:11:01:81:cb 
          inet addr:192.168.0.200  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21f:11ff:fe01:81cb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:6376 (6.3 KB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3897 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3897 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:497618 (497.6 KB)  TX bytes:497618 (497.6 KB)

ranjit@ranjit-laptop:~$
ranjit@ranjit-laptop:~$ ADBHOST=192.168.0.202 adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
emulator-5554    device

 Now we can make use of ddms(Dalvik Debug Monitor) or monitor(Android Debug Monitor) to take the screenshots, which is set using the PATH variable

ranjit@ranjit-laptop:~$ echo $PATH
/home/ranjit/development/android-sdk-linux/platform-tools:/home/ranjit/development/android-sdk-linux/tools:/opt/toolchains/arm920t-eabi/bin:/usr/local/Trolltech/Qt-4.5.0/bin:/home/ranjit/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
ranjit@ranjit-laptop:~$

ranjit@ranjit-laptop:~$ ddms
The standalone version of DDMS is deprecated.
Please use Android Device Monitor (tools/monitor) instead.

(DDMS:2392): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -5 and height 17

(DDMS:2392): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -5 and height 17
ranjit@ranjit-laptop:~$















 



















other commands

ranjit@ranjit-laptop:~$ ping 192.168.0.202

shell access on the android device

ranjit@ranjit-laptop:~$ adb shell
# echo $PATH
/sbin:/system/sbin:/system/bin:/system/xbin
# ls -l
drwxrwxrwt root     root              2000-01-13 16:18 sqlite_stmt_journals
drwxrwx--- system   cache             2000-01-13 11:45 cache
d--------- system   system            2000-01-13 11:45 sdcard
lrwxrwxrwx root     root              2000-01-13 11:45 etc -> /system/etc
drwxr-xr-x root     root              2011-01-20 14:39 sbin
-rwxr-xr-x root     root       106604 2011-01-19 22:55 init
drwxr-xr-x root     root              1970-01-01 05:30 sys
drwxr-xr-x root     root              1970-01-01 05:30 system
drwxr-xr-x root     root              2000-01-13 11:45 dev
-rw-r--r-- root     root        12099 2011-01-20 14:36 init.rc
-rw-r--r-- root     root         4570 2010-08-22 01:17 init.gta02.rc
-rw-r--r-- root     root         1677 2010-08-22 01:17 init.goldfish.rc
drwxrwx--x system   system            2000-01-01 12:32 data
dr-xr-xr-x root     root              1970-01-01 05:30 proc
-rw-r--r-- root     root          118 2011-01-19 22:55 default.prop
#

# set
ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=9,32768
ANDROID_ROOT=/system
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
EXTERNAL_STORAGE=/sdcard
IFS='    
'
LD_LIBRARY_PATH=/system/lib
OPTIND=1
PATH=/sbin:/system/sbin:/system/bin:/system/xbin
PS1='# '
PS2='> '
PS4='+ '
PWD=/
_=env
#

# cd /system/bin
# pwd
/system/bin
#

# ls
am
dd
df
hd
id
ln
ls
mv
pm
ps
rm
sh
cat
cmp
dvz
ime
log
smd
svc
top
date
hcid
gzip
kill
ping
rild
stop
sync
vold
wipe
vchanneld
dalvikvm
logwrapper
chmod
chown
dmesg
iftop
ioctl
input
lsmod
mkdir
mount
servicemanager
qemud
rmdir
rmmod
route
sleep
start
check_prereq
dosfsck
sdptool
service
setprop
dumpsys
schedtop
gdbserver
dumpcrash
dumpstate
bugreport
surfaceflinger
getprop
toolbox
showlease
ifconfig
mediaserver
alsa_ctl
wpa_cli
radiooptions
qemu-props
hciattach
setconsole
system_server
debuggerd
dbus-daemon
schedtest
sendevent
mkdosfs
alsa_aplay
dexopt
dhcpcd
getevent
netstat
insmod
linker
logcat
monkey
netcfg
notify
app_process
reboot
renice
sdutil
umount
vmstat
printenv
wmiconfig
watchprops
wpa_supplicant
alsa_amixer
applypatch
installd
#
# printenv
ANDROID_ROOT=/system
PWD=/system/bin
LD_LIBRARY_PATH=/system/lib
PATH=/sbin:/system/sbin:/system/bin:/system/xbin
BOOTCLASSPATH=/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
ANDROID_BOOTLOGO=1
ANDROID_ASSETS=/system/app
EXTERNAL_STORAGE=/sdcard
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=9,32768
#
# ps
USER     PID   PPID  VSIZE RSS   WCHAN    PC         NAME
root     1     0     304   216   c00cf9c0 0000c75c S /init
root     2     0     0     0     c008b574 00000000 S kthreadd
root     3     2     0     0     c007cf4c 00000000 S ksoftirqd/0
root     4     2     0     0     c00885d4 00000000 S events/0
root     5     2     0     0     c00885d4 00000000 S khelper
root     15    2     0     0     c00885d4 00000000 S suspend
root     182   2     0     0     c00885d4 00000000 S kblockd/0
root     188   2     0     0     c00885d4 00000000 S ksuspend_usbd
root     194   2     0     0     c01fcd88 00000000 S khubd
root     197   2     0     0     c0229ed0 00000000 S kseriod
root     207   2     0     0     c00885d4 00000000 S kmmcd
root     214   2     0     0     c00885d4 00000000 S btaddconn
root     215   2     0     0     c00885d4 00000000 S btdelconn
root     239   2     0     0     c00a71e0 00000000 S pdflush
root     240   2     0     0     c00a71e0 00000000 S pdflush
root     241   2     0     0     c00ab89c 00000000 S kswapd0
root     243   2     0     0     c00885d4 00000000 S aio/0
root     274   2     0     0     c01a8864 00000000 S kapmd
root     321   2     0     0     c00885d4 00000000 S pcf50633
root     357   2     0     0     c00885d4 00000000 S glamo-spi-gpio.
root     391   2     0     0     c01e8864 00000000 S mtdblockd
root     425   2     0     0     c00885d4 00000000 S spi_s3c24xx_gpi
root     492   2     0     0     c0245de8 00000000 S mmcqd
root     525   2     0     0     c00885d4 00000000 S hid_compat
root     570   2     0     0     c03061c0 00000000 S krfcommd
root     853   1     764   348   c0197e00 afe0c31c S /system/bin/sh
system   854   1     832   312   c02707d8 afe0c5bc S /system/bin/servicemanager
root     855   1     872   408   c00cf9c0 afe0c6e4 S /system/bin/vold
root     856   1     692   296   c0298ea4 afe0cf4c S /system/bin/debuggerd
media    858   1     27980 5504  ffffffff afe0c5bc S /system/bin/mediaserver
bluetooth 859   1     1220  780   c00cf9c0 01b66594 S /system/bin/dbus-daemon
root     860   1     1228  616   c00ec698 afe0d4ac S /system/bin/vchanneld
root     861   1     828   332   c02f35e4 afe0c31c S /system/bin/installd
root     862   1     6452  224   ffffffff 0000e804 S /sbin/adbd
radio    868   1     5520  780   ffffffff 0181c4e8 S /system/bin/rild
root     1790  1     1280  604   c00cf9c0 afe0c6e4 S /system/xbin/pppd
root     1809  1     73468 21216 c00cf9c0 afe0c6e4 S zygote
system   1811  1809  222052 31188 ffffffff afe0c5bc S system_server
radio    1847  1809  120080 21932 ffffffff afe0d6c0 S com.android.phone
app_2    1851  1809  120120 25300 ffffffff afe0d6c0 S android.process.acore
app_4    1873  1809  95612 17592 ffffffff afe0d6c0 S com.android.mms
app_0    1900  1809  96968 18076 ffffffff afe0d6c0 S com.android.calendar
app_1    1908  1809  96520 17616 ffffffff afe0d6c0 S android.process.media
app_7    1923  1809  94956 15360 ffffffff afe0d6c0 S com.android.voicedialer
app_11   1931  1809  99980 16496 ffffffff afe0d6c0 S android.process.im
app_15   1953  1809  95392 16588 ffffffff afe0d6c0 S com.android.alarmclock
app_2    1970  1809  96460 16848 ffffffff afe0d6c0 S com.android.inputmethod.latin
system   1976  1809  103208 19656 ffffffff afe0d6c0 S com.android.settings
root     4452  862   764   372   c007a878 afe0d35c S /system/bin/sh
root     4550  4452  912   368   00000000 afe0c31c R ps
#