blob: e433f1c4a52af5811e24726e6558a91fb0176236 [file] [log] [blame]
page.title=Android Interfaces
@jd:body
<!--
Copyright 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol id="auto-toc">
</ol>
</div>
</div>
<p>
Android gives you the freedom to implement your own device specifications and
drivers. The hardware abstraction layer (HAL) provides a standard method for
creating software hooks between the Android platform stack and your hardware.
The Android operating system is also open source, so you can contribute your own
interfaces and enhancements.
</p>
<p>
To ensure devices maintain a high level of quality and offer a consistent user
experience, each device must pass tests in the compatibility test suite (CTS).
The CTS verifies devices meet a quality standard that ensures apps run reliably
and users have a good experience. For details on the CTS, see
<a href="{@docRoot}compatibility/index.html">Compatibility</a>.
</p>
<h2 id="Android system architecture">Android system architecture</h2>
<p>
Before porting Android to your hardware, take a moment to understand the Android
system architecture at a high level. Because your drivers and the HAL interact
with Android, knowing how Android works can help you navigate the many layers of
code in the Android Open Source Project (AOSP) source tree.
</p>
<img src="images/ape_fwk_all.png">
<p class="img-caption"><strong>Figure 1.</strong> Android System Architecture</p>
<h3 id="Application framework">Application framework</h3>
<p>
The application framework is used most often by application developers. As a
hardware developer, you should be aware of developer APIs as many map directly
to the underlying HAL interfaces and can provide helpful information about
implementing drivers.
</p>
<h3 id="Binder IPC">Binder IPC</h3>
<p>
The Binder Inter-Process Communication (IPC) mechanism allows the application
framework to cross process boundaries and call into the Android system services
code. This enables high level framework APIs to interact with Android system
services. At the application framework level, this communication is hidden from
the developer and things appear to "just work."
</p>
<h3 id="System services">System services</h3>
<p>
Functionality exposed by application framework APIs communicates with system
services to access the underlying hardware. Services are modular, focused
components such as Window Manager, Search Service, or Notification Manager.
Android includes two groups of services: <em>system</em> (services such as
Window Manager and Notification Manager) and <em>media</em> (services involved
in playing and recording media).
</p>
<h3 id="Hardware Abstraction Layer">Hardware abstraction layer (HAL)</h3>
<p>
The HAL is a standard interface that allows the Android system to call into the
device driver layer while being agnostic about the lower-level implementations
of drivers and hardware.
</p>
<img src="images/ape_fwk_hal.png">
<p class="img-caption"><strong>Figure 2.</strong> Hardware abstraction layer
(HAL) components</p>
<p>
You must implement the corresponding HAL (and driver) for the specific hardware
your product provides. HAL implementations are typically built into shared
library modules (<code>.so</code> files). Android does not mandate a standard
interaction between your HAL implementation and your device drivers, so you have
free reign to do what is best for your situation. However, to enable the Android
system to correctly interact with your hardware, you <strong>must</strong> abide
by the contract defined in each hardware-specific HAL interface.
</p>
<h3 id="Linux kernel">Linux Kernel</h3>
<p>
Developing your device drivers is similar to developing a typical Linux device
driver. Android uses a version of the Linux kernel with a few special additions
such as wake locks (a memory management system that is more agressive in
preserving memory), the Binder IPC driver, and other features important for a
mobile embedded platform. These additions are primarily for system functionality
and do not affect driver development.
<p>
You can use any version of the kernel as long as it supports the required
features (such as the binder driver). However, we recommend using the latest
version of the Android kernel. For details on the latest Android kernel, see <a href="{@docRoot}source/building-kernels.html" >Building Kernels</a>.
</p>