Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android...

30
Introduction Lecture 1 Operating Systems Practical 5 October 2016 This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. OSP Introduction, Lecture 1 1/30

Transcript of Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android...

Page 1: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

IntroductionLecture 1

Operating Systems Practical

5 October 2016

This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of thislicense, visit http://creativecommons.org/licenses/by/4.0/.

OSP Introduction, Lecture 1 1/30

Page 2: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Team, Schedule and Grading

Android Architecture

Application development overview

OSP Introduction, Lecture 1 2/30

Page 3: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Outline

Team, Schedule and Grading

Android Architecture

Application development overview

OSP Introduction, Lecture 1 3/30

Page 4: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Team and Schedule

I TeamI Laura Gheorghe, Vlad Traista-Popescu, invited speakers

I ScheduleI Lecture: Wednesday, 18-20, room PRECIS 706I Labs: Wednesday, 20-22, room PRECIS 706

OSP Introduction, Lecture 1 4/30

Page 5: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Grading

I ExamsI 2.5 points Mid-term examI 2.5 points Final exam

I Labs & ProjectI 2.4 points Lab activityI 3 points Project

OSP Introduction, Lecture 1 5/30

Page 6: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Syllabus

I Android OS:I SDKI InternalsI ServicesI ConnectivityI NDKI Native librariesI Security

OSP Introduction, Lecture 1 6/30

Page 7: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Resources

I Wiki: http://ocw.cs.pub.ro/courses/osp

I Moodle:http://cs.curs.pub.ro/2016/course/view.php?id=179

OSP Introduction, Lecture 1 7/30

Page 8: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Outline

Team, Schedule and Grading

Android Architecture

Application development overview

OSP Introduction, Lecture 1 8/30

Page 9: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Popularity

I Open-source OS for mobile devices

I More than 87.6% of mobile market share (2016 Q2)

I Official application market: Google Play

OSP Introduction, Lecture 1 9/30

Page 10: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Architecture

OSP Introduction, Lecture 1 10/30

Page 11: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Architecture

I Linux kernelI Android Mainlining Project / Android UpstreamingI AndroidismsI Advantages

I Hardware Abstraction Layer (HAL)I Standard interfacesI Multiple library modules

I Native userspaceI init processI Native daemonsI Native libraries

I Through Java framework APIsI Through Android NDK

OSP Introduction, Lecture 1 11/30

Page 12: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Architecture

I Android RuntimeI DalvikI ARTI Ahead-Of-Time (AOT) compilation

I Java Runtime librariesI java.* and javax.*I Apache Harmony ProjectI Java Native Interface (JNI)

OSP Introduction, Lecture 1 12/30

Page 13: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Architecture

I System servicesI Fundamental features of AndroidI Native and Java codeI Service interface

I Android framework librariesI Base components for app developmentI Interaction with the hardwareI Interaction with high level servicesI Framework APIs

OSP Introduction, Lecture 1 13/30

Page 14: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Linux Kernel

I Modified to work on mobile devices

I Patches on top of mainline Linux

I Android Mainlining Project / Android Upstreaming

I Wakelocks (also added to Linux 3.5)

I Low-Memory Killer (3.10)

I Binder (3.19)

I Alarm (3.20)

I Logger (3.20)

I Only suspend to memory

OSP Introduction, Lecture 1 14/30

Page 15: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Runtime - Dalvik VM

I Default until Android 5.0

I Runs Dalvik-specific byte-codeI Dalvik Executable Format (DEX)

I Runs .dex files instead of .jar filesI .dex is 50% smaller than corresponding .jar

I Just-In-Time compilationI From Android 2.2I Short segments of bytecode translated into native machine

code at runtimeI Improves performance

OSP Introduction, Lecture 1 15/30

Page 16: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

APK Creation

OSP Introduction, Lecture 1 16/30

Page 17: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Android Runtime - ART

I From Android 5.0

I More advanced runtime architectureI Ahead-Of-Time compilation

I Just once, at installationI Entire DEX file -> executable for target deviceI Instead of JIT compilation and Dalvik interpretationI More efficient, reduced power consumptionI More space to store the executables

I Improved memory allocation, GC, debugging and profiling

OSP Introduction, Lecture 1 17/30

Page 18: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Native Libraries

I bioniC (libc)I Much smaller and faster than glibc

I SQLiteI Managing SQL databases

I OpenGL ESI Standard software interface for 3D processing hardware

I WebKitI Display web pagesI Android, Apple iOS, BlackBerry, Tizen

I SSLI Securing the communication over Internet

OSP Introduction, Lecture 1 18/30

Page 19: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Application Framework

I System Services and ManagersI TelephonyI LocationI ActivityI PackageI Notification

I System Content ProvidersI CalendarI DictionaryI ContactsI Settings

OSP Introduction, Lecture 1 19/30

Page 20: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Application Framework

Application process System processes

Binder Service 1

Thread

Binder Service N

Thread. . .

Application APIRPCstub

Native application libraries

JNI

OSP Introduction, Lecture 1 20/30

Page 21: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Outline

Team, Schedule and Grading

Android Architecture

Application development overview

OSP Introduction, Lecture 1 21/30

Page 22: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Application components

I User interactionI Activities

I Background functionalityI ServicesI Broadcast ReceiversI Content Providers

OSP Introduction, Lecture 1 22/30

Page 23: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Activity

I User interface

I Similar to a window from window-based GUIs

I User interacts with a single activity at a timeI Activities stack

I Activities launch other activitiesI Back button for returning to the previous activityI No forward button

I Start activities with intentsI Launcher or application components

OSP Introduction, Lecture 1 23/30

Page 24: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Service

I Performs operations in background, no UII Runs in the same process as the application

I Can be configured to run in another process

I Tasks for the current application

I Provide services to the other applications

I Communication through the Binder

OSP Introduction, Lecture 1 24/30

Page 25: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Broadcast Receiver

I Receive broadcast announcementsI Low batteryI RebootI Application state changes

I Can receive global or local broadcastsI Choose which broadcasts to receive

I Intent filters

I Intents

I Active only when receiving a broadcast

OSP Introduction, Lecture 1 25/30

Page 26: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Content Provider

I Manage access to a structured set of data

I Required for sharing data with other apps

I File data or ”structured” data

I URI: provider and table

I Content Resolver uses the URI to send a query to the provider

I Active only when responding to a request

OSP Introduction, Lecture 1 26/30

Page 27: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Intents

I Similar to signals

I Send message, determine action executionI Purpose

I Start activities, start or bind servicesI Delivering broadcast messages to receivers

I Dispatched by the Android systemI Includes action and data

I ACTION DIAL content://contacts/people/1

I TypesI Explicit: directed towards a specific receiverI Implicit: a receiver which can resolve the action

OSP Introduction, Lecture 1 27/30

Page 28: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Binder

I Lightweight RPC

I Remote object invocation

I In process and interprocess

I Transmit parcels of data

I Synchronous calls (blocking)

OSP Introduction, Lecture 1 28/30

Page 29: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Bibliography

I Karim Yaghmour, Embedded Android: Porting, Extending,and Customizing, Chapter 2

I https://wiki.linaro.org/LMG/Kernel/Upstreaming

I http://elinux.org/Android_Kernel_Features

I https://www.google.com/events/io/io14videos/

b750c8da-aebe-e311-b297-00155d5066d7

I http://developer.android.com/guide/components/

activities.html

I http://developer.android.com/guide/components/

services.html

I http://developer.android.com/guide/topics/

providers/content-providers.html

I http://developer.android.com/guide/components/

intents-filters.html

OSP Introduction, Lecture 1 29/30

Page 30: Operating Systems Practicalocw.cs.pub.ro/courses/_media/osp/lectures/lecture-intro.pdf · Android Runtime - ART I From Android 5.0 I More advanced runtime architecture I Ahead-Of-Time

Keywords

I Linux kernel

I Android Runtime

I Dalvik

I ART

I Native libraries

I Application framework

I Activities

I Services

I Broadcast receivers

I Content providers

I Intents

I Binder

OSP Introduction, Lecture 1 30/30