Stack
Jackson F. De A. Mafra
Curso: Desenvolvimento Mobile
Android
The Stack| Stack Overview
The Android operating system is like a cake consisting of
various layers. Each layer has its own characteristics and
purpose—but the layers are not always cleanly separated and
often seep into one another.
The Stack| Linux
Android is built on top of the Linux kernel. Linux is a great
operating system, and is the poster child of open source. Its
kernel has been hardened and tightened over the years by
many engineers continually improving it.
The Stack| Linux
Portability
Linux is a flexible platform that is relatively easy to port to
various hardware architectures. What Linux brings to Android
is a level of hardware abstraction. Because Android is based
on the Linux kernel, we don’t have to worry too much about
underlying hardware features. Most low-level parts of Linux
have been written in fairly portable C code, which allows for
third parties to port Android to a variety of devices.
The Stack| Linux
Security
Linux is a highly secure system, having been tried and tested
through some very harsh environments over the decades.
Android relies heavily on Linux for security, and all Android
applications run as separate Linux processes with permissions
set by the Linux system. As such, Android passes many
security concerns to the underlying Linux system. Unlike some
other Java-based mobile platforms, in Android the kernel is
the sole enforcer of Android permissions. This allows for a
simple, yet very powerful, security mechanism. It also allows
Android apps access to native code, such as fast C
implementations of various libraries via the Java Native
Interface.
The Stack| Linux
Features
The Linux kernel comes with a lot of very useful features.
Android leverages many of them, such as support for memory
and power management, as well as networking and radio
functionality.
The Stack| Android != Linux
Keep in mind that Android is not just another flavor of Linux,
in the way that Ubuntu, Fedora, or Red Hat are. Many things
you’d expect from a typical Linux distribution aren’t available
in Android, such as the X11 window manager, the ability to
add a person as a Linux, or even the glibc standard C library.
On the other hand, Android adds quite a bit to the Linux
kernel, such as an improved power management that is well-
suited for mobile battery-powered devices, a very fast
interprocess communication mechanism based on Binder, and
a mechanism for sand‐ boxing applications so they are
isolated from one another.
The Stack| Native Layer
The native layer is a set of code that is written mostly in
C/C++. Unlike the Linux layer, the native layer is in the so-
called user space. This part of the stack consists of couple of
different parts, such as HAL, native libraries, native daemons,
and native tools.
The Stack| HAL
Android was designed to run on many different hardware
configurations, and an An‐ droid app shouldn’t care about
specifics of certain boards. To solve this problem, An‐ droid
abstracts each major device driver with a shared native library.
HAL basically provides the unified device driver model that is
missing in standard Linux. This is its primary role. Secondarily,
it has an additional feature of keeping the GPL code out of the
user space. Basically, most device drivers are implemented as
Linux kernel modules, and are often built into the kernel itself.
The Stack| Native Libraries
The native libraries are C/C++ libraries. Their primary job is to
support the Android Application Framework layer, which we’ll
explore next.
Some of these libraries are purpose-built for the Android OS,
whereas others are often taken from the open source
community in order to complete the operating system.
The Stack| Native Libraries
Bionic
An Android-specific implementation of libc library, derived
from the BSD project and updated for needs of Android OS.
Bionic also helps keep LGPL code out of user space.
The Stack| Native Libraries
Binder
A very fast inter-process communication mechanism that
allows for one Android app to talk to another.
The Stack| Native Libraries
Framework libraries
Various libraries designed to support system services, such as
location, media, package installer, telephony, WiFi, voip, and
so on.
The Stack| Native Libraries
Webkit
A fast web-rendering engine used by Safari, Chrome, and
other browsers.
The Stack| Native Libraries
SQLite
A full-featured SQL database that the Android app framework
exposes to applica‐ tions.
The Stack| Native Libraries
Apache Harmony
An open source implementation of Java libraries.
The Stack| Native Libraries
OpenGL
3D graphics libraries.
The Stack| Native Daemons
Native daemons are executable code that usually runs to
support some kind of system service. Examples of native
daemons include:
Service Manager (servicemanager)
The umbrella process running all other framework services. It
is the most critical native daemon.
Radio interface layer daemon (rild)
Responsible for supporting the telephony functionality via
GSP or CDMA, usually.
The Stack| Native Daemons
Installation daemon (installd)
Supports management of apps, including installation,
upgrades, as well as granting of permissions.
Media server (mediaserver)
Supports camera, audio, and other media services.
Android Debug Bridge (adbd)
Supports developer connectivity from your PC to the device
(including the emulator) so that you can develop apps for
Android.
The Stack| Native Tools
Native tools include many standard Linux command-line tools, as
well as the init process that is responsible for starting all the native
daemons, among other things.
Like most other operating systems, Android has a command-line
shell where developers can poke around the system.
On Android, developers access this shell via ADB, which we’ll go
over later. However, if you are an experienced Linux user, you’ll
quickly notice that the set of commands available in the standard
Android release is far smaller than other typical Linux distributions.
That’s because Android uses toolbox to support most of these
command-line tools, such as cd, ls, ps, top, df, and so on. If you are
used to Linux, do not expect to find grep, vi, less, more, or any other
of the common developer tools.
The Stack| Dalvik
Dalvik is a purpose-built virtual machine designed specifically for
Android.
The Java virtual machine (VM) was designed to be a one-size-fits-all
solution, and the Dalvik team felt it could do a better job by
focusing strictly on mobile devices. It looked at which constraints
specific to a mobile environment are least likely to change in the
future. One of these is the limited battery life, and the other is the
size of ever-shrinking mobile devices. Dalvik was built from the
ground up to address those constraints.
The Stack| Android and Java
In Java, you write your Java source file, compile it into Java byte
code using the Java compiler, and then run this byte code on the
Java VM. In Android, things are different. You still write the Java
source file, and you still compile it to Java byte code using the same
Java compiler. But at that point, you recompile it once again to
Dalvik byte code using the Dalvik compiler. It is this Dalvik byte
code that is then executed on the Dalvik VM.
Stack
Jackson F. De A. Mafra
Curso: Desenvolvimento Mobile
Android

Curso de Desenvolvimento Mobile - Android - Stack

  • 1.
    Stack Jackson F. DeA. Mafra Curso: Desenvolvimento Mobile Android
  • 2.
    The Stack| StackOverview The Android operating system is like a cake consisting of various layers. Each layer has its own characteristics and purpose—but the layers are not always cleanly separated and often seep into one another.
  • 3.
    The Stack| Linux Androidis built on top of the Linux kernel. Linux is a great operating system, and is the poster child of open source. Its kernel has been hardened and tightened over the years by many engineers continually improving it.
  • 4.
    The Stack| Linux Portability Linuxis a flexible platform that is relatively easy to port to various hardware architectures. What Linux brings to Android is a level of hardware abstraction. Because Android is based on the Linux kernel, we don’t have to worry too much about underlying hardware features. Most low-level parts of Linux have been written in fairly portable C code, which allows for third parties to port Android to a variety of devices.
  • 5.
    The Stack| Linux Security Linuxis a highly secure system, having been tried and tested through some very harsh environments over the decades. Android relies heavily on Linux for security, and all Android applications run as separate Linux processes with permissions set by the Linux system. As such, Android passes many security concerns to the underlying Linux system. Unlike some other Java-based mobile platforms, in Android the kernel is the sole enforcer of Android permissions. This allows for a simple, yet very powerful, security mechanism. It also allows Android apps access to native code, such as fast C implementations of various libraries via the Java Native Interface.
  • 6.
    The Stack| Linux Features TheLinux kernel comes with a lot of very useful features. Android leverages many of them, such as support for memory and power management, as well as networking and radio functionality.
  • 7.
    The Stack| Android!= Linux Keep in mind that Android is not just another flavor of Linux, in the way that Ubuntu, Fedora, or Red Hat are. Many things you’d expect from a typical Linux distribution aren’t available in Android, such as the X11 window manager, the ability to add a person as a Linux, or even the glibc standard C library. On the other hand, Android adds quite a bit to the Linux kernel, such as an improved power management that is well- suited for mobile battery-powered devices, a very fast interprocess communication mechanism based on Binder, and a mechanism for sand‐ boxing applications so they are isolated from one another.
  • 8.
    The Stack| NativeLayer The native layer is a set of code that is written mostly in C/C++. Unlike the Linux layer, the native layer is in the so- called user space. This part of the stack consists of couple of different parts, such as HAL, native libraries, native daemons, and native tools.
  • 9.
    The Stack| HAL Androidwas designed to run on many different hardware configurations, and an An‐ droid app shouldn’t care about specifics of certain boards. To solve this problem, An‐ droid abstracts each major device driver with a shared native library. HAL basically provides the unified device driver model that is missing in standard Linux. This is its primary role. Secondarily, it has an additional feature of keeping the GPL code out of the user space. Basically, most device drivers are implemented as Linux kernel modules, and are often built into the kernel itself.
  • 10.
    The Stack| NativeLibraries The native libraries are C/C++ libraries. Their primary job is to support the Android Application Framework layer, which we’ll explore next. Some of these libraries are purpose-built for the Android OS, whereas others are often taken from the open source community in order to complete the operating system.
  • 11.
    The Stack| NativeLibraries Bionic An Android-specific implementation of libc library, derived from the BSD project and updated for needs of Android OS. Bionic also helps keep LGPL code out of user space.
  • 12.
    The Stack| NativeLibraries Binder A very fast inter-process communication mechanism that allows for one Android app to talk to another.
  • 13.
    The Stack| NativeLibraries Framework libraries Various libraries designed to support system services, such as location, media, package installer, telephony, WiFi, voip, and so on.
  • 14.
    The Stack| NativeLibraries Webkit A fast web-rendering engine used by Safari, Chrome, and other browsers.
  • 15.
    The Stack| NativeLibraries SQLite A full-featured SQL database that the Android app framework exposes to applica‐ tions.
  • 16.
    The Stack| NativeLibraries Apache Harmony An open source implementation of Java libraries.
  • 17.
    The Stack| NativeLibraries OpenGL 3D graphics libraries.
  • 18.
    The Stack| NativeDaemons Native daemons are executable code that usually runs to support some kind of system service. Examples of native daemons include: Service Manager (servicemanager) The umbrella process running all other framework services. It is the most critical native daemon. Radio interface layer daemon (rild) Responsible for supporting the telephony functionality via GSP or CDMA, usually.
  • 19.
    The Stack| NativeDaemons Installation daemon (installd) Supports management of apps, including installation, upgrades, as well as granting of permissions. Media server (mediaserver) Supports camera, audio, and other media services. Android Debug Bridge (adbd) Supports developer connectivity from your PC to the device (including the emulator) so that you can develop apps for Android.
  • 20.
    The Stack| NativeTools Native tools include many standard Linux command-line tools, as well as the init process that is responsible for starting all the native daemons, among other things. Like most other operating systems, Android has a command-line shell where developers can poke around the system. On Android, developers access this shell via ADB, which we’ll go over later. However, if you are an experienced Linux user, you’ll quickly notice that the set of commands available in the standard Android release is far smaller than other typical Linux distributions. That’s because Android uses toolbox to support most of these command-line tools, such as cd, ls, ps, top, df, and so on. If you are used to Linux, do not expect to find grep, vi, less, more, or any other of the common developer tools.
  • 21.
    The Stack| Dalvik Dalvikis a purpose-built virtual machine designed specifically for Android. The Java virtual machine (VM) was designed to be a one-size-fits-all solution, and the Dalvik team felt it could do a better job by focusing strictly on mobile devices. It looked at which constraints specific to a mobile environment are least likely to change in the future. One of these is the limited battery life, and the other is the size of ever-shrinking mobile devices. Dalvik was built from the ground up to address those constraints.
  • 22.
    The Stack| Androidand Java In Java, you write your Java source file, compile it into Java byte code using the Java compiler, and then run this byte code on the Java VM. In Android, things are different. You still write the Java source file, and you still compile it to Java byte code using the same Java compiler. But at that point, you recompile it once again to Dalvik byte code using the Dalvik compiler. It is this Dalvik byte code that is then executed on the Dalvik VM.
  • 23.
    Stack Jackson F. DeA. Mafra Curso: Desenvolvimento Mobile Android