44
COM594 2015 Presentation Smartphone Architecture and Mobile Apps

COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Embed Size (px)

Citation preview

Page 1: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

COM594 2015 Presentation

Smartphone Architecture and Mobile Apps

Page 2: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Rationale

• More than in any previous machine, the smartphone architecture and the app are closely integrated;

Page 3: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Android (Google)

• Open Source• The OS Architecture is a stack of software

components using a layered abstraction mechanism

Page 4: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Android Architecture

Page 5: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Application Layer

The User-Interaction Layer: Top layer of the Stack:The Software Developer’s chief interaction at this layer is Testing:

Several standard applications come installed with every device, such as:• SMS client app• Dialer• Web browser• Contact manager

Page 6: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Application Framework

Key functionality:• Activity Manager: Manages the Activity Life-cycle of the Application:• Content Providers: Manage data-sharing between applications.• Telephony Manager: Manages Voice Calls• Location Manager: Location management: GPS or Cell-tower or other AP• Resource Manager: manages all of the resources needed to support a project

• Static code content, bitmaps, colours, Layout definitions, animation, etc.

Page 7: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Library Layer

The Native Libraries comprise the software needed to allow the phone to deal with different types of data. For example, the Media Framework Library providesthe support for the recording and playback of various audio and video file formats.

Page 8: COM594 2015 Presentation Smartphone Architecture and Mobile Apps
Page 9: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Open Source Libraries:

Page 10: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

The Android Runtime

On the same layer as the libraries, the Android Runtime Layer includes a set ofCore Java Libraries. Android Apps are constructed via Java. The Runtime includes the Dalvik Virtual Machine

Page 11: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

The Dalvik Virtual Machine

Page 12: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

The Dalvik Virtual Machine (2)

• The Runtime comprises the DVM and the core libraries• The DVM is a type of JVM• It is optimized for low processing power• It is optimized for low memory environments• It Runs .dex files (Not .class files)• .dex files are built from .class files at compile time• DVM supports multiple instances of the VM

• It implements support for:• Security;• Isolation;• Memory Management;• Threading

Page 13: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Architecture including Hardware Abstraction Layer

Page 14: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Hardware Abstraction Layer

The hardware Abstraction Layer is conceptually between the Libraries and the Kernel. It is essentially the lowest layer which the developer accesses.This layer provides a software abstraction of the physical hardware and provides the access point for an apps hardware implementation.

Page 15: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

The Kernel Layer

Essentially the interface to the hardware: The key functions of the kernel are:• Hardware Abstraction;• Memory Management;• Security Management;• Power Management• Hardware Drivers;• Shared-Library support;• The network Stack

The Kernel is never accessed directly by the developer. Access is via the hardware Abstraction layer

Page 16: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Android Kernel Evolution

Android Version 4.4 KitKat: Kernel Version:

More detail at: http://en.wikipedia.org/wiki/Android_version_history

Page 17: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Android Version History

Page 18: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Hardware

• The primary Hardware Platform supporting Android is the 33-bit ARMv7 architecture:

• The Android• Intel began providing microprocessors for

Android in 2012

Page 19: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Architecture and Apps

• Hardware designed to maintain low power:• Apps not in use are suspended automatically• Suspended apps do not consume power• Apps do not require closing and reopening• Automatic memory management• If memory gets low, inactive apps (and

processes) get ‘killed’ in ‘oldest-first’ order;

Page 20: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Memory Management

• The process is supposed to be transparent to the user

• Lack of care by developers has resulted in ‘task-Killer’ apps on the market. ??

Page 21: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Open Source

• Android Development is done ‘in private’ by Google until release:

• Then the source code is made public• Source code is subsequently modified by

OEMs.• Source code does NOT contain proprietary

device drivers

Page 22: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Google Upgrade Policy

• Upgrades are typically every 9 or 10 Months• Upgrades are slow to roll-out to devices– (Except Google Nexus ?)

• Manufactures implement policy on updates• Older Smartphones may not be updated• A view persists that not upgrading will incentivise

the move to new devices• Difficult for App Developers to maintain quality

of provision in such circumstances?

Page 23: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Impact of Wireless

• Wireless Carriers must update Android with their comms ‘apps’.

• These typically take longer to test and evaluate.

Page 24: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Google Play Services

• In 2012, Google began decoupling core applications from the Kernel

• The objective was that they could be updated independently from Android OS

• Google Play Services: A system-level process which provides APIs for Google Services.

• Essentially enables new OS functionality to be added without a complete OS update.

