This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Android OS : Core Concepts Dr. Jeyakesavan Veerasamy Sr. Lecturer University of Texas at Dallas
Introduction.  Professor  Adam Porter 
14 Macintosh OS X Internals. © 2005 Pearson Addison-Wesley. All rights reserved The Macintosh Platform 1984 – first affordable GUI Based on Motorola 32-bit.
Android architecture overview
Android Platform Overview (1)
Android: An Open Software Platform for Mobile Devices
Mobile Application Development
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Using Two Queues. Using Multiple Queues Suspended Processes Processor is faster than I/O so all processes could be waiting for I/O Processor is faster.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Case study 2 Android – Mobile OS.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Android Middleware Bo Pang
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Android Introduction Platform Overview.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Mobile Application Development with ANDROID. Agenda Mobile Application Development (MAD) Intro to Android platform Platform architecture Application building.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Android Introduction Based on slides made by
Authors: William Enck The Pennsylvania State University Peter Gilbert Duke University Byung-Gon Chun Intel Labs Landon P. Cox Duke University Jaeyeon Jung.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
CASE STUDY 1: Linux and Android Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Linux and Real Time Real-time systems are characterized by deadlines. When a missed deadline results in inconvenience or a diminished customer experience,
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Embedded Software SKKU 29 1 Sungkyunkwan University Tizen v2.3 Application Model.
Android for Java Developers Denver Java Users Group Jan 11, Mike
Overview of Android Application Development
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
The Performance of Micro-Kernel- Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presentation by: Seungweon Park.
Android Security Auditing Slides and projects at samsclass.info.
Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
ANDROID BY:-AANCHAL MEHTA MNW-880-2K11. Introduction to Android Open software platform for mobile development A complete stack – OS, Middleware, Applications.
Android. Basic Architecture Linux Kernel Libraries Applications Android Runtime Application Framework.
The Performance of Micro-Kernel- Based Systems H. Haertig, M. Hohmuth, J. Liedtke, S. Schoenberg, J. Wolter Presentation by: Tim Hamilton.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
1 Android Workshop Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Accelerometer based motion gestures for mobile devices Presented by – Neel Parikh Advisor Committee members Dr. Chris Pollett Dr. Robert Chun Dr. Mark.
 This work confers an application which makes possible to use a Bluetooth enabled mobile phone to remote control home appliances such electric fan, LEDs.
ANDROID OS Ravi Soni MTech (CS) III Sem. W HAT IS A NDROID ? Android is a software stack for mobile devices that includes an operating system, middleware.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
Android Overview Reference: Embedded Android by Yaghmour.
ANDROID ACCESS CONTROL Presented by: Justin Williams Masters of Computer Science Candidate.
Presented by: Saurabh Kumar Sinha (MRT07UGBIT 186) IT VII Semester, Shobhit University Meerut.
The Basics of Android App Development Sankarshan Mridha Satadal Sengupta.
Computer System Structures
Android Mobile Application Development
Android Kernel Extensions
Karthik Dantu and Steve Ko
ANDROID AN OPEN HANDSET ALLIANCE PROJECT
Android Runtime – Dalvik VM
Chapter 2: Operating-System Structures
chapter 6- Android Introduction
CASE STUDY 1: Linux and Android
Chapter 2: System Structures
Android: Modding & Hacking whitone 2012/12/12.
CMPE419 Mobile Application Development
Building Android OS Topics: Building Android and Kernel
Application Development A Tutorial Driven Course
Android Platform, Android App Basic Components
Emerging Platform#3 Android & Programming an App
CMPE419 Mobile Application Development
Presentation transcript:

This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. Lecture 3 – Android Internals

Laura Gheorghe, Petre Eftime Linux Kernel  ”Androidized” kernel  Hundreds of patches over the standard kernel  Device-specific functionality, fixes, enhancements  Many features get into the mainline kernel  ”Androidisms”  Wakelocks  Low-Memory Killer  Binder  Anonymous Shared Memory  Alarm  Logger 2

