\subsection{Hardware Abstraction Layer}
\begin{frame}
  \frametitle{Hardware Abstraction Layers}
  \begin{itemize}
  \item Usually, the kernel already provides a HAL for userspace
  \item However, from Google's point of view, this HAL is not sufficient and
    suffers some restrictions, mostly:
    \begin{itemize}
    \item Depending on the subsystem used in the kernel, the userspace
      interface differs
    \item All the code in the kernel must be GPL-licensed
    \end{itemize}
  \item Google implemented its HAL with dynamically loaded userspace libraries
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Library naming}
  \begin{itemize}
  \item It follows the same naming scheme as for init: the generic
    implementation is called \code{libfoo.so} and the hardware-specific
    one \code{libfoo.hardware.so}
  \item The name of the hardware is looked up with the following properties:
    \begin{itemize}
    \item \code{ro.hardware}
    \item \code{ro.product.board}
    \item \code{ro.board.platform}
    \item \code{ro.arch}
    \end{itemize}
  \item The libraries are then searched for in the directories:
    \begin{itemize}
    \item \code{/vendor/lib/hw}
    \item \code{/system/lib/hw}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Various layers}
  \begin{itemize}
  \item Audio (\code{libaudio.so}) configuration, mixing, noise
    cancellation, etc.
    \begin{itemize}
    \item \code{hardware/libhardware_legacy/include/hardware_legacy/AudioHardwareInterface.h}
    \end{itemize}
  \item Graphics (\code{gralloc.so}, \code{copybit.so},
    \code{libhgl.so}) handles graphic memory buffer allocations,
    OpenGL implementation, etc.
    \begin{itemize}
    \item \code{libhgl.so} should be provided by your vendor
    \item \code{hardware/libhardware/include/gralloc.h}
    \item \code{hardware/libhardware/include/copybit.h}
    \end{itemize}
  \item Camera (\code{libcamera.so}) handles the camera functions:
    autofocus, take a picture, etc.
    \begin{itemize}
    \item \code{frameworks/base/include/camera/CameraHardwareInterface.h}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Various layers}
  \begin{itemize}
  \item GPS (\code{libgps.so}) configuration, data acquisition
    \begin{itemize}
    \item \code{hardware/libhardware/include/hardware/gps.h}
    \end{itemize}
  \item Lights (\code{liblights.so}) Backlight and LEDs management
    \begin{itemize}
    \item \code{hardware/libhardware/include/lights.h}
    \end{itemize}
  \item Sensors (\code{libsensors.so}) handles the various sensors on
    the device: Accelerometer, Proximity Sensor, etc.
    \begin{itemize}
    \item \code{hardware/libhardware/include/sensors.h}
    \end{itemize}
  \item Radio Interface (\code{libril-vendor-version.so}) manages all
    the communications between the baseband and \code{rild}
    \begin{itemize}
    \item You can set the name of the library with the \code{rild.lib} and
      \code{rild.libargs} properties to find the library
    \item \code{hardware/ril/include/telephony/ril.h}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Example: rild}
  \begin{center}
    \includegraphics[height=0.8\textheight]{slides/android-native-layer-hal/rild-architecture.pdf}
  \end{center}
\end{frame}