Page 25: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Contribute to the Android Open Source Project (AOSP)

• Companies and Individuals can contribute to Android Development through AOSP

• Largest contributors are Device and chipset manufactures

• Google has the final say!• To join in, visit the Android contribution

discussion:• https://groups.google.com/forum/?

fromgroups#!forum/android-contrib

Page 26: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

AOSP

• Want to fix a bug?• Visit the issue tracker:• https://code.google.com/p/android/issues/list• Contributions are described in detail at• http://source.android.com/source/contributin

g.html

Page 27: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

AOSP Quality Control

• Contributions must comply with the Android Code Style Guidelines

• http://source.android.com/source/code-style.html

• Be patient– Google get a huge number of contributions– Most submissions never make it– Some do but Google are very careful

• The next slide shows the Workflow of a patch-

Page 28: COM594 2015 Presentation Smartphone Architecture and Mobile Apps
Page 29: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (1)

• Don’t perform resource intensive operations on the main UI thread.– Always use asynchronous tasks or threads to offload

blocking operations• Use efficient data structures and algorithms– Responsive apps = happy users

• Use recursion with care– Never use recursion unless it is absolutely necessary

• Recursion is never absolutely necessary

Page 30: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (2)

• Save your state and assume that your application will be stopped or suspended at any moment– If your application is suspended or closed, you

cannot expect the user to do anything (click a button, or whatever!

– Ensure that your application can resume gracefully

Page 31: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (3)

• Start up fast and Resume fast– You cannot afford to have the user waiting (Mostly

they won’t)• During long operations, inform the user by

using progress bars– Consider offloading heavy processing to a server

instead of processing on the device• Better performance• Saves battery drainage

Page 32: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (4)

• Ensure that long operations are likely to succeed before embarking upon them– For example, if your application downloads large

files, check for network connectivity, file size, and available space before attempting the download

Page 33: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (5)

• Minimize use of local storage – Most devices have very limited amounts– Use external storage• Remember that an SD card is ‘external storage’• Remember also that SD cards can be ejected• Remember also that SD cards can be swapped• Your app should handle all of these scenario’s gracefully

Page 34: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Designing Stable and Responsive Mobile Applications (6)

• Understand that data calls to content providers (and across the AIDL boundary) have a performance ‘hit’ so use judiciously

• Establish an application resource-consumption model and verify that this matches your target audience.– Gamers might reasonably anticipate and accept shorter

battery life– Productivity app users will expect lightweight power

drainage and in any case won’t always carry a charger!

Page 35: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Common mistakes in app development

• Trusting the emulator– You must test on a real device

• Forgetting to add new application activities and required permissions to the AndroidManifest.xml file

• Forgetting to display Toast messages using the show() method• Hard-coding information, such as network info, test user

information and other data into the application• Forgetting to disable diagnostic logging before release• Distributing live applications with debug enabled

Page 36: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Design for Easy Upgrades and Updates

• Updates: Modifying manifest information and redeploying the updated application on user devices– Schedule updates so that they are frequent enough to

be useful, but not so frequent that the user is constantly interrupted• You must have an update strategy

• Upgrading: Creating a new application package with new features, and deploying it as a separate application that the user must choose to install

Page 37: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Windows Phone 8.1

• One standard hardware platform• Strictly controlled• Any manufacturer can make a Windows Phone• All functionality including the UI is standard• No manufacturer specific interfaces or system

software• Security Model

Page 38: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Windows Phone 8 Platform Stack

Page 39: COM594 2015 Presentation Smartphone Architecture and Mobile Apps
Page 40: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Security Model

Page 41: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Security Chambers and Principle of Least Privilege

• The Windows Phone Security model is based on the concept of Security Chambers:– Isolated containers in which processes are created

and executed• Chambers are granted ‘Access Rights’• Access Rights are granted on the principle of

Least Privilege– An app should not be granted the rights to do

anything beyond what is strictly necessary to perform its stated functions.

Page 42: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Case Study

• Consider how the understanding the platform design supports all of the concepts discussed:– For example, How does Windows Phone 8

implement Least Privilege– How does Android compare

• What advantages does learning the OS/Hardware Architecture bring to the app designer and developer?

• Support your views with specific examples

Page 43: COM594 2015 Presentation Smartphone Architecture and Mobile Apps

Microsoft Windows Phone 8

• Case Study: Windows Phone 8 Development Internals:

• http://scisweb.ulster.ac.uk/~derek/com594_2014/Reading2014/

• Chapter 1: Vision and Architecture• Chapter 2: App Model and Navigation