+ All Categories
Home > Documents > Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android...

Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android...

Date post: 03-Jul-2019
Category:
Upload: hoangnhu
View: 224 times
Download: 0 times
Share this document with a friend
15
Android Fundamentals Gaurav Mitra
Transcript
Page 1: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

AndroidFundamentals

Gaurav Mitra

Page 2: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Scope

Topics to be covered, and assessed:

I Android Fundamentals

I Android Studio Overview

I App Components (Activity, Service, Content Provider, BroadcastReceiver, Intent etc)

I User Interface or UI (View, Layouts, Input Controls, Input Events,Event Handlers, Menus, Notifications etc)

I Persistent Data Storage

COMP 2100/2500/6442 2/15

Page 3: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Scope

Topics beyond our scope (NOT to be covered):

I UI (Accessibility, Custom Components, Styles & Themes)

I Animation & Graphics

I Computation with Renderscript

I Media & Camera

I Connectivity (Bluetooth, NFC, Wifi P2P, USB, SIP)

I Synchronization via Cloud resources

I Web Apps

COMP 2100/2500/6442 3/15

Page 4: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Why Android?

I Smartphones are ubiquitous

I Four major smartphone operating systems - Android, iOS, WindowsPhone, Blackberry OS

I Android dominates the smartphone OS market share1I Q2, 2015: Android (82.8%); iOS (13.9%); Windows Phone (2.6%); Blackberry OS (0.3%); Other (0.4%)I Q2, 2014: Android (84.8%); iOS (11.6%); Windows Phone (2.5%); Blackberry OS (0.5%); Other (0.7%)

I Free and Open source2

I Supports multiple instruction-set architectures (ARM, x86 etc) and avariety of hardware platforms ranging from smartphones, tablets,laptops, set-top-boxes to watches, and soon.. cars!

I Built to run on top of the Linux kernel

I Focus on touch-based input i.e. UI is a major design priority

1http://www.idc.com/prodserv/smartphone-os-market-share.jsp.2https://source.android.com/.

COMP 2100/2500/6442 4/15

Page 5: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Software Construction Perspective

I Android incorporates the use of multiple software design patternsI Creating an android app requires knowledge of

I Java programmingI Adaptable software design - A single app could target many different

devicesI Responsive UI designI Security and permissionsI Mark-up languages such as XMLI Persistent storage solutions using databasesI Inter-process communication - Often between appsI Network communication

I Modularity is key in Android’s layered architecture

COMP 2100/2500/6442 5/15

Page 6: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Layered System Architecture

Loosely coupled layers built on top of each other3

I Application Framework: For app developers.Many developer APIs map directly to theunderlying HAL interfaces

I Binder IPC Proxies: Allows apps to make systemcalls to the System Server. This communication ishidden from the app developer

I System Services: Modular system and mediaservices

I Hardware Abstraction Layer (HAL): Definesstandard interface for the hardware vendors toimplement. Allows upper android layers to bedevice agnostic

I Linux Kernel: Special build using additions suchas wake locks

3https://source.android.com/devices/.

COMP 2100/2500/6442 6/15

Page 7: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Layered Software Stack

I Loosely coupled layers built on top of eachothera

I Android Framework: For app developers.Our scope is limited to this layer only.

I Android Runtime: Dalvik Java virtualmachine (VM). Most apps run on this VM

I Native Libraries: Some apps are runnatively such as core services

ahttps://source.android.com/security/index.html.

COMP 2100/2500/6442 7/15

Page 8: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Java Virtual Machine

I Java programs are device/processoragnostic

I Source compiled to Java bytecodeintermediate representation (IR)

I Bytecode is executed by a JVM

I JVM compiles bytecode to machine codeJust-in-time (JIT) i.e. during theexecution of the program

I JIT compilation is a combination ofAhead-of-time (AOT) compilation andinterpretation

I Machine code executed by OS on CPU

COMP 2100/2500/6442 8/15

Page 9: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Android’s Dalvik JVM

Design Requirements:

I Must work on resource constrained hardware - smartphones a fewyears back had limited amounts of RAM and processing power

I Application Sandbox - to ensure security, performance and reliability

I Lack of swap space

I Battery powered

COMP 2100/2500/6442 9/15

Page 10: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Android’s Dalvik JVM

Dalvik Design Features4:

I Every Android app runs in its own process, with its own instance ofDalvik VM

I Multiple Dalvik VM’s can run together efficiently

I Optimized intermediate representation: Dalvik Executable (.dex) -Minimal memory footprint

I dex tool compiles .class files to .dex files

I Since each app runs an instance of Dalvik, both creation andexecution of new Dalvik instances must be efficient

I Dalvik relies on the Linux kernel to provide threading and low-levelmemory management

Dalvik has now been replaced with the improved ART (Android Runtime). However,ART remains compatible with Dalvik and runs Dex bytecode5

4http://davidehringer.com/software/android/The_Dalvik_Virtual_Machine.pdf.5https://source.android.com/devices/tech/dalvik/.

COMP 2100/2500/6442 10/15

Page 11: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Android Code Path

I A typical smartphone has multipleprcessing elements such as a CPU, GPUand DSP

I Java code runs in the Dalvik or ART JVMwhich runs on the CPU

I How are the GPU and DSP cores used?OpenGL and Renderscript

I Renderscript code is compiled to LLVM IRbitcode

I LLVM Bitcode is JIT compiled andexecuted on the GPU or DSP

COMP 2100/2500/6442 11/15

Page 12: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Security Sandbox

No app, by default, has permission to perform any operations that wouldadversely impact other apps, the OS or the user6

I Android is a privilege-separated OS

I Each application runs in isolation, in a process sandbox, with its ownsystem identity (Linux UID, GID)

I Additional security provided via permissions

I Permissions enforce restrictions on specific operations that particularprocesses can perform

I Apps prevented from reading/writing user’s private data, other app’sfiles, unauthorized network access, keeping device awake etc

I The Dalvik VM is not a hard security boundary though - apps maystill execute native code using the Android NDK

6http://developer.android.com/guide/topics/security/permissions.html.

COMP 2100/2500/6442 12/15

Page 13: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Android Learning Resources

I Google developer docs:http://developer.android.com/guide/index.html

I API reference:http://developer.android.com/reference/packages.html

I Video training:http://developer.android.com/training/index.html

I Multiple books available

COMP 2100/2500/6442 13/15

Page 14: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Android Version History and API Levels7

I Android Alpha: First release - November 2007

I Android 1.0: First commercial release - API Level 1.0 - September2008

I Release schedule stabilized to two major releases every year 2010

I . . .

I Ice Cream Sandwich: Version 4.0-4.0.4 - API level 15 - October 2011- 97% of Android devices today have an API level equal or higherthan ICS

I . . .

I Lollipop: Version 5.0-5.1.1 - API level 22 - November 2014

I Marshmallow: Most recent version 6.0-6.0.1 - API level 23 - October2015

7https://en.wikipedia.org/wiki/Android_version_history.

COMP 2100/2500/6442 14/15

Page 15: Android - Fundamentals - Research School of Computer Science | · I Android Fundamentals I Android Studio Overview ... I Every Android app runs in its own process, ... memory management

Assignment 1 - Overview

I Objective: Build an Android app that can be usedto create, store, edit and delete simple notes

I A good example is Google’s own app - Keepab

I Assignment1 Specification is up

I Use minimum SDK version 15

I Labs 3 and 4 will focus on Android development

I Source code to be committed via git to CECSgitlab repository

I Week 7 due date: 28/03/2016 23:59 AEDT29/03/2016 10:00 AEDT

I No commits can be pushed after this time

I Final demo due in Week 7 labs

ahttps://www.google.com/keep/.bhttps://googleblog.blogspot.com.au.

COMP 2100/2500/6442 15/15


Recommended