andriod - technical review

36
Technical Review www.folio3.com

Upload: folio3-software

Post on 15-Jul-2015

472 views

Category:

Mobile


0 download

TRANSCRIPT

Technical Review

www.folio3.com

www.folio3.com

Mobile Platforms

There a lot of mobile platforms SymbianOS IPhoneOS BlackberryOS WinMo ALP OpenMoko WebOS Android BadaOS

Mobile Platform requirements Stable real-time kernel Steady HAL Power management Rich system libraries Rich application

framework Essential applications Steady UI Optimized application

management

www.folio3.com

Introduction Another Mobile Platform

Offers Operating System

Kernel: Linux 2.6 Sys Library: Subset of LibC, LibM,

A complete application stack User land applications Development infrastructure

SDK 2.0.1 Java

NDK 1.5 C/C++

Components reusability and integration Based on ARM based processor

Can be run on x86 platform

(Cont.) Introduction License

Open source from the beginning Apache License

Made available Primarily for

Cell (mobile) devices But can also be use on

MIDs Nettops Mobile gaming devices Other light weight devices

Releases 1.5 – Cupcake 1.6 – Donut 2.0 – Eclair

2.1 – Extension to Eclair

www.folio3.com

Support

Full multimedia hardware and software stack Advanced application supports

Background services Complex widgets Easy and manageable lifecycle Full control of the hardware through well designed

APIs

Advanced I/O supports

www.folio3.com

History July 2005

Google acquired Android Inc. November 2007

OHA, Open Handset Alliance, consortium started with Texas Instruments, Broadcom Corporation, Google, HTC, Intel, LG, Marvell

Technology Group, Motorola, Nvidia, Qualcomm, Samsung Electronics, Sprint Nextel, T-Mobile

October 2008 First Android phone release – HTC Dream

December 2008 OHA, Open Handset Alliance, expanded with

ARM Holdings, Atheros Communications, Asustek Computer Inc, Garmin Ltd., Softbank, Sony Ericsson, Toshiba Corp, Vodafone Group

January 2010 OHA, Open Handset Alliance, expanded with

China Mobile Comm Corp., China Telecomm Corp., China United Network Comm., KDDI Corp., NTT DoCoMo Inc., Bouygues Telecom, etc

www.folio3.com

Open Handset Alliance

Kashif Ali Siddiqui - [email protected] | 2010

Architecture & Design

The Kernel Kernel – Linux 2.6

Patches – Android Ashmem, binder, and Android Power Management (PM)

OS HAL Provides management for

Memory modules (Primary, Secondary) Processes

Provides networking stack Full TCP/IP v4 support

Provides device drivers Telephony, GSM, CDMA, GPRS, Edge, 3G, WiFi, Bluetooth, others

transceivers Accelerometer, gyroscope , GPS transceiver, magnetometer Touchscreen, keyboard, keypad, camera VGA display Others

www.folio3.com

Native System Libraries C/C++ libraries

Interface through Java layer Includes …

1. Standard UNIX libc libraries Called BIONIC Derived from BSD Only on ARM and x86 platforms

1. Surface manager2. 3D graphics with/without H/W acceleration using OpenGL ES3. 2D scalable vector graphics using SGL (Skia)4. TrueType fonts5. Media frameworks including audio, video codecs6. HTTP rendering engine – Webkit7. Light database management through SQLite38. TCP socket security through SSL

www.folio3.com

Java Runtime

Specialized Virtual Machine Dalvik Virtual Machine

Written by Dan Bornstein Architecture - Register-based machine Class files - Delvik Executibles .dex files

Structures ? Difference from normal class files Light weight, compact, and processor and memory efficient An uncompressed .dex size is less than compressed .jar Can contain several classes Code reordering and re-organization at installation time

Designed to enable execution of multiple instances

www.folio3.com

(Cont.) Java Runtime

Relies on Linux for underlying functionality such as multi-threading and low level memory management

The dx utility No official JIT compiler

Core library – Java 1.5 SDK Completely not compatible with Java SE and ME

class library profiles E.g., J2ME, AWT, Swing are not supported

Subset of the Apache Harmony

www.folio3.com

Dalvik Virtual Machine Motivation

Can run on lesser RAM Can run on slower CPUs Can run without swap space defined Can run with less power Can enable concurrent execution of multiple instances

Memory efficiency More memory requirement

Each application runs in its own address space – process Optimization

Shared constant pool in .dex files Minimal repetition Per type pools (implicit typing) Implicit labeling

www.folio3.com

(Cont.) Dalvik Virtual Machine

Emphasis to use clean (shared/private) memory Emphasis to limit the use of dirty private memory

Memory types Clean memories

Common .dex files (shared) Application specific .dex files (private)

Private dirty memories Application “live” .dex structures Application heap

Shared dirty memories Common “live” .dex structures Shared COW heap

www.folio3.com

(Cont.) Dalvik Virtual Machine Separate Garbage Collection meta

Specialized GC meta structures Optimized for memory usage with less fragmentation and sharing Each application heap is GCed independently

Run time efficiency Install time verification

Static type and reference checking, indices and offset checking Reduces run-time cost of checking the code

Install time optimization Byte swapping and padding Static linking Inlining special native methods Pruning empty methods Adding auxiliary data Creating shared constant pools

www.folio3.com

(Cont.) Dalvik Virtual Machine

Why To avoid instruction dispatch Avoid unnecessary memory accesses Consume instruction stream efficiently

Higher semantic density per instruction

Uses register based interpreter Stacks are used to keep tracks on the methods nesting and

calling sequence

Efficient initialization and management of array data

www.folio3.com

Enter the Zygote

The first process Similar to UNIX init process

Preloads and preinitializes shared classes Create clean shared memories Create dirty shared memories

Uses UNIX fork() to start a new application Provides shared mapping to the child

processes for shared classes Promotes the sharing of common code

www.folio3.com

Application Framework All Java Libraries

1. Activity manager – Manages application life cycle An activity is an application UI window Activities are managed through system’s activity stack Four states of activity

Foreground – top on activity stack Paused – when lost focus, and still showing (partially) on the screen. Stopped – When completely hidden by another activity Killed - Killing the process

1. Package manager – Installed software manager2. Window manager – Manages UI components along with

screens and transitions3. Telephony manager – Provides the interface to the underneath

telephony/GSM services

www.folio3.com

(Cont.) Application Framework

5. Resource manager – Provides access to the non-code components such as images, icons, audio/video, string tables, etc.

6. Content manager – Mediates in the data sharing among applications, such as contacts are shared to other application.

Various content providers Can access others, and publish own Content provider security

5. Location manager – Provides intends on registered location. Uses GPS, or GSM tower ID or WiFi location beacons to determine location.

www.folio3.com

(Cont.) Application Framework

8. View system – Provides widgets to the application to create activities

Two new views; MapView and WebView

8. Notification manager – Enables the application to show custom alerts on the status bar.

9. XMPP services – Peer-to-peer Android device communication layer

www.folio3.com

Applications

Java applications Runs in separate user address space - process Each is managed by its own DVM instance Can be replaced Can be installed from

Online app stores

Usually end up in calling native code that might goes to the kernel system call

www.folio3.com

Security & Access Control Only Java applications can be installed Each application runs in its process under DVM Each process (DVM) is a sandbox Each application has its own UIDs and GIDs Additional access control on several operations

Architecture: No application by default has permission to perform any operation that would

adversely impact other applications, operating system, or the user. Such as

R/W on user’s private data; contacts R/W on another application data files Performing network (through GPRS/Edge, Wifi), bluetooth access, or Keeping the device awake

Application certificate, UID/GID, Access Control and URI Permissions

www.folio3.com

(Cont.) Security & Access Control Application signing and certification

Contains authors identification, and signing authority

Access control The sandbox is executed with some permissions (access control) to the

operations. These access control permissions are defined in the application package, Set at installation point, and Can be modified by user when OS prompt for the permission to perform the

operation

UIDs and GIDs Each application and its components are installed with unique UID

Limits the applications to access Shared UIDs

Only allow applications with identical digital signature Each file created has the creator’s UID

www.folio3.com

(Cont.) Security & Access Control URI permissions

Mainly for content providers Allows capability like access control Enables applications to manage other application’s accesses on their shared

contents

www.folio3.com

OS Concerns Kernel

No udev support Static hardware linking and policy

No dynamic hotplug control and management Replaced by Vold

Provides static hotplug events processing Storage devices are not managed by HAL (VFS)

Replaced by Vold Responsible of mounting and unmounting of MMC subsystem

device Hardcoded power-management policy

Layered PM design Android PM mapped on Linux PM module To change the Android PM policy requires code change

www.folio3.com

(Cont.) OS Concerns

Limited, un-natural (non-Linux style) I/O support Un-orthodox touchscreen support

No official support through tslib

Fixed sized framebuffer No support for larger resolution > 1024x768

Static hardware support assumptions Telephony (3G signal indicator hardcoded) Wifi (signal indicator hardcoded) Ringer volume slider assumes telephony present

No official Ethernet support

No X Window System supportwww.folio3.com

(Cont.) OS Concerns

LibC - Bionic No glibc support Only available on ARM and x86 platforms Partial pthreads support No SysV IPC support Limited C++ support

No STL support

No Linux headers Limiting the development of native binaries

www.folio3.com

Application Development Online official guide

http://developer.android.com/guide/index.html

Development with Eclipse Using ADT plugin

Tools Android – To create/update projects Emulator – Qemu based ARM emulation system Debugger bridge – To interface with the emulator Ant – To compile and build projects into .apk files Keytool – To maintain keystore and private keys Jarsigner – To sign .apk files with private keys

www.folio3.com

(Cont.) Application Development

Requires to learn the following skills1. Java programming language

2. Java 1.5 SDK library

3. Android application life cycle

4. Android APIs

5. Mobile HPC programming

6. Use of sensory hardware and Internet services

www.folio3.com

(Cont.) Application Development

Native Development (NDK) http://developer.android.com/sdk/ndk

Java Vs. Native development

Why native development is required? Situations

Resource intensive work Complex algorithms Hardware interactions …

www.folio3.com

Limitations Kernel

Limited support for Mass Storage Devices No official support for mouse, Ethernet devices No support of other filesystems, and hardware Very thin network protocol stack

System libraries No support for IPC among the application

Replaced by content manager Limited pthread support Limited UNIX/Linux native library support

www.folio3.com

(Cont.) Limitations

Application Applications can only be installed on the primary nonvolatile

memory Most of the Linux binaries will failed to run on Android Only Java based application can be executed

Native code can be only packaged as library modules for the Java application

No compatibility to the Jave ME and SE platforms No Enterprise integration solutions

Missing push messaging or notifications

www.folio3.com

Comparison With Other Mobile Platforms

IPhone Blackberry Android

Background application

Multiprocessing

Peer-to-peer communication

Extensible & Scalable in HW support

Platform support

Application development & publishing

www.folio3.com

Comparison With Other Mobile Platforms

IPhone Blackberry Android

Third party community support

Enterprise integration

Multimedia support

Optimized Java support

Native development

Security

Organization Support

www.folio3.com

Future of Android

IS VERY BIG

Increasing support for more hardware and platforms Extensions to more system level libraries Extensions to more Java runtime libraries Enterprise level support Increase in platform domain from cellphone market

to military, gaming, medical, and other domains And more …

www.folio3.com

Conclusion It uses Linux, but loses all the flexibility of Linux Based on the assumption of hardware support available on the

smart-phones with no/limited flexibility for dynamic adjustments Requires custom work and patching to enable Android to run on

other non-mobile platform and/or with more hardware Provides native development, but disallows the creation,

execution of the native applications Provides easy application development using Java Provides rich application stack and multimedia support Backed by a stronger organization Google

Technically more stronger and mature platform than other mobile OS platforms such as IPhoneOS, Blackberry OS and WinMo

www.folio3.com