Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

An Introduction To Android


Published on

Presented by Brian Gupta ( and Nathan Freitas (

Learn more at

Android is a fully integrated and open source bundle of software significantly lowers the current costs of developing mobile devices (currently runs on a cellphone (the HTC Dream/T-Mobile G1), and a number of unofficial "ports". It consists of an operating system, middleware, a user-friendly interface and powerful applications.

The talk will start with a review of the internal architecture of the Android platform, breaking down the various components, and examine how they work. Then we will review the latest status of the open source project, including how to get and build the source code, and how to get involved.

Published in: Technology

An Introduction To Android

  1. 1. An overview of the Android Mobile Platform Brian Gupta & Nathan Freitas
  2. 2. Credits • Google Android team • Patrick Brady (Google) IO http:// physiology-of-an-android • Jay Freeman (Saurik) - Debian port • #android • JesusFreke /Disconnect
  3. 3. What is Android?
  4. 4. Internal Architecture
  5. 5. The Linux Kernel in Android • Android is based on the Linux kernel • Android is not Linux • No native windowing system • No glibc • Does not include full set of standard linux utilities • Kernel source at
  6. 6. Why Linux kernel for Android ? • Great memory and process management • Great permissions based security model • Proven driver model • Support for shared libraries • It’s already open source
  7. 7. Kernel Enhancements • Alarm • Ashmem • Binder • Power Management • Low memory killer • Kernel debugger • Logger
  8. 8. Kernel Enhancements: Binder • Driver to facilitate inter-process communication • High performance through shared memory • Per-process thread pool for processing requests • Reference counting and mapping of object references across processes • Synchronous calls between processes.
  9. 9. Binder in Action
  10. 10. Kernel Enhancements: Power Management • Built on top of standard Linux power management • More aggressive power manager • Components make requests to keep power via “wake locks” • Supports different types of wake locks • android.os.PowerManager
  11. 11. Libraries • Bionic Libc - custom libc implementation • Function Libraries • Native Servers • Hardware Abstraction Libraries
  12. 12. Libraries: Bionic Libc • Custom libc implementation optimized for embedded use • License BSD - Keeps GPL out of user space • Size: loads in each process so it needs to be small • Fast: limited CPU power (fast and small pthread implementation)
  13. 13. Libraries: WebKit • Based on the open source WebKit browser • Renders pages in full (desktop) mode • Full CSS, JavaScript, DOM, Ajax support • Single-column and Adaptive view rendering • Really powerful
  14. 14. Libraries: Media Framework • Based on PacketVideo OpenCORE platform • Supports standard audio, video and stills • Support for hardware/software codecs
  15. 15. Libraries: SQLite • Light-weight transactional data store • Back end for most platform data storage
  16. 16. Libraries: Flingers • Flingers are native servers that regulate all the heavy lifting for System I/O • Surface Flinger • Audio Flinger
  17. 17. Hardware Abstraction Layer • user space C/C++ library layer • Standard interface that Android drivers need to implement • Separates Android platform logic from hardware interface • Plugabble : e.g. you can plug in OSS below
  18. 18. Dalvik Virtual Machine • Android’s custom clean room implementation virtual machine • provides application portability • runs optimized file format (.dex) • Java .class/.jar files converted into .dex at build time • Supports multiple virtual machine processes per VM
  19. 19. Core Libraries: Overview • Data Structures • Utilities • File access • Network Access • Graphics •
  20. 20. Core platform services • Activity manager • Package manager • Window manager • Resource manager • Content manager
  21. 21. Hardware Services • Telephony • Location • Bluetooth • WiFi • USB • Sensor(s)
  22. 22. How Android boots
  23. 23. How Android boots: Init • Similar to linux based systems • At startup the boot loader loads the linux kernel and starts the init process
  24. 24. Runtime Walkthrough • USB Daemon (usbd) • Android debug bridge • Debugger Daemon • Radio interface layer daemon
  25. 25. Runtime Walkthrough (2) • Initializes service manager • Registers service manager as default context manager for Binder service
  26. 26. Init and Zygote • Init process starts with the zygote process • a nascent process which strats the dalvik VM instance • loads classes and listens on socket for request to spawn VM’s • Forks on request to create VM instances for managed processes • Copy-on-write to maximize re-use and minimize footprint
  27. 27. Layer Interaction • App -> Runtime Service -> Lib • App -> Runtime Service -> Native Service -> Lib • App -> Runtime Service -> Native Daemon -> Lib
  28. 28. Android: Open Source Project
  29. 29. Open Source Licenses • GPL - Linux Kernel and modules, bluez • BSD - Bionic • Apache - almost everything else
  30. 30. Closed source Components • HTC RIL (radio interface) library and data files (this is glue between the telephony layer in android and the AT/QMI control channels provided via GPL kernel drivers) • - Qualcomm/ati opengl ES library • - Qualcomm camera library • akmd - software to process and adjust compass/accelerometer events • Qualcomm h264 codec frontend (does some processing the dsp cannot do) • frontend HW accel codec • quot;Google appsquot; - Maps, Gmail, etc.
  31. 31. Project Status • Public vs private branches • Repo, git and Gerrit • Cupcake - development branch •
  32. 32. Getting the source •
  33. 33. Setting up your machine • Android development can be done on • Ubuntu 32 bit (preferred) • Ubuntu AMD64 • MacOS X •
  34. 34. Setting up your machine (2) • Steps (at a glance) • Non Android specific prereqs: • Install git and GPG for your platform • JDK 5.0, update 12 or higher. • The following packages: flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl. • You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. • libreadline • Install repo script • Create a working dir • repo init, repo sync • Build the code - quot;makequot;
  35. 35. How to get involved
  36. 36. Android Hardware
  37. 37. HTC Dream G1 vs ADP1
  38. 38. Netbooks
  39. 39. Ports • Nokia Internet Tablets • Sharp Zaurus • HTC Models • Kaiser,Vogue, Polaris, Titan, Raphael & Diamond • OpenMoko FreeRunner
  40. 40. Application Development Nathan Freitas
  41. 41. The Basics with (or w/o) Android 1.1 SDK r1 Eclipse IDE
  42. 42. Hello, Android 1) 3) 2)
  43. 43. All the Tools Fit.... Android Emulator: A virtual mobile device that runs on your computer.You use the emulator to design, debug, and test your applications in an actual Android run-time environment. Android Development Tools Plugin (for the Eclipse IDE): The ADT plugin adds powerful extensions to the Eclipse integrated environment, making creating and debugging your Android applications easier and faster. If you use Eclipse, the ADT plugin gives you an incredible boost in developing Android applications. Hierarchy Viewer: The Hierarchy Viewer tool allows you to debug and optimize your user interface. It provides a visual representation of your layout's hierarchy of Views and a magnified inspector of the current display with a pixel grid, so you can get your layout just right. Draw 9-patch: The Draw 9-patch tool allows you to easily create a NinePatch graphic using a WYSIWYG editor. It also previews stretched versions of the image, and highlights the area in which content is allowed. Dalvik Debug Monitor Service (ddms): Integrated with Dalvik, the Android platform's custom VM, this tool lets you manage processes on an emulator or device and assists in debugging.You can use it to kill processes, select a specific process to debug, generate trace data, view heap and thread information, take screenshots of the emulator or device, and more. Android Debug Bridge (adb): The adb tool lets you install your application's .apk files on an emulator or device and access the emulator or device from a command line. You can also use it to link a standard debugger to application code running on an Android emulator or device. Android Asset Packaging Tool (aapt): The aapt tool lets you create .apk files containing the binaries and resources of Android applications. mksdcard: Helps you create a disk image that you can use with the emulator, to simulate the presence of an external storage card (such as an SD card).
  44. 44. What’s in an App? Libraries Other Service Default Other Activities Other Intents Activity Activities Activities Content Providers Android Manifest Drawable Layouts Values Assets
  45. 45. Setting up the Manifest <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <manifest xmlns:android=quot;; package=quot;com.openideals.inaugreportquot; android:versionCode=quot;1quot; android:versionName=quot;1.0.0quot;> <uses-permission android:name=quot;android.permission.ACCESS_FINE_LOCATIONquot; /> <uses-permission android:name=quot;android.permission.ACCESS_COARSE_LOCATIONquot; /> <uses-permission android:name=quot;android.permission.INTERNETquot; /> <uses-permission android:name=quot;android.permission.READ_PHONE_STATEquot;/> <application android:icon=quot;@drawable/iconquot; android:label=quot;@string/app_namequot;> <activity android:name=quot;.InaugReportMainActivityquot; android:label=quot;@string/app_namequot;> <intent-filter> <action android:name=quot;android.intent.action.MAINquot; /> <category android:name=quot;android.intent.category.LAUNCHERquot; /> </intent-filter> </activity> <activity android:name=quot;; android:label=quot;@string/view_location_finderquot;/> <activity android:name=quot;.ReportFormActivityquot; android:label=quot;@string/view_report_formquot;/> <activity android:name=quot;; android:label=quot;@string/internal_web_viewquot; /> <activity android:name=quot;; android:label=quot;@string/geo_map_viewquot; /> <uses-library android:name=quot;; /> </application> </manifest>
  46. 46. Config & Code Editing
  47. 47. Laying it All Out <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <ScrollView xmlns:android=quot;; android:id=quot;@+id/scrollReportFormquot; android:layout_width=quot;fill_parentquot; android:layout_height=quot;fill_parentquot; android:background=quot;@drawable/inaug_report_no_seal_quot;> <LinearLayout android:id=quot;@+id/layoutReportFormquot; android:label=quot;Text Reportquot; android:layout_width=quot;fill_parentquot; android:layout_height=quot;wrap_contentquot; android:orientation=quot;verticalquot; android:gravity=quot;topquot; android:padding=quot;6.0spquot;> <TextView android:id=quot;@+id/labelTitlequot; android:layout_width=quot;wrap_contentquot; android:layout_height=quot;wrap_contentquot; android:text=quot;Title:quot;/> <EditText android:id=quot;@+id/entryTitlequot; android:layout_width=quot;fill_parentquot; android:layout_height=quot;wrap_contentquot; android:background=quot;@android:drawable/editbox_backgroundquot; /> <TextView android:id=quot;@+id/labelReportquot; android:layout_width=quot;wrap_contentquot; android:layout_height=quot;wrap_contentquot; android:paddingTop=quot;10dpquot; android:text=quot;Your Report:quot;/>
  48. 48. Activity: Do Something! /** Called when the activity is first created. */ @Override package com.openideals.inaugreport; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); import; import; setContentView(R.layout.reportform); import android.content.Intent; import android.location.Location; ((Button)findViewById(; import android.os.Bundle; ((Button)findViewById(; import android.os.Handler; import android.util.Log; import android.view.View; } import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.Spinner; Toast.makeText(getBaseContext(), quot;There was import android.widget.TextView; a problem submitting your report. Wait a second, and then import android.widget.Toast; try again!quot;, Toast.LENGTH_LONG).show(); import; import; import; private void showMain () } { Intent iMain = new Intent(this, LocationFinderActivity.class); startActivity(iMain); }
  49. 49. “DDMS” Debugger
  50. 50. Launch the Emulator!
  51. 51. Title Action Description Call android.intent.action.CALL Perform a call to someone specified by the data. Capture an image An application implementing this intent protocol allows the user to capture an image. Check for Update org.openintents.intents.CHECK_VERSION Preliminary protocol until Market improves update facitilities! Connect host org.theb.ssh.action.CONNECT_HOST Connect to a host. Create shortcut android.intent.action.CREATE_SHORTCUT Creates a shortcut on the main screen. Delete data android.intent.action.DELETE Delete the given data from its container. Dial a number android.intent.action.DIAL Dial a number as specified by the data. Edit data android.intent.action.EDIT Provide explicit editable access to the given data. Edit title Edit the title of a content. Encode Encode to barcode and display on screen. Environmental measurement com.borntotinker.intent.action.MEASURE An open ended intent to collect information from the android phone's surroundings. Flickr photo Show a flickr photo. Flickr stream Display a Flickr stream. Get content android.intent.action.GET_CONTENT Allow the user to select a particular kind of data and return it. Insert data android.intent.action.INSERT Insert an empty item into the given container. List all applications android.intent.action.ALL_APPS List all available applications. Main android.intent.action.MAIN Start as a main entry point, does not expect to receive data. Pick data android.intent.action.PICK Pick an item from the data, returning what was selected. Pick directory org.openintents.action.PICK_DIRECTORY Pick a directory (folder) through a file manager. Pick file org.openintents.action.PICK_FILE Pick a file through a file manager. Record sound android.provider.MediaStore.RECORD_SOUND Start SoundRecorder application to record sound. Resolve unresolved intents org.openintents.intents.UNRESOLVED_INTENT Delegates the user to a selection of possible applications that can resolve the given intent. Ringtone picker android.intent.action.RINGTONE_PICKER Show a ringtone picker. Scan Scan a barcode. Search android.intent.action.SEARCH Perform a search. Search book contents Google Book Search to search the contents of the book provided. Send a message to the given uri android.intent.action.SENDTO Send a message to someone specified by the data. Send data to someone android.intent.action.SEND Deliver some data to someone else. Send Twitter Message com.twidroid.SendTweet Send a Twitter/ Message thru Twidroid. Set wallpaper android.intent.action.SET_WALLPAPER Show settings for choosing wallpaper Share (through QR code) Display an item as QR code to scan with a phone. Show about dialog org.openintents.action.SHOW_ABOUT_DIALOG Show an about dialog to display information about your application. Show radar Display a radar like view centered around the current position and mark the given location Tag data org.openintents.action.TAG Add a tag to the given data. View data android.intent.action.VIEW Display the data to the user. Web search android.intent.action.WEB_SEARCH Perform a web search.
  52. 52. Geo Report App
  53. 53. GeoMapping Results
  54. 54. PhoneGap “webOS” • PhoneGap is a development tool that allows web developers to take advantage of the core features in the iPhone, Android, and Blackberry SDK using JavaScript.
  55. 55. Application Development Nathan Freitas blog: consulting:
  56. 56. Phone Hacking
  57. 57. Getting root By getting root you can update the bootloader and install custom firmware
  58. 58. Why custom firmware? • • Include bug fixes from git add useful kernel modules source (ext2, cifs, ++) unionfs • • Phone tethering hack Phone backup utility • • Multi-touch hack Change splash screen • • Install Debian userspace Custom compiled firmware • busybox + lots of commands • added a modified /system/ etc/security/cacerts.bks • added a /system/etc/ file, which contains resolv.conf file with the 4.2.2 additional certificates for family of DNS servers, to (courtesy of allow busybox's ping, wget, Disconnect) etc. to resolve host names
  59. 59. Getting and installing custom firmware Look for the latest JesusFreke custom firmware
  60. 60. Building custom firmware • Jesus Freke's instructions here: • showthread.php?t=466174 • Jesus Freke's latest build environment here: •
  61. 61. Installing Debian on the G1 Jay Freeman's (Saurik) instructions:
  62. 62. Resources • • FAQ Android New York City: androidfaq #androidnyc@irc.freenode .net • IRC • Mailing lists Text • General Android: • android/groups.html • Android application • development: #android- AndroidNYC Meetup androidnyc • Android hacking: • My email: