23
Stack Jackson F. De A. Mafra Curso: Desenvolvimento Mobile Android

Curso de Desenvolvimento Mobile - Android - Stack

Embed Size (px)

Citation preview

Page 1: Curso de Desenvolvimento Mobile - Android - Stack

Stack

Jackson F. De A. Mafra

Curso: Desenvolvimento Mobile

Android

Page 2: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 3: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 4: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Linux

PortabilityLinux 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.

Page 5: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Linux

SecurityLinux 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.

Page 6: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Linux

FeaturesThe 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.

Page 7: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 8: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 9: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 10: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 11: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 12: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

Binder

A very fast inter-process communication mechanism that allows for one Android app to talk to another.

Page 13: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

Framework librariesVarious libraries designed to support system services, such as location, media, package installer, telephony, WiFi, voip, and so on.

Page 14: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

WebkitA fast web-rendering engine used by Safari, Chrome, and other browsers.

Page 15: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

SQLiteA full-featured SQL database that the Android app framework exposes to applica‐ tions.

Page 16: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

Apache HarmonyAn open source implementation of Java libraries.

Page 17: Curso de Desenvolvimento Mobile - Android - Stack

The Stack| Native Libraries

OpenGL3D graphics libraries.

Page 18: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 19: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 20: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 21: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 22: Curso de Desenvolvimento Mobile - Android - Stack

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.

Page 23: Curso de Desenvolvimento Mobile - Android - Stack

Stack

Jackson F. De A. Mafra

Curso: Desenvolvimento Mobile

Android

A