00 Android Overview

Embed Size (px)

Citation preview

  • 7/29/2019 00 Android Overview

    1/33

    Android

    InternalsDao Thanh Chung CSLab30/9/2011Email: [email protected]

    Android Internals - @chung_sfc 1

  • 7/29/2019 00 Android Overview

    2/33

    Rumors

    10/2008 released Sales grew by nearly 900% from 2009 5/11 : 294.730 apps (vs iOS 381.062 apps)

    Android Internals - @chung_sfc 2

  • 7/29/2019 00 Android Overview

    3/33

    Agenda

    1. What is Android?2. Android Stack3. Operating System Features

    Android Internals - @chung_sfc 3

  • 7/29/2019 00 Android Overview

    4/33

    1.What is Android?

    A complete set of software for mobile devices:o An operating systemo Middlewaveo Key mobile applications

    Openo No license feeso Great deal of Open Handset Alliance (OHA)

    Fast & easy application development

    Android Internals - @chung_sfc 4

  • 7/29/2019 00 Android Overview

    5/33

    Open Handset Alliance (OHA)

    A group of 84 techbology and mobile companieso Google, Samsung, HTC, Sharp, LG, Intel, etc

    They together develop Androido The first complete, open, and free mobile platform

    h`p://www.openhandsetalliance.com/index.html

    Android Internals - @chung_sfc 5

  • 7/29/2019 00 Android Overview

    6/33

    Why Open?

    Android Internals - @chung_sfc 6

    Industry

    Users

    Developer

    Source availble after handsets ship Everyone can build a system image

    Users control what gets installed

    They choose thedefault se`ings

    Can integrate, extend, and replace existingComponents No hidden or privilegedFramework APIs

  • 7/29/2019 00 Android Overview

    7/33

    Agenda

    1. What is Android?2. Android Stack3. Operating System Features

    Android Internals - @chung_sfc 7

  • 7/29/2019 00 Android Overview

    8/33

    2.Android Stack

    Android Internals - @chung_sfc 8

    Android Stack is

  • 7/29/2019 00 Android Overview

    9/33

    System Architecture

    Android Internals - @chung_sfc 9

  • 7/29/2019 00 Android Overview

    10/33

    Linux Kernel

    Run on Linux 2.6.x modified Built on the Linux kernel, but Android is not Linux Linux kernel provides:

    oHardware abstraction layer

    o Memory managemento Process managemento Power managemento Binder Drivero Networking

    Android Internals - @chung_sfc 10

  • 7/29/2019 00 Android Overview

    11/33

    Native Libraries

    Wri`en in C/C++ Some libraries

    o Libc : c standard libo SSL : secure socket layero SGL : 2D image engineo SQLite : Embedded databaseo Webkit : Kernel of web brower

    Android Internals - @chung_sfc 11

  • 7/29/2019 00 Android Overview

    12/33

    Dalvik

    Core librarieso Provides the functionality of JAVA

    Dalvik VMo Java-based license free VMo Register-based (DalvikVM) vs Stack-based (JVM)o Optimized for low memory requiremento Runs .dex fileso Completely Fair Scheduler (CFS)

    Red-Black Tree

    Android Internals - @chung_sfc 12

  • 7/29/2019 00 Android Overview

    13/33

    Application Framework

    Wri`en in Java Some frameworks

    o Activation manager controls the life cycle of the appo Content providers encapsulate data that is shared (e.g. contacts)o Location manager figures out the location of the phone (GPS,

    GSM, WiFi)

    o Notification manager for events such as arriving messages,appointments, etc

    Android Internals - @chung_sfc 13

  • 7/29/2019 00 Android Overview

    14/33

    Applications

    Packaged into APK files 5/11 : 294.730 apps

    Android Internals - @chung_sfc 14

  • 7/29/2019 00 Android Overview

    15/33

    More details

    Android Internals - @chung_sfc 15

  • 7/29/2019 00 Android Overview

    16/33

    Android and Java

    Android Internals - @chung_sfc 16

  • 7/29/2019 00 Android Overview

    17/33

    3. Layer Interactions

    Apps talk to native libraries 3 ways

    o App Runtime Service Libo App Runtime Service Native Service Libo App Runtime Service Native Deamon Lib

    Android Internals - @chung_sfc 17

  • 7/29/2019 00 Android Overview

    18/33

    App Runtime Service Lib

    Android Internals - @chung_sfc 18

  • 7/29/2019 00 Android Overview

    19/33

    App Runtime Service Native Service Lib

    Android Internals - @chung_sfc 19

  • 7/29/2019 00 Android Overview

    20/33

    App Runtime Service Native Deamon Lib

    Android Internals - @chung_sfc 20

  • 7/29/2019 00 Android Overview

    21/33

    Agenda

    1. What is Android?2. Android Stack3. Operating System Features

    Android Internals - @chung_sfc 21

  • 7/29/2019 00 Android Overview

    22/33

    3. OS Features

    Android Internals - @chung_sfc 22

  • 7/29/2019 00 Android Overview

    23/33

    File System

    Yet Another Flash File System (YAFFS) by defaulto Useful for NAND and NOR Flasho Boots quickly

    3 main mount pointso One for systemo One for appso One for whatever

    Each app has its own sandboxo /data/data/com.chung.helloworldo Easily accessible

    Android Internals - @chung_sfc 23

  • 7/29/2019 00 Android Overview

    24/33

    Security

    Each App runs inside its own Linux process Each App has

    o Its own file systemo Its own preferenceso Its own database

    Other applications can not access any of its datao Unless shared

    Android Internals - @chung_sfc 24

  • 7/29/2019 00 Android Overview

    25/33

    Memory Management

    Handled by the native Linux kernel How to use memory for each application

    o Its own run time and virtual machine to manage applicationmemory

    o Its run time also manages the process lifetimes Stops and kills processes as necessary to manage

    resources

    Android Internals - @chung_sfc 25

  • 7/29/2019 00 Android Overview

    26/33

    Process States

    Android Internals - @chung_sfc 26

    Kill lower priority ifnecessary

    Active Processo a process runs a activity

    Visible Processo a process holds a paused

    Started Service Processo a process started service

    Background Processo an activity that is no longer

    visible Empty Process

    o a processe contains no activeapplication

  • 7/29/2019 00 Android Overview

    27/33

    Power Management

    Android supports its own Power Management Kernel modified to fulfill some special needs of certain

    platformo MSM7xxx, Open Multimedia Application Platform (OMAP)

    Apps and services request CPU resources with "wakelocks

    If no active wake locks, Android will shut down the CPU

    Android Internals - @chung_sfc 27

  • 7/29/2019 00 Android Overview

    28/33

    Wake locks

    Wake locks are used by applications and services torequest CPU resources

    Wake locks exampleo Create a wake lock and specify the power management flags for

    screen, timeout, etc.

    o Acquire wake lock.o Perform operation (play MP3, open HTML page, etc.).o Release wake lock.

    Android Internals - @chung_sfc 28

  • 7/29/2019 00 Android Overview

    29/33

    Power Management

    Android Internals - @chung_sfc 29

  • 7/29/2019 00 Android Overview

    30/33

    Application Anatomy

    An android application is based on four differentcomponentso Activity, Service, BroadcastReceiver and ContentProvider

    Not necessarily consists of all four of these components At least an Activity in GUI

    Android Internals - @chung_sfc 30

  • 7/29/2019 00 Android Overview

    31/33

    Application Anatomy

    Activityo Single screeno UI composed of views o Responds to eventso Change screens by starting new Activity

    Serviceo Runs without UI (example: media player automatically)o Long-livedo Communicate with via interface exposed by service (example:pause, rewind, etc)

    Android Internals - @chung_sfc 31

  • 7/29/2019 00 Android Overview

    32/33

    Application Anatomy

    BroadcastReceivero For reactions to an external event (phone rings, data network is

    available, alarm)

    ContentProvidero Share data with other apps

    Android Internals - @chung_sfc 32

  • 7/29/2019 00 Android Overview

    33/33

    Install Android SDK

    SDK = Software Development Kit Download SDK:

    o h`p://developer.android.com/sdk/index.html

    Add platform and packageso h`p://developer.android.com/sdk/installing/adding-

    packages.html

    o Should download 2.3, 4.0 platform Install Eclipse and ADT plugin

    o h`p://developer.android.com/sdk/installing/installing-adt.html Install suitable drivers for Android devices and Ge`ing

    Started ^^

    Android Internals - @chung sfc 33