Laura Gheorghe, Petre Eftime Wakelocks 3  The Android kernel goes to sleep as often as possible  Sometimes you want to keep the system from going to sleep  Input from the user, critical operations  Wakelocks keep the system awake  A wakelock must be obtained by the application when it needs to stay awake  Apps communicate with the Power Manager Service when they require a wakelock  Device drivers call in-kernel wakelock primitives  Included in mainline

Laura Gheorghe, Petre Eftime Low-Memory Killer 4  Linux OOM killer  Prevents the activation of the OOM killer (system unlikely to run out of memory)  Kills processes with components unused for a long time  Based on OOM adjustments mechanism  Different OOM kill priorities for different processes  The userspace may control OOM killing policies  Policies applied at startup by init  Modified and enforced by Activity Manager

Laura Gheorghe, Petre Eftime Low-Memory Killer 5  Levels assigned to processes based on their components  Levels from -17 to 15 (high -> killed)  Threshold (MinFree) for each type of process  Foreground app - application in foreground  Visible app - visible but not in foreground  Secondary server - service  Hidden app - hidden, needed by a running app  Content provider - provide data  Empty app - app not active  Starts killing when the threshold is reached

Laura Gheorghe, Petre Eftime Anonymous Shared Memory (ashmem) 6  IPC mechanism  SysV IPC can lead to resource leakage in the kernel (vulnerability)  Similar to POSIX SHM, differences:  Uses reference counting to destroy the memory regions  Shrink mapped regions when the system needs memory  To shrink a region it must be unpinned  First process creates region, uses Binder to share descriptor with other processes  System services rely on ashmem  Surface Flinger, Audio Flinger  Driver included in the staging tree

Laura Gheorghe, Petre Eftime Alarm 7  Uses the RTC and HRT functionalities  The setitimer() does not work when the system is suspended (HRT)  The application receives the signal when the device wakes up  Using RTC, the alarm will be fired even if the system is suspended  RTC hardware device  Uses HRT by default  When the system is about to suspend, it uses RTC

Laura Gheorghe, Petre Eftime Alarm 8  /dev/alarm character device, ioctl()  SystemClock, AlarmManager class rely on the driver  SystemClock - obtain and set time  AlarmManager - provide alarms to apps  The driver and AlarmManager use WakeLocks  The app that receives the alarm runs before the system is suspended again  Included in the staging tree

Laura Gheorghe, Petre Eftime Logger 9  Uses kernel buffers for logging data  Circular buffers in RAM  No task switch, no writing in files (compared to syslog)  Avoiding write operations in files is critical on Android devices  Each buffer - separate entry in /dev/log (Events, System, Radio, Main)  logcat displays the Main buffer by default

Laura Gheorghe, Petre Eftime Logger 10  Log and EventLog classes - public API  Developers use Log  EventLog used by the system components  Diagnostic events  Slog - system use (AOSP)

Laura Gheorghe, Petre Eftime Logging Messages 11  Through liblog library  Logging from java classes  Used by logcat  Formatting and filtering  Log message  Priority, tag and data for each event  Priority: verbose, debug, info, warn, error  Tag: identifies the component that generated the message  Staging tree

Laura Gheorghe, Petre Eftime Logging System 12

Laura Gheorghe, Petre Eftime Binder History 13  RPC mechanism  Initially in BeOS (then bought by Palm)  OpenBinder project  OpenBinder developers working in Android team  Android Binder does not derive from OpenBinder  Clean re-write of the same functionality  OpenBinder documentation for understanding the mechanism  Binder driver in the staging tree from kernel 3.3

Laura Gheorghe, Petre Eftime Binder 14  Remote object invocation  Remote services as objects  Interface definition and reference to it  Cornerstone of Android architecture  Apps talk to System Server  Apps talk to other service components  Developers don’t use the Binder directly  Use interfaces and stubs generated with the aidl tool

Laura Gheorghe, Petre Eftime Binder Driver 15  Part of the Binder implemented in a kernel driver  Character device  /dev/binder  Uses ioctl() calls  Transmit parcels of data (serialized) between entities

