{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Peering into an Android Device via the shell
Summary
This article looks at what’s there (in terms of directories and processes) on an Android device/emulator via its shell.
 
Table of Contents

Looking into the device/emulator

Directories at the root

Code Listing 1. Contents of the root directory

Processes running on the Android Device

Code Listing 2. The processes running on Android

Some interesting Android Directories

Dalvik Cache

Code Listing 3. The Dalvik Cache

The app Directory

Code Listing 4. Pushing the .apk file from Eclipse

Code Listing 5. The .apk files on the device

Related Articles

 

Looking into the device/emulator

Here, ADB (Android Debug Bridge) is used to look into an Android device by starting its shell. You can start the shell on a particular device by using the command ‘adb –d <id> shell’. For some additional information on this, please refer to the following article:

Using ADB – Android Debug Bridge

Android uses Linux as its operating system, so, very basic UNIX commands like ls, ps, etc would work from the shell.

Directories at the root

As shown in the listing below, the root directory (/) has several directories and one file. The file is ‘init’. Dates on these directories/file are interesting: init, etc, var, sys, proc, sbin, and root have the date Jan 1, 1970. And the other directories, cache, d, data, system, tmp, and dev have dates from 2008.

The directories with the old dates are from the good ‘old’ UNIX world. You might expect to find more Android-specific stuff in the newer directories.

Code Listing 1. Contents of the root directory

C:\Users\Administrator>adb -d 1 shell

# pwd
pwd
/

# ls -l
ls -l
drw-rw-rw- root root 2008-03-18 17:32 cache
drwxr-xr-x root root 2008-03-18 17:32 d
-rwxr-xr-x root root 91952 1970-01-01 00:00 init
drwxr-xr-x root root 1970-01-01 00:00 etc
drwxr-xr-x root root 1970-01-01 00:00 var
drwxrwx--x system system 2008-02-29 01:19 data
drwxr-xr-x root root 2008-02-29 01:19 system
drwxr-xr-x root root 1970-01-01 00:00 sys
drwxrwxrwt root root 2008-03-18 18:04 tmp
dr-xr-xr-x root root 1970-01-01 00:00 proc
drwxr-xr-x root root 1970-01-01 00:00 sbin
drwx------ root root 1970-01-01 00:00 root
drwxr-xr-x root root 2008-03-18 17:33 dev

Processes running on the Android Device

The listing below is the output of the standard UNIX command ps (for listing active processes). Towards the end you can see Android related applications/processes. In this example, I am running the Notepad application; you can see the com.google.android.notepad process. Since the shell is being run here, you can see /system/bin/sh process. And, of course, there is the ps process for the command ps itself.

Code Listing 2. The processes running on Android

C:\Users\Administrator>adb -d 1 shell
# ps
ps
USER PID PPID VSIZE RSS WCHAN PC NAME
root 1 0 248 160 c0084edc 0000ae2c S /init
root 2 0 0 0 c0049168 00000000 S kthreadd
root 3 2 0 0 c003ad20 00000000 S ksoftirqd/0
root 4 2 0 0 c00460ac 00000000 S events/0
root 5 2 0 0 c00460ac 00000000 S khelper
root 8 2 0 0 c00460ac 00000000 S suspend/0
root 33 2 0 0 c00460ac 00000000 S kblockd/0
root 36 2 0 0 c00460ac 00000000 S cqueue/0
root 38 2 0 0 c0153ab8 00000000 S kseriod
root 76 2 0 0 c005eb48 00000000 S pdflush
root 77 2 0 0 c005eb48 00000000 S pdflush
root 78 2 0 0 c00624f8 00000000 S kswapd0
root 79 2 0 0 c00460ac 00000000 S aio/0
root 201 2 0 0 c0151168 00000000 S mtdblockd
root 220 2 0 0 c00460ac 00000000 S kmmcd
root 233 2 0 0 c00460ac 00000000 S rpciod/0
root 492 1 4420 188 ffffffff 0000e0e4 S /sbin/adbd
root 493 1 2824 300 ffffffff afe0c79c S /system/bin/usbd
root 494 1 644 228 c0179838 afe0ca9c S /system/bin/debuggerd
root 495 1 12564 608 ffffffff afe0c79c S /system/bin/rild
root 496 1 55540 14028 c0179838 afe0ca9c S zygote
root 497 1 21272 2168 ffffffff afe0c1fc S /system/bin/runtime
bluetooth 498 1 1224 776 c0084edc afe0d07c S /system/bin/dbus-daemon
root 517 1 114896 18720 ffffffff afe0c1fc S system_server
root 562 496 55540 7784 c01d9aac afe0cbfc S zygote
app_0 563 562 71444 14864 ffffffff afe0d204 S com.google.process.content
app_6 579 562 71812 13220 ffffffff afe0d204 S com.google.android.home
phone 581 562 81124 15728 ffffffff afe0d204 S com.google.android.phone
app_8 618 562 80392 13608 ffffffff afe0d204 S com.google.android.notepad
root 677 492 732 312 c00386cc afe0ceac S /system/bin/sh
root 678 677 840 324 00000000 afe0bfbc R ps

Some interesting Android Directories

Dalvik Cache

Dalvik is the virtual machine for Android. A Dalvik executable has the extension .dex. As you can see below, the directory /data/dalvik-cache has some of these dex files on a currently running device/emulator.

From the filenames, you can see that these files are obtained from .apk or .jar files (for example, NotesList.apk, core.jar). The extension .apk is from Android (stands for Android Package). And .jar is from Java (Java Archive)

From the file names, you can also see where (directory) these .apk or .jar files reside. For example, the applications are in \data\app directory (as shown in data@app@NotesList.apk@classes.dex). And the Android System files are in \system\framework or \system\app directories.

Code Listing 3. The Dalvik Cache

# pwd
pwd
/data/dalvik-cache

# ls
ls
data@app@NotesList.apk@classes.dex
system@framework@pm.jar@classes.dex
system@framework@am.jar@classes.dex
system@app@ContactsProvider.apk@classes.dex
system@app@gtalkservice.apk@classes.dex
system@app@TelephonyProvider.apk@classes.dex
system@app@SettingsProvider.apk@classes.dex
system@app@Phone.apk@classes.dex
system@app@MediaProvider.apk@classes.dex
system@app@MasfProxyService.apk@classes.dex
system@app@Maps.apk@classes.dex
system@app@ImProvider.apk@classes.dex
system@app@Home.apk@classes.dex
system@app@GoogleAppsProvider.apk@classes.dex
system@app@GoogleApps.apk@classes.dex
system@app@GTalkSettings.apk@classes.dex
system@app@Fallback.apk@classes.dex
system@app@Development.apk@classes.dex
system@app@Contacts.apk@classes.dex
system@app@Browser.apk@classes.dex
system@framework@framework-tests.jar@classes.dex
system@framework@framework.jar@classes.dex
system@framework@ext.jar@classes.dex
system@framework@core.jar@classes.dex

The app Directory

The applications are in the /data/app directory. This is where the .apk files are pushed to. For example, if you run/debug NotesList application from Eclipse, you might see the following comments in the console about pushing the .apk file.

Code Listing 4. Pushing the .apk file from Eclipse

[2008-03-18 11:21:08 - NotesList] New emulator found: emulator-tcp-5555
[2008-03-18 11:22:46 - NotesList] HOME is up on device ’emulator-tcp-5555’
[2008-03-18 11:22:46 - NotesList] Pushing NotesList.apk to /data/app on device ’emulator-tcp-5555’

On the device itself, you will see the apk files in the /data/app directory.

Code Listing 5. The .apk files on the device

# pwd
pwd
/data/app
# ls -l
ls -l
-rw-rw-rw- root root 25791 2008-03-18 18:22 NotesList.apk
-rw-r--r-- system system 4337675 2008-02-29 01:19 ApiDemos.apk

Related Articles

Using ADB – Android Debug Bridge

Peering into an Android Device via the shell

Using SQLite from Shell in Android

Bookmark and Share This

More Articles With Similar Tags
icon-android-debug-toolbar.jpg
This article gives some quick pointers on how to start debugging an Android application, along with where to put the breakpoints and how to change the emulator sizes from within Eclipse.
icon-android-safari-browser-user-agent-string.jpg
This article talks about the basics of the browser (including the user agent string) used in the Android platform.
This article talks about various aspects of creating an SQLite database. It also uses Android SQLite shell as an example.
This article explains how to get pretty / nice output from the SQLite command line shell program.
icon-android-emulator-hvga-p-lunar-lander.jpg
See the images of various skins and screens of Android emulator with games (Lunar Lander and Snake) in them. Also shows how to change the skins of Android emulator while debugging your program.
About  Contact  Privacy Policy  Site Map