1page.title=Source Code Overview 2pdk.version=1.0 3doc.type=porting 4@jd:body 5 6<a name="toc"/> 7<div style="padding:10px"> 8<a href="#androidSourceCodeDirectories">Introduction</a><br/> 9<a href="#Android_Source">Android Source</a><br/><div style="padding-left:40px"> 10 11<a href="#androidSourceCodeDirectoriesKernel">Linux Kernel</a><br/> 12<a href="#androidSourceCodeDirectoriesDevice">Android Platform and Applications</a><br/></div> 13<a href="#androidSourceGuidelines">Adding Source Code</a><br/></div> 14 15<a name="androidSourceCodeDirectories"></a><h2>Introduction</h2> 16 17<p>Android source code is maintained in two code bases: the Android Linux kernel (<code>kernel</code> directory) and Android platform and applications (<code>device</code> directory). This document provides a high-level introduction to the source code organization and an overview of the major components of each primary directory.</p> 18 19<a name="Android_Source"></a><h2>Android Source</h2> 20 21 22<a name="androidSourceCodeDirectoriesKernel"></a><h3>Linux Kernel</h3> 23 24<p>The Android Linux kernel includes enhancements to the Linux 2.6 kernel that provide additional drivers to support the Android platform, including:</p> 25<ul> 26 <li>Binder: an OpenBinder-based driver to facilitate inter-process communication (IPC) in the Android platform.</li> 27 <li>Android Power Management: a light weight power management driver built on top of standard Linux power management but optimized for embedded systems.</li> 28 <li>Low Memory Killer: Based on hints from the userspace, the low memory killer can kill off processes to free up memory as necessary. It is designed to provide more flexibility than the Out Of Memory (OOM) killer in the standard kernel.</li> 29 <li>Logger: A light weight logging device used to capture system, radio, logdata, etc.</li> 30 <li>USB Gadget: Uses the USB function framework.</li> 31 <li>Android/PMEM: The PMEM (physical memory) driver is used to provide contiguous physical memory regions to userspace libraries that interact with the digital signal processor (DSP) and other hardware that cannot cope with scatter-gather.</li> 32 <li>Android Alarm: A driver which provides timers that can wake the device up from sleep and a monotonic timebase that runs while the device is asleep.</li> 33</ul> 34<p>Look for Android-specific enhancements in the following directories:</p> 35<p><ul> 36<li><code>/drivers/android</code></li> 37<li><code>/drivers/misc</code></li> 38<li><code>/include/linux</code></li> 39</ul> 40</p> 41 42 43<a name="androidSourceCodeDirectoriesDevice"></a><h3>Android Platform and Applications</h3> 44 45<p>The following list outlines the directory structure found within the <code>device</code> branch of Android source code:</p> 46 47 48<p><span class="lh2"><a name="gmapiMobileTagsListStart"></a></span> 49 50<ul> 51 52 53<li>apps 54Core Android applications such as Phone, Camera, and Calendar. 55</li> 56 57 58<li>boot 59Reference Android bootloader and other boot-related source code. 60</li> 61 62 63<li>commands 64Common Android commands, the most important of which is the runtime command, which does much of the initialization of the system. 65</li> 66 67 68<li>config 69System-wide makefiles and linker scripts. 70</li> 71 72 73<li>content 74Standard Android ContentProvider modules. 75</li> 76 77 78<li>dalvik 79Android runtime Virtual Machine (VM). 80</li> 81 82 83<li>data 84Fonts, keymaps, sounds, timezone information, etc. 85</li> 86 87 88<li>docs 89Full set of Android documentation. 90</li> 91 92 93<li>extlibs 94Non-Android libraries. This directory is intended to host unmodified external code. None of the libraries included within this directory rely on Android headers or libraries. 95</li> 96 97 98<li>ide 99Tools for support of the IDE's used to write Android applications. 100</li> 101 102 103<li>include 104Android system headers for inclusion. 105</li> 106 107 108<li>java 109Android core APIs, as well as some external libraries. 110</li> 111 112 113<li>libs 114Android-specific C++ based libraries. 115</li> 116 117 118<li>partner 119Project-specific source code for various proprietary components. 120</li> 121 122 123<li>prebuilt 124Prebuilt tools, like the toolchains and emulator binary. 125</li> 126 127 128<li>product 129Device-specific configuration files. This directory will include a subdirectory for each new device. 130</li> 131 132 133<li>samples 134Sample applications. 135</li> 136 137 138<li>servers 139C++ based system servers. 140</li> 141 142 143<li>system 144Core of the embedded Linux platform at the heart of Android. These essential bits are required for basic booting, operation, and debugging. 145</li> 146 147 148<li>tests 149Platform and application test cases. 150</li> 151 152 153<li>tools 154Tools for building and debugging Android (of particular interest for porting are "adb" and "emulator"). 155</li> 156 157 158 159<p><span class="lh2"><a name="gmapiMobileTagsListEnd"></a></span> 160 161</ul> 162 163 164<a name="androidSourceGuidelines"></a><h2>Adding Source Code</h2> 165 166<p>You can develop Android applications with the same standard tools you use to develop any Java application. The Android core libraries provide the functionality needed to build rich mobile applications and the Android development tools are designed to simplify running, debugging, and testing your applications.</p> 167 168<p>Add project-specific source code to the Android source tree under the <code>partner</code> directory in a directory specific to the application or service you are building. For example, all Google-specific applications would be placed under <code>vendor/google/</code>. A Google search application would be placed under <code>vendor/google/apps/Search</code>. 169<p>See <a href="build_new_device.html">Building Android for a new Mobile Device</a> for detailed instructions.</p> 170 171 172