Taking Advantage of Android Source Code

During these early releases of Android, documentation is a bit "wanting" in places. When you run into that situation, it is worthwhile exploring Android source code to fill the gaps.

The details of the Android source distribution are published at http://source.android. com. The code was open sourced around October 2008 (read the announcement at http:// source.android.com/posts/opensource). One of the Open Handset Alliance's goals was to make Android a free and fully customizable mobile platform. The announcement strongly suggests that the Android Platform is a fully capable mobile computing platform with no gaps. The open source model allows contributions from noncore team members within the public communities.

As indicated, Android is a platform and not just one project. You can see the scope and the number of projects at http://source.android.com/projects.

The source code of Android and all its projects is managed by the Git source-code control system. Git (http://git.or.cz/) is an open source source-control system designed to handle large and small projects with speed and convenience. The Linux kernel and Ruby on Rails projects also rely on Git for version control. The complete list of Android projects in the Git repository appears at http://android.git.kernel.org/.

You can download any of these projects using the tools provided by Git and described at the product's web site. Some of the primary projects include Dalvik, frameworks/base (the android.jar file), Linux kernel, and a number of external libraries such as Apache HTTP libraries (apache-http). The core Android applications are also hosted here. Some of these core applications include: AlarmClock, Browser, Calculator, Calendar, Camera, Contacts, Email, GoogleSearch, HTML Viewer, IM, Launcher, Mms, Music, PackageInstaller, Phone, Settings, SoundRecorder, Stk, Sync, Updater, and VoiceDialer.

The Android projects also include the "Provider" projects. "Provider" projects are like databases in Android that wrap their data into RESTful services. These projects are Calen-darProvider, ContactsProvider, DownloadProvider, DrmProvider, GoogleContactsProvider, GoogleSubscribedFeedsProvider, ImProvider, MediaProvider, SettingsProvider, Subscribed-FeedsProvider, and TelephonyProvider.

As a programmer, you will be most interested in the source code that makes up the android.jar file. (If you'd rather download the entire platform and build it yourself, refer to the documentation available at http://source.android.com/download.) You can download the source for this .jar file by typing in the following URL:



This is one of the general-purpose URLs you can use to download Git projects. On Windows, you can unzip this file using pkzip. Although you can download and unzip the source, it might be more convenient to just look at these files online if you don't need to debug the source code through your IDE. Git also allows you to do this. For example, you can browse through android.jar source files by visiting this URL:


However, you have to do some work after you visit this page. Pick grep from the dropdown list and enter some text in the search box. Click one of the resulting file names to open that source file in your browser. This facility is convenient for a quick lookup of source code.

At times the file you are looking for might not be in the frameworks/base directory or project. In that case, you need to find the list of projects and search each one step by step. The URL for this list is http://android.git.kernel.org/.

You cannot grep across all projects, so you will need to know which project belongs to which facility in Android. For example, the graphics-related libraries in the Skia project are available here:


0 0

Post a comment