slides - Computer Science - University of Massachusetts Lowell

Download Report

Transcript slides - Computer Science - University of Massachusetts Lowell

Android OS Development
What Lies Beyond SDK !
Bhanu Kaushik
April 16 2013
PhD Student
Department of Computer Science,
University of Massachusetts, Lowell, MA.
Learning with Purpose
Outline
• Session I : Android OS
–
–
–
–
Introduction
Android Architecture
Download and Build
Android Code
Organization
– Implementation - Demo
– SmartParcel
– Session I – Summary
Learning with Purpose
• Session II : Android SDK
– All You Need to Know
– Samples
– Summary Session II
Introduction
Well This is Not Necessary !
Supports Millions
of mobile devices
in more than 190
countries.
It's the largest
installed base of
any mobile
platform.
Learning with Purpose
Session I
Android OS
Learning with Purpose
Session I
What will we learn !
How to get Android Source code ?
What Goes Where in Android ?
How to Compile the code ?
How can I create apps shipped with OS ?
How to modify OS to offer new Services?
How to use custom services in Apps ?
Using all above , How can I provide
solutions to real life problems ?
Learning with Purpose
Android Architecture
Learning with Purpose
Android Architecture
Enhancements over Linux 2.6
Binder: OpenBinder-based driver to facilitate inter-process
communication (IPC)
Android Power Management: a light weight power
management driver optimized for embedded systems.
Low Memory Killer: To kill off processes to free up memory
as necessary.
Logger: A light weight logging device used to capture
system, radio, log data, etc.
USB Gadget: Uses the USB function framework.
Android/PMEM: Provide contiguous physical memory
regions to userspace libraries that interact with the digital
signal processor (DSP).
Android Alarm: A driver which provides timers that can
wake the device up from sleep.
Learning with Purpose
Download and Build
Environment Setup
Available at,
http://source.android.com/source/initializing.ht
ml (Link)
Requirements
Linux or MacOS (Only Unix Based Systems)
Python 2.6 -- 2.7 (python.org.)
GNU Make 3.81 - 3.82 (gnu.org,)
JDK 6 if you wish to build Gingerbread or newer
JDK 5 for Froyo or older. You can download both
from (java.sun.com.)
• Git 1.7 or newer (git-scm.com.)
•
•
•
•
•
Learning with Purpose
Download and Build
Download
Available at,
http://source.android.com/source/downloading.ht
ml (Link)
Basic Steps
•
•
•
•
Initialize Repo
Choose Build Version (Link)
Sync Repo
Go Grab a coffee – This will take a while !
Learning with Purpose
Download and Build
Build
Instructions available at (Link)
Basic Steps
Setup Environment paths
• $ source build/envsetup.sh
Choose Build Target using lunch
• $ lunch full-eng
• $ make –jN (j4, j8…j32)
• Chose N between 1 and 2 times the number of hardware
threads on the computer being used for the build
Go Grab a Lunch and a Nap – This will take a
Loooong time!
Learning with Purpose
Android Code Organization
Lets Dive into the Code
Learning with Purpose
Android Code Organization
What we have seen so far !
/bionic.: where the bionic library is.
/build/: is the main make file system.
/dalvik/: where the Dalvik VM and dex compiler is.
/development/: integration to IDE like eclipse emacs etc.
/device/: device specific code lies here.
/external/:external libraries go here. Eg. Skia, jpeg, sqlite.
/frameworks/:all the android frameworks go here.
/hardware/: HAL, hardware abstract layer
/prebuilt/: all the prebuilt code. Linux Kernel goes here.
/packages/: all default apps shipped with system
/out/: final output directory.
Learning with Purpose
Implementation - Demo
Learning with Purpose
Implementation
System APP - Steps involved
Create App using SDK (or otherwise)
Turn off the Build Automatically in Eclipse.
Copy the code to /packages/apps/YOUR_APP
Create make file
Template
•
•
•
•
•
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call my-dir/src/)
LOCAL_PACKAGE_NAME := AppCall
include $(BUILD_PACKAGE)
Expose Application
• In /build/target/product/core.mk
• Add , YOUR_APP \ in product packages section
Learning with Purpose
Implementation
Steps involved
Create service Aidl
(Link)
Add AIDL to Build
Add Service
Functionality
Expose service
Use the service
Learning with Purpose
Session I
SmartParcel: A Collaborative Data
Sharing Framework for Mobile
Operating Systems
Bhanu Kaushik∗ , Honggang Zhang†, Xinwen Fu∗, Benyuan Liu∗ , Jie Wang∗
∗Department
of Computer Science, University of Massachusetts, Lowell, MA.
†Department of Computer and Information Science, Fordham University, Bronx NY
Learning with Purpose
Introduction
Huge number of Mobile Devices such as Smartphones,
Tablets, PDAs, portable media players etc.
“About 6.2 billion users around the globe” – Ericsson,
2012.
These devices support large number of Internet based
applications.
These Applications work on simple one-to-one clientserver data distribution model.
Results in:
•
•
Increasing concerns about volume of global
online digital content generated by these devices.
Multi-fold increase in Network traffic
originating from these devices
• “100 PetaByte/Month in 2007 to 700
PetaByte/Month in 2012”-Ericsson, 2012.
•
Learning with Purpose
Huge incumbent content availability and
maintainability cost.
Motivation and Related Work
Motivation
Major challenges faced by mobile Internet
users
•
•
•
•
•
Carrier enforced limited data plans,
Unavailability of hardware (3G or LTE),
Unavailability of access points,
Service outages and
Network and server overloads.
Results in:
• Unavailability of application data to the users
• High service maintainability cost, to both the
service providers and hosting servers.
Learning with Purpose
Motivation and Related Work
Related Work : Data Offloading
Proposed Solutions for data offloading
• Large Scale
• Alvarion, “Mobile data offloading for 3G and LTE networks.”
• Cisco, “Architecture for mobile data offload over Wi-Fi access networks.”
• Small Scale
• Han et. al. “Mobile data offloading through opportunistic communications
and social participation”
• Lee et. al., “Mobile data offloading: How much can wifi deliver?”
Unaddressed Issues:
• Entail huge changes in both, state of the art software and
hardware technologies
• Do not take into account the heterogeneity of application data.
Learning with Purpose
Motivation and Related Work
Related Work: Opportunistic Data delivery and Familiar
Strangers
Delay-Tolerant Networks (DTN)
• Target the interoperability between and among
challenged networks
Familiar Strangers
• Coined by Stanley Milgram in 1972,
“Individuals that regularly observe and exhibit
some common patterns in their daily activities”.
SmartParcel uses the idea of opportunistic
connectivity and in-network storage and
retransmission from DTN architecture to
ensure data delivery among the nodes in a
“Familiar Strangers” network set up.
Learning with Purpose
Problem Definition
SmartParcel
Our Goal is to develop framework of a Mobile data offloading and Service
Assurance scheme by encouraging collaborative data sharing among
spatio-temporally co-existing mobile devices.
Fig. 1 : Proposed SmartParcel Approach
Learning with Purpose
Architecture
Components
Service Discovery Manager
Data Transfer Manager
Service Cache Manager
• Dynamic Cache
• Static Cache
Network Interface Manager
Service APIs
Central Control Manager
Fig. 2 : SmartParcel Service Architecture.
Learning with Purpose
Architecture
Component Details
Service Discovery Manager:
• Identifies the available candidates for data transfer by broadcasting a “SYN”
message periodically
• “SYN” packet contains meta-data about applications registered to
SmartParcel.
• The meta-data is organized as a key value pair, i.e., (“ApplicationId,
TimeStamp”).
• At receiver, based on the meta-data information it sets up a one-to-one
connection
Data Transfer Manager:
• Manages the data transfer.
• Can manage concurrent connections to multiple devices.
• To reduce the network overhead, sends data for multiple applications as one
chunk.
Learning with Purpose
Architecture
Component Details
Service Cache Manager:
• Service cache to store the application specific (heterogeneous ) data .
• Dynamic Cache
• In-memory cache for storing the applications meta-data information.
• Implemented as Hash Map with (Application Id, Timestamp) as key-value
pairs.
• Static Cache
• Static cache for storing the actual application specific data.
• Maintained as SQLite database.
• Schema “Ap- plication Id (as string), Data (as blob), Time Stamp”
• Primary key : Application id and timestamp
• Flexibility to developer to assign “Time to live” and “Reset-Time” for the
application data, end of day by default.
Learning with Purpose
Architecture
Component Details
Central Control Manager:
• Manage the control from all components of the SmartParcel service.
• All components work under same instance for synchronous operation.
Network Interface Manager:
• Internal service, responsible for managing network connections.
• Assists Service Discovery for identifying available devices on different
network interfaces (3G, LTE, WiFi, BlueTooth etc.).
Service APIs:
•
•
•
•
Subscribe or unsubscribe to service
Update app data
Settings
Sharing statistics etc.
Learning with Purpose
Architecture
Android and SmartParcel
Group Name
BlueTooth
WiFi
NFC
DISk-IO
SMP_ALL
√
√
√
√
SMP_BLUETOOTH
√
×
×
√
SMP_WIFI
×
√
×
√
SMP_NFC
×
×
√
√
SMP_BT_WIFI
√
√
×
√
Table 1 : Resources used in different permissions
Fig. 3 : Integration of SmartParcel in Android framework
Android SDK
•
•
New set of permissions.
SMP_ALL, SMP_BLUETOOTH, SMP_WIFI,
SMP_NFC and SMP_BT_WIFI.
Android OS
•
•
•
•
Learning with Purpose
Integrated in the “System Server” module.
System Server is launched by Zygote.
Zygote forks the SmartParcel service as a system
service.
Ensures system level privileges and independence
from the application “context”.
Simulation Setup
Data Set
MIT Reality Mining Data Set
• 100 unique devices, 500,000 hours, 9
months
• We use the Bluetooth encounters data.
Table 2 : Data Set Description
Encounters
Activity
Maximum
65
901
Minimum
2
4
Mean
4
243
Std. Dev.
8.67
133
Fig 4 : Distribution of Active Devices Per Day.
Learning with Purpose
Fig 5 : Distribution of Device Encounters.
Fig 6 : Hourly Variation of Device Encounters.
Simulation Setup
Setup Parameters
Data Refresh Rate (DRR) : The frequency with which the
data is being refreshed.
Allowed Server Connections (ASC) : Number of devices
allowed to get data from server on each day.
User Participation Probability (UPP) : The Probability of user
acting selfish, i.e., limiting its participation by only receiving
data and not sending data
We measure the Data Availability Ratio (DAR)
Learning with Purpose
Results
Effect of user’s social activity level
User Participation Probability
(UPP) = 100%
Data Refresh Rate (DRR) =1
Refresh interval
Fig 6 : Effect of ASC on DAR over the Day, when ASC = 1
Fig 8 : Effect of ASC on DAR , when ASC =1 to 75 devices.
Learning with Purpose
Fig 7 : Effect of ASC on DAR over the Day, when ASC = 30
Results
Effect of Data Refresh Rate (DRR)
User Participation Probability (UPP) = 100%
Data Refresh Rate (DRR) = 2 Refresh intervals,
12:00am -11:59am and 12:00am-07:59am
Fig 9 : Variation of Data Availability Ratio (DAR) with Data Refresh
Rate (DRR) when DRR = 2 and Refresh Interval 12:00 am - 11:59 am.
Learning with Purpose
Fig 10 : Variation of Data Availability Ratio (DAR) with Data Refresh
Rate (DRR) when DRR = 2 and Refresh Interval 12:00pm - 11:59pm.
Results
Effect of Data Refresh Rate (DRR)
User Participation Probability
(UPP) = 100%
Data Refresh Rate (DRR) = 3
Refresh intervals.
Fig 12 : Refresh Interval 08:00am-03:59pm.
Fig 11 : Refresh Interval 12:00am-07:59am.
Learning with Purpose
Fig 13 : Refresh Interval 04:00pm-11:59pm.
Results
Effect of Selfishness
User Participation Probability (UPP) = 10%, 20%, 50% and 90%.
Data Refresh Rate (DRR) = 1 Refresh interval
Allowed Server Connections(ASC) = 1 to 90 devices.
Fig 14 : Variation of Data Availability Ratio with User Participation
Probability(UPP) and Allowed Server Connections(ASC).
Learning with Purpose
(*Median of 1000 Simulation runs)
Conclusions and Future Work
“SmartParcel” - A novel approach for Data sharing among co-existing and
co-located devices is presented.
“One for all”, multiple incentive system for application developers, Internet
service providers and application data providers (eg. cloud services) with
collateral benefits for the consumer itself.
We discussed the Design and implementation “SmartParcel” in Android.
Implementation in android framework dictates the feasibility of the
architecture.
Flexibility of design ensures integration in almost every existing mobile
operating system.
In the future, we intend to investigate the scalability and performance
issues encountered on real devices.
Learning with Purpose
Session I : Summary
 Android Source code Download
 Code Organization in Android- What Goes
Where.
 Compiling the code.
 Creating Apps shipped with OS
 Modifying OS to offer new Services
 Using custom services in Apps
 Demo of Sample project - SmartParcel
Learning with Purpose
Session II
Android SDK
Learning with Purpose
Session II
What will we learn !
Getting the right tools !
Basic Android app
Services in Apps
AsyncTask -Performance Enhancement
Sound Recoder demo
Learning with Purpose
Implementation - Demo
Learning with Purpose
Session II
Summary !
 Basic Android app
 Services in Apps
 AsyncTask -Performance Enhancement
 Sound Recorder demo
Learning with Purpose
Thank You !
Questions ?
Learning with Purpose