\subsection{Various Java Services}

\begin{frame}
  \frametitle{Android Java Services}
  \begin{itemize}
  \item There are lots of services implemented in Java in Android
  \item They abstract most of the native features to make them
    available in a consistent way
  \item You get access to the system services using the
    \code{Context.getSystemService()} call
  \item You can find all the accessible services in the documentation 
    for this function
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{ActivityManager}
    \begin{itemize}
    \item Manages everything related to Android applications
      \begin{itemize}
      \item Starts Activities and Services through Zygote
      \item Manages their lifecycle
      \item Fetches content exposed through content providers
      \item Dispatches the implicit intents
      \item Adjusts the Low Memory Killer priorities
      \item Handles non responding applications
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{PackageManager}
    \begin{itemize}
    \item Exposes methods to query and manipulate already installed
      packages, so you can:
      \begin{itemize}
      \item Get the list of packages
      \item Get/Set permissions for a given package
      \item Get various details about a given application (name,
        uids, etc)
      \item Get various resources from the package
      \end{itemize}
    \item You can even install/uninstall an apk
      \begin{itemize}
      \item \code{installPackage}/\code{uninstallPackage} functions are
        hidden in the source code, yet \code{public}.
      \item You can't compile code that is calling directly these
        functions and they are not documented anywhere except in the
        code
      \item But you can call them through the Java \code{Reflection}
        API, if you have the proper permissions of course
      \end{itemize}
    \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{PowerManager}
  \begin{itemize}
  \item Abstracts the Wakelocks functionality
  \item Defines several states, but when a wakelock is grabbed,
    the CPU will always be on
    \begin{itemize}
    \item \code{PARTIAL_WAKE_LOCK}
      \begin{itemize}
      \item Only the CPU is on, screen and keyboard backlight are off
      \end{itemize}
    \item \code{SCREEN_DIM_WAKE_LOCK}
      \begin{itemize}
      \item Screen backlight is partly on, keyboard backlight is off
      \end{itemize}
    \item \code{SCREEN_BRIGHT_WAKE_LOCK}
      \begin{itemize}
      \item Screen backlight is on, keyboard backlight is off
      \end{itemize}
    \item \code{FULL_WAKE_LOCK}
      \begin{itemize}
      \item Screen and keyboard backlights are on
      \end{itemize}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{AlarmManager}
  \begin{itemize}
  \item Abstracts the Android timers
  \item Allows to set a one time timer or a repetitive one
  \item When a timer expires, the AlarmManager grabs a wakelock,
    sends an Intent to the corresponding application and releases
    the wakelock once the Intent has been handled
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{ConnectivityManager and WifiManager}
  \begin{itemize}
  \item ConnectivityManager
    \begin{itemize}
    \item Manages the various network connections
      \begin{itemize}
      \item Falls back to other connections when one fails
      \item Notifies the system when one becomes available/unavailable
      \item Allows the applications to retrieve various information
        about connectivity
      \end{itemize}
    \end{itemize}
  \item WifiManager
    \begin{itemize}
    \item Provides an API to manage all aspects of WiFi networks
      \begin{itemize}
      \item List, modify or delete already configured networks
      \item Get information about the current WiFi network if any
      \item List currently available WiFi networks
      \item Sends Intents for every change in WiFi state
      \end{itemize}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Example: Vibrator Service}
  \begin{center}
    \includegraphics[height=0.82\textheight]{slides/android-framework-java-services/overall-arch-vibrator.pdf}
  \end{center}
\end{frame}
