Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik...

23
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/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. Lecture 1 - Introduction to Android

Transcript of Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik...

Page 1: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

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/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California,

94041, USA.

Lecture 1 - Introduction to Android

Page 2: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Android Architecture

2

Source: http://commons.wikimedia.org

Page 3: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Android Architecture

Linux kernel

AOSP

Runtime

Libraries

Application framework

Applications

3

Page 4: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Linux Kernel

4

Patches on top of mainline Linux

Android Mainlining Project

Wakelocks (also added to Linux 3.5)

Low-Memory Killer, Binder, Alarm, Logger, etc.

Only suspend to memory

Page 5: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Android Runtime

5

Dalvik Virtual Machine (Java VM)

Runs Dalvik-specific byte-code generated from Java-based apps, system components

Apache Harmony project (implementation of Java libraries)

Designed for embedded systems (slow CPU, small RAM, no swap, battery)

Works with .dex files instead of .jar files

Dalvik Executable Format

.dex is 50% smaller than corresponding .jar

Page 6: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Android Runtime

6

Page 7: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Libraries

7

bioniC (libc)

Much smaller than glibc

sqlite

Managing SQL databases

OpenGL ES

Standard software interface for 3D processing hardware

WebKit

Display web pages

Android, Apple iOS, BlackBerry, Tizen

SSL

Securing the communication over Internet

Page 8: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Application Framework

8

Services

Managers

Telephony

Location

Activity

Package

Notification

Content Providers

Page 9: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Application Framework

9

Page 10: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Application components

10

User interaction

Activities

Background functionality

Services

Broadcast Receivers

Content Providers

Page 11: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Activity

11

User interface

Similar to a window from window-based GUIs

Cannot be minimized, maximized, resized

Uses the whole visual area

User interacts with a single activity at a time

Activities stack

Activities launch other activities

Back button for returning to the previous activity

No forward button

Start activities with intents

Page 12: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Activity Lifecycle

12

Page 13: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Service

13

Background thread

Runs in the same process as the application

Can be configured to run in another process

Provide services to the other applications

Communication through the Binder

Page 14: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Broadcast Receiver

14

Receive broadcast announcements

Low battery

Reboot

Application state changes

Can receive global or local broadcasts

Choose which broadcasts to receive

Intent filters

Intents

Active only when receiving a broadcast

Page 15: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Content Provider

15

Store and share application data

Required for sharing data

Relational database

URI for identifying the provider and the table

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

Active only when responding to a request

Page 16: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Intents

16

Send message, determine action execution

Purpose

Start activities, start or bind services

Delivering broadcast messages to receivers

Dispatched by the Android system

Includes action and data ACTION DIAL content://contacts/people/1

Types

Explicit: directed towards a specific receiver

Implicit: a receiver which can resolve the action

Page 17: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Binder

17

Lightweight RPC

Remote object invocation

In process and interprocess

Transmit parcels of data

Synchronous calls (blocking)

Page 18: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

SDK Tools

18

Android SDK Manager

Download SDK packages

AVD Manager

Manages Android Virtual Devices (for emulator)

Emulator

Virtual mobile devices running on a PC

Dalvik Debug Monitor Server (ddms)

Debugging tool

Port forwarding, screen capture, call and SMS spoofing, location spoofing, etc.

Page 19: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

SDK Tools

19

Android Debug Bridge (adb) Communication between the development tools and (virtual) device

dx

Generates the classes.dex file from several .class files

Android Interface Definition Language (aidl) To allow clients from another application to access your service

Generates interfaces and stubs that are used by the Binder

Android Asset Packaging Tool (aapt) Create, update and view Zip-compatible archives (zip, apk, jar)

Compile resources into binary assets (XML files, etc.)

dexdump

Disassembler tool

Obtain the Dalvik bytecode from classes.dex

Page 20: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Android Debug Bridge

20

Three components

Client: runs on the development machine

Server: background process on the development machine

Daemon: background process on the (virtual) device

Copy files

Install applications

Debug

Shell on the (virtual) device

Page 21: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Emulator

21

QEMU

Screen, Keyboard, Network, Audio, GPS, Radio

Can be accelerated through virtualization

x86 System Image

Intel Hardware Accelerated Execution Manager (HAXM) on Windows

KVM on Linux

GPU accelerated

Page 22: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Bibliography

22

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

http://developer.android.com/guide/components/activities.html

http://developer.android.com/guide/components/services.html

http://developer.android.com/guide/topics/providers/content-providers.html

http://developer.android.com/guide/components/intents-filters.html

http: //developer.android.com/tools/help/index.html

Page 23: Lecture 1 - Introduction to Android · Laura Gheorghe, Petre Eftime Android Runtime 5 Dalvik Virtual Machine (Java VM) Runs Dalvik-specific byte-code generated from Java-based apps,

Laura Gheorghe, Petre Eftime

Keywords

23

Linux kernel

AOSP

Android Runtime

Libraries

Activities

Services

Broadcast Receivers

Content Providers

Intents

Binders

ADB

Emulator