Android Overview

Feng Qin [email protected] CSE Dept., The Ohio State University Outline

• What is Android? • Why Android? • Android Architecture • Android v.s. What is Android?

• A open-source and comprehensive platform for mobile devices – Linux-based OS – VM (Java programming) – Application Framework

• Developed by led by Why Android?

• Extremely popular – Best-selling platform worldwide in Q4 2010 – Over 300 million Android devices in use by Feb. 2012 – Over 850,000 Android devices activated every day • Open source – Based on – We can study the code Android Versions

• Google purchased Android Inc. in 2005 • Android 1.5 Cupcake • Android 1.6 Donut • Android 2.0, 2.1 Éclair • Android 2.2 Froyo • Android 2.3.x Gingerbread • Android 3.x.x Honeycomb • Android 4.0.x Ice Cream Sandwich Group Discussion

• Why do we need different Operating Systems for mobile devices? – Differences between mobile devices such as and non-mobile devices such as desktop/servers

• 5-6 students form a group Android System Architecture Target Hardware Architecture

• Linux supports many different architectures – Initially created in 1991 as by – Next slide shows the history

• Android trims down the supported architectures to and ARM. UNIX Family Why ARM Architecture?

• ARM: Advanced RISC Machine, developed by ARM Holdings. • ARM is a RISC instruction set architecture – Much simpler for execution than CISC ISA. – Focused on low power design, perfectly fit for mobile devices – Licensed to many companies, e.g., Apple, Nvidia, and TI. More on ARM

• Provide the following RISC features: – Load/Store architecture – No support for misaligned memory accesses (mostly) – Uniform 16 x 32-bit register files – Fixed instruction width of 32 bits – Mostly single clock-cycle execution • Low power consumption – E.g., ARM7100 consumes 72mW when operating at 14MIPS, 33 mW in idle mode, 33 uW during standby – Atom (x86) operates at ~1W Kernel Modification

• Removed Support: – Most architectures except for ARM and x86 – …. • New enhancement: – Alarm driver – Ashmem – Binder driver – Power management – Low memory killer – Drivers for mobile device-specific components Bionic Library

• GNU C library is designed for good performance, instead of constrained memory • Bionic libc: a simple implementation based on BSD standard C library. – BSD license (allow proprietary use), isolating Android apps from GPL (kernel license) – Small size and good speed for CPUs with relatively low clock frequencies More on Bionic C Library

• Provide lightweight wrappers around kernel facilities – Syscall stubs – Simple pthread implementation bundled in: highly optimized for common operations – Not provide read/write memory barriers – No support on C++ exceptions – Some Android-specific features … Dalvik Virtual Machine

• Java-compatible: – Developers write programs in Java and compile to Java class files – dx translates Java bytecode into dex file that can run in Dalvik VM • Dalvik VM optimized for mobile devices with limited resources – E.g., shared constant pools with 32-bit indices Group Discussion

• What are Security and Privacy issues in mobile devices? • How do we handle them? Memory Management

• ION Memory Allocator (for Android 4.0.x) – Consolidated previous versions of memory managements for different Android devices, e.g., “PMEM” for Qualcomm MSM devices, “NVMAP” for NVIDIA Tegra devices

• Low Memory Killer – Kill processes when system is under memory pressure Group Discussion

• Policies for Low Memory Killer – Which apps to kill first? – Why? Storage and File System

• New storage media – NAND: low cost, high density, and offers fast writes and slow reads – NOR: low density, offers slow writes and fast reads • Traditional filesystems do not work well with new storage media – NAND requires block erasure – A limited number of erase-write cycles • YAFFS (Yet Another Flash File System) – JFFS mainly for NOR-based storage Group Discussion

• Different storage systems: – Disk – Flash – DRAM – … • When do use these storage systems? • What are trade-offs among them? Android Power Management

• On top of the standard Linux Power management • Apps or services request CPU using “wakelocks” through Android app framework and native Linux libraries – CPU should not consume power if no apps or services require power Tentative Class Schedule (System Part) • April 5 (today), Android Overview • April 10, Dalvik VM and TaintDroid • April 12, Memory Management • April 17, Storage and File System • April 19, Power Management • April 23, Attend Dr. Ricardo Bianchini’s talk (3:30-4:30pm, DL 480) • April 24, No class References

[1] http://en.wikipedia.org/wiki/Android_(operating_system) [2] A Survey on Android vs. Linux, Frank Maker and Yu-Hsuan Chan, http://handycodeworks.com/wp- content/uploads/2011/02/linux_versus_android.pdf [3] http://lwn.net/Articles/480055/ [4] http://www.netmite.com/android/mydroid/1.5/bionic/libc/docs/OVERVIEW.TXT [5] http://processors.wiki.ti.com/index.php/Android_Devkit_Power_Management_Porting_Guide