Laura Gheorghe, Petre Eftime Android Framework 16  On top of the native userspace  android.* packages, System Services, Android Runtime  Code in /frameworks directory in AOSP  Key building blocks: Service Manager, Dalvik, Zygote

Laura Gheorghe, Petre Eftime System Services 17  Form an object-oriented OS on top of Linux  System Server  All components run in the system_server process  Many Java-based services/managers, 2 C-based services  Power Manager, Activity Manager, Location Manager, etc.  Surface Flinger, Sensor Service (C/C++)  Media Server  mediaserver process  C/C++ code  Audio Flinger, Media Player Service, Camera Service

Laura Gheorghe, Petre Eftime Service Manager 18  Performs system service handle lookups  The Yellow pages book of all services  A service must be registered to the Service Manager to be available  Started by init before any other service  Opens /dev/binder and becomes the Context Manager of the Binder  Binder ID 0 = ”magic object” = Service Manager

Laura Gheorghe, Petre Eftime Service Manager 19  System Server registers every service with the Service Manager  Any app that wants to talk to a system service:  Asks the Service Manager for a handle  getSystemService()  Invokes the methods of the service using the handle  Not used by an app to access its own service  Used by the dumpsys utility to obtain the status of the system services

Laura Gheorghe, Petre Eftime Dalvik 20  Dalvik virtual machine  Java VM optimized for mobile architectures  Lower memory footprint  Works with.dex files instead of.jar files  Incompatible with Java bytecode  Register based, not stack based  16 bit instructions

Laura Gheorghe, Petre Eftime Dalvik 21  Includes Just-in-Time (JIT) compiler  ARM, x86, MIPS  Translates bytecode into binary machine instructions  Code runs directly on the CPU, not one instruction at a time by the VM  The conversion is stored and used next time the application runs  Apps run much faster

Laura Gheorghe, Petre Eftime Zygote 22  Daemon used to launch apps  Listens to connections on its socket for requests to start apps  /dev/socket/zygote  When it gets a request, it forks itself and launches the app  Preloads (in RAM) all Java classes and resources needed by an app  Copy-on-write (COW)  Classes and resources are not modified, so all apps use them from Zygote (only one copy in RAM)  The System Server is started explicitly by Zygote  The PPID of all apps is the PID of Zygote

Laura Gheorghe, Petre Eftime Activity Manager 23  One of the most important services in the System Server  Handles application lifecycle  Broadcasts intents  Starting new components (activities, services)  Fetching Content Providers  Responsible with the Application Not Responding (ANR) messages  Involved in  Permission checks  OOM adjustments for the Low-Memory Killer  Task management

Laura Gheorghe, Petre Eftime Activity Manager 24  Starts the Launcher (with Intent.CATEGORY_HOME )  When an app is started from Launcher  Launcher’s onClick() callback is called  Launcher calls the startActivity() from ActivityManager (through Binder)  ActivityManager calls startViaZygote() method  Opens socket to Zygote and asks to start the activity  am command for invoking the functionality of the ActivityManager  isUserAMonkey()

Laura Gheorghe, Petre Eftime Package Manager 25  Manages the.apk files in the systems  API for installing, uninstalling, upgrading.apk files  system_server and installd processes  Ensures that the JIT versions of the dex bytecode is available before the app is started  Resolves intents  pm command for invoking the functionality of the PackageManager

Laura Gheorghe, Petre Eftime Power Manager 26  Control the power state of the device  Handles WakeLocks  Includes the WakeLock class  acquire(), release()  Apps request WakeLocks from PowerManager  All calls to the Power Management (kernel) go through PowerManager  Can force device to go to sleep  Set the brightness of the backlights

Laura Gheorghe, Petre Eftime Bibliography 27  Karim Yaghmour, Embedded Android: Porting, Extending, and Customizing, Chapter 2

Laura Gheorghe, Petre Eftime Keywords 28  WakeLocks  Low-Memory killer  Binder  Ashmem  Alarm  Logger  System Server  Service Manager  Dalvik  Zygote  Activity Manager  Package Manager