Clay Murphy | f9d451e | 2014-10-21 18:11:12 -0700 | [diff] [blame] | 1 | page.title=Android Interfaces |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 2 | @jd:body |
| 3 | |
| 4 | <!-- |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 5 | Copyright 2015 The Android Open Source Project |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 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 | |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 27 | <p> |
| 28 | Android gives you the freedom to implement your own device specifications and |
| 29 | drivers. The hardware abstraction layer (HAL) provides a standard method for |
| 30 | creating software hooks between the Android platform stack and your hardware. |
| 31 | The Android operating system is also open source, so you can contribute your own |
| 32 | interfaces and enhancements. |
| 33 | </p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 34 | |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 35 | <p> |
| 36 | To ensure devices maintain a high level of quality and offer a consistent user |
| 37 | experience, each device must pass tests in the compatibility test suite (CTS). |
| 38 | The CTS verifies devices meet a quality standard that ensures apps run reliably |
| 39 | and users have a good experience. For details on the CTS, see |
| 40 | <a href="{@docRoot}compatibility/index.html">Compatibility</a>. |
| 41 | </p> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 42 | |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 43 | <h2 id="Android system architecture">Android system architecture</h2> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 44 | |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 45 | <p> |
| 46 | Before porting Android to your hardware, take a moment to understand the Android |
| 47 | system architecture at a high level. Because your drivers and the HAL interact |
| 48 | with Android, knowing how Android works can help you navigate the many layers of |
| 49 | code in the Android Open Source Project (AOSP) source tree. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 50 | </p> |
| 51 | |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 52 | <img src="images/ape_fwk_all.png"> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 53 | |
| 54 | <p class="img-caption"><strong>Figure 1.</strong> Android System Architecture</p> |
| 55 | |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 56 | <h3 id="Application framework">Application framework</h3> |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 57 | <p> |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 58 | The application framework is used most often by application developers. As a |
| 59 | hardware developer, you should be aware of developer APIs as many map directly |
| 60 | to the underlying HAL interfaces and can provide helpful information about |
| 61 | implementing drivers. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 62 | </p> |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 63 | |
| 64 | <h3 id="Binder IPC">Binder IPC</h3> |
| 65 | <p> |
| 66 | The Binder Inter-Process Communication (IPC) mechanism allows the application |
| 67 | framework to cross process boundaries and call into the Android system services |
| 68 | code. This enables high level framework APIs to interact with Android system |
| 69 | services. At the application framework level, this communication is hidden from |
| 70 | the developer and things appear to "just work." |
Clay Murphy | 768b82a | 2013-11-12 11:32:41 -0800 | [diff] [blame] | 71 | </p> |
Heidi von Markham | a848162 | 2015-04-13 12:26:23 -0700 | [diff] [blame] | 72 | |
| 73 | <h3 id="System services">System services</h3> |
| 74 | <p> |
| 75 | Functionality exposed by application framework APIs communicates with system |
| 76 | services to access the underlying hardware. Services are modular, focused |
| 77 | components such as Window Manager, Search Service, or Notification Manager. |
| 78 | Android includes two groups of services: <em>system</em> (services such as |
| 79 | Window Manager and Notification Manager) and <em>media</em> (services involved |
| 80 | in playing and recording media). |
| 81 | </p> |
| 82 | |
| 83 | <h3 id="Hardware Abstraction Layer">Hardware abstraction layer (HAL)</h3> |
| 84 | <p> |
| 85 | The HAL is a standard interface that allows the Android system to call into the |
| 86 | device driver layer while being agnostic about the lower-level implementations |
| 87 | of drivers and hardware. |
| 88 | </p> |
| 89 | |
| 90 | <img src="images/ape_fwk_hal.png"> |
| 91 | |
| 92 | <p class="img-caption"><strong>Figure 2.</strong> Hardware abstraction layer |
| 93 | (HAL) components</p> |
| 94 | |
| 95 | <p> |
| 96 | You must implement the corresponding HAL (and driver) for the specific hardware |
| 97 | your product provides. HAL implementations are typically built into shared |
| 98 | library modules (<code>.so</code> files). Android does not mandate a standard |
| 99 | interaction between your HAL implementation and your device drivers, so you have |
| 100 | free reign to do what is best for your situation. However, to enable the Android |
| 101 | system to correctly interact with your hardware, you <strong>must</strong> abide |
| 102 | by the contract defined in each hardware-specific HAL interface. |
| 103 | </p> |
| 104 | |
| 105 | <h3 id="Linux kernel">Linux Kernel</h3> |
| 106 | <p> |
| 107 | Developing your device drivers is similar to developing a typical Linux device |
| 108 | driver. Android uses a version of the Linux kernel with a few special additions |
| 109 | such as wake locks (a memory management system that is more agressive in |
| 110 | preserving memory), the Binder IPC driver, and other features important for a |
| 111 | mobile embedded platform. These additions are primarily for system functionality |
| 112 | and do not affect driver development. |
| 113 | |
| 114 | <p> |
| 115 | You can use any version of the kernel as long as it supports the required |
| 116 | features (such as the binder driver). However, we recommend using the latest |
| 117 | version of the Android kernel. For details on the latest Android kernel, see <a href="{@docRoot}source/building-kernels.html" >Building Kernels</a>. |
| 118 | </p> |