Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 1 | page.title=Porting Android to Devices |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
| 5 | Copyright 2010 The Android Open Source Project |
| 6 | |
| 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | you may not use this file except in compliance with the License. |
| 9 | You may obtain a copy of the License at |
| 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
| 13 | Unless required by applicable law or agreed to in writing, software |
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | See the License for the specific language governing permissions and |
| 17 | limitations under the License. |
| 18 | --> |
| 19 | <div id="qv-wrapper"> |
| 20 | <div id="qv"> |
| 21 | <h2>In this document</h2> |
| 22 | <ol id="auto-toc"> |
| 23 | </ol> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
| 27 | <p>Android provides you with the freedom to implement your own device specifications |
| 28 | and the drivers to support them. The hardware abstraction layer (HAL) gives you a |
| 29 | standard way to create software hooks in between the Android |
| 30 | platform stack and your hardware. In addition, the Android operating system |
| 31 | is open-sourced to help you through your device's bringup.</p> |
| 32 | |
| 33 | <p>To ensure that your devices maintain a high level of quality and offers a consistent |
| 34 | experience for your users, they must must also |
| 35 | pass the tests in the compatibility test suite (CTS). CTS ensures that anyone |
| 36 | building a device meets a quality standard that ensures apps run reliabaly well |
| 37 | and gives users a good experience. For more information, see the |
| 38 | <a href="{@docRoot}compatibility/index.html">Compatibility</a> section.</p> |
| 39 | |
| 40 | <h2>Android Low-Level System Architecture</h2> |
| 41 | |
| 42 | <p>Before you begin porting Android to your hardware, it is important to have an |
| 43 | understanding of how Android works at a high level. Because your drivers and HAL code interact |
| 44 | with many layers of Android code, this understanding can help you find |
| 45 | your way through the many layers of code that are available to you through the AOSP |
| 46 | (Android Open Source Project) source tree. The following diagram shows a system |
| 47 | level view of how Android works: |
| 48 | </p> |
| 49 | |
| 50 | <img src="images/system-architecture.png"> |
| 51 | |
| 52 | <p class="img-caption"><strong>Figure 1.</strong> Android System Architecture</p> |
| 53 | |
| 54 | <h4>Application framework</h4> |
| 55 | <p>This is the level that most application developers concern themselves with. You should be |
| 56 | aware of the APIs available to developers as many of them map 1:1 to the underlying HAL |
| 57 | interfaces and can provide information as to how to implement your driver. |
| 58 | </p> |
| 59 | |
| 60 | <h4>Binder IPC</h4> |
| 61 | <p> |
| 62 | The Binder Inter-Process Communication mechanism allows the application framework to |
| 63 | cross process boundaries and call into the Android system services code. This basically allows |
| 64 | high level framework APIs to interact with Android's system services. At the application framework level, all |
| 65 | of this communication is hidden from the developer and things appear to "just work." |
| 66 | </p> |
| 67 | |
| 68 | <h4>System services</h4> |
| 69 | <p>Most of the functionality exposed through the application framework APIs must |
| 70 | communicate with some sort of system service to access the underlying hardware. Services |
| 71 | are divided into modular components with focused functionality |
| 72 | such as the Window Manager, Search Service, or Notification Manager. System services are grouped |
| 73 | into two buckets: system and media. The system services include things such as the Window or |
| 74 | Notification Manager. The media services include all the services involved in playing and |
| 75 | recording media. |
| 76 | </p> |
| 77 | |
| 78 | <h4>Hardware abstraction layer (HAL)</h4> |
| 79 | <p>The HAL serves as a standard interface that allows the Android system to call into the device |
| 80 | driver layer while being agnostic about the lower-level implementations of your drivers and hardware. |
| 81 | You must implement the corresponding HAL (and driver) for the particular piece of hardware that your product |
| 82 | provides. Android does not mandate a standard interaction between your HAL implementation and your device drivers, so |
| 83 | you have free reign to do what is best for your situation. However, you must abide by the contract |
| 84 | defined in each hardware-specific HAL interface for the Android system to be able |
| 85 | to correctly interact with your hardware. HAL implementations are typically built into |
| 86 | shared library modules (<code>.so</code> files). |
| 87 | </p> |
| 88 | <h4>Linux Kernel</h4> |
| 89 | <p>For the most part, developing your device drivers is the same as developing a typical Linux device driver. |
| 90 | Android uses a specialized version of the Linux kernel with a few special additions such as |
| 91 | wakelocks, a memory management system that is more agressive in preserving memory, |
| 92 | the Binder IPC driver, and other features that are important for a mobile embedded platform like Android. |
| 93 | These additions have less to do with driver development than with the system's functionality. The PDK |
| 94 | does not provide kernel sources, so you must provide your own. You can use any version of the kernel that |
| 95 | you want as long as it supports the required features, such as the binder driver. However, we recommend |
| 96 | using the latest version of the Android kernel. For the latest Android kernel, see |
| 97 | <a href="{@docRoot}source/building-kernels.html" >Building Kernels</a>. |
| 98 | </p> |