1. HIT3328 / HIT8328 Software Development for Mobile
Devices
Dr. Rajesh Vasa, 2012
1
Lecture 01
Platforms and
Devices
Image Source: Google
2. R. Vasa, 20122
Lecture Overview
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
3. R. Vasa, 20123
Mobile Ecosystem
Ad
Networks
Platform
Content Providers
(Music/Video/Books)
Handset
OEMs
Telephone
Networks
App.
Distribution
Cloud
Infrastructu
re
Billing
4. R. Vasa, 20124
Mobile Ecosystem - Android
**Google, Double Click
Google, Amazon
Samsung, HTC, Motorola, Sony ...
Platform
Cloud
Infrastructure
Ad
Networks
Content Providers
(Music/Video/Books)
Handset
(OEMs)
Telephone
Networks
App.
Distribution
Billing
Google Checkout
Android
Google, Amazon
5. R. Vasa, 20125
Mobile Ecosystem - Apple
iTunes
iAd
Ad
Networks
Platform
Content Providers
(Music/Video/Books)
iPhone/iPa
d/iPod
Telephone
Networks
App.
Distribution
Cloud
Infrastructure
Billing
App Store
iTunes + App. Store
Dropbox, Google
iOS
6. R. Vasa, 20126
Lecture Overview - Where are we?
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
7. R. Vasa, 20127
App. Development Journey
â˘Application Planning
â˘Platform / Library Selection
â˘Develop and Test
â˘Prepare for Market and Deploy
â˘Monetization
â˘Analytics, Support and Update
Management
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
8. R. Vasa, 20128
App. Development Journey
â˘Planning
â˘User identification
â˘Concept / Prototype design
â˘Market research (focus groups)
â˘Requirements documentation
â˘[Business case / Budget]
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
9. R. Vasa, 20129
App. Development Journey
â˘Platform Preparation
â˘Identifying appropriate platform
â˘Selection of libraries and tools (increase
productivity)
â˘Development methodology
â˘Gap identification and learning plan
â˘Working with development community
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
10. R. Vasa, 201210
App. Development Journey
â˘Develop and Test
â˘IDE, SDK, Source code control tools
â˘UI construction / automation tools
â˘Emulators, Simulators, Debuggers
â˘Profiling and Testing tools
â˘Porting, internationalization
â˘Cloud infrastructure and services
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
11. R. Vasa, 201211
App. Development Journey
â˘Deployment
â˘Packaging and Signing
â˘Certification and Approval process
â˘Beta testing (Sandbox-ed networks)
â˘Localization
â˘Packaging and Managing versions
â˘Technical support frameworks
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
12. R. Vasa, 201212
App. Development Journey
â˘Monetization
â˘Distribution methods and channels
â˘Tools to aid promotion
â˘Ad. networks
â˘Billing and Settlement (in-app selling)
â˘Application usage profiling
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
13. R. Vasa, 201213
App. Development Journey
â˘Support and Tracking
â˘Analytics (tracking usage)
â˘User ratings, support
â˘Managing application upgrades /
updates
â˘Privacy management
Planning Platform Prep Develop & Test Deploy Monetize Support> > > > >
14. R. Vasa, 201214
Lecture Overview - Where are we?
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
15. R. Vasa, 201215
Typical Hardware Capabilities
â˘Mobile telephony
â˘Sensors & Actuators
â˘Location detector
â˘CPU / GPU (optimised to run on battery)
â˘Touch screen (&& || small keyboards)
â˘Networking (WiFi, Bluetooth, 3G, 4G...)
â˘High resolution battery efficient display
â˘Memory (onboard + SD Card)
16. R. Vasa, 201216
Sensors and Actuators
â˘Magnetometer
â˘Accelerometer/Gyro
â˘Temperature (and humidity) sensors
â˘Proximity / Light sensors
â˘Vibrator and Haptic feedback
â˘Camera (Front and Back) + Flash
â˘Vibrate motor
17. R. Vasa, 201217
Location Detection
â˘Location detection is possible at fine or coarse
level using:
â˘GPS (fine -- to few meters)
â˘Cell grid triangulation (to 100 meters)
â˘IP network location (Suburb / City)
18. R. Vasa, 201218
Touch Screen
â˘Resistive (cheaper) touch screen
â˘Detects a change in current when touched --
any object can touch it
â˘Need some pressure applied
â˘Capacitive (expensive) touch screen
â˘Respond to conductive surface (like a human
finger) -- capacitance change
â˘Ideal for gesture / multi-touch UI
19. R. Vasa, 201219
CPU / GPU
â˘Current generation in wide use
â˘CPU + GPU on single die
â˘~ 50% of the graphics power of a PS3
â˘Next generation (Tegra series chips)
â˘Dual/Quad core CPUs
â˘GPU (8-core or 16-core)
â˘Entire phone feature set on single chip
â˘Dual/Quad core are more power efficient
20. R. Vasa, 201220
Networking
â˘Full TCP/IP support
â˘WiFi (theory~54Mbps, practice~30Mbps)
â˘GPRS (48 Kbps) a.k.a. 2.5G
â˘3G (HSDPA ~ 7Mbps, HSUPA ~ 5Mbps)
â˘Bluetooth (~3Mbps, Next-Gen ~ 24Mbps)
â˘Note: If network is operating at 1Mbps, then
you can download a 1 Mega Byte file in 10
seconds. (Mbps is megabit per sec)
21. R. Vasa, 201221
Battery Technology
â˘Popular technology - Lithium-Ion
â˘Generally around 1500 mAh battery pack
â˘Current generation batteries will power,
â˘light use (typical): ~ 2 days
â˘heavy use (esp. internet): 6 to 10 hours
â˘game play/video: 2 to 3 hours
â˘Battery drain depends on sensor use (but
display is the largest consumer of power)
22. R. Vasa, 201222
Where does battery go?
â˘How is battery used (without GPS)?
â˘Display (50%)
â˘Cell grid usage including stand by (25%)
â˘WiFi (20%)
â˘Phone Idle (5%)
â˘If GPS is enabled -- it will use about 20-25% of
the battery power.
â˘Note: The above is based on an average user
23. R. Vasa, 201223
Memory
â˘Persistent Solid State Storage
â˘Flash memory (8/16/32Gb, @ ~10MB/sec )
â˘SD Card (@ ~ 4 - 6 MB/sec)
â˘2 Gb special memory for (O/S + drivers)
â˘Volatile
â˘RAM (256 Mb - 512 Mb)
â˘GPU shares RAM
â˘Memory read/write speed is a constraint
24. R. Vasa, 201224
Display Technology
â˘Bright / full colour - AMOLED, OLED, LCD
â˘Different resolutions are used
â˘eXtra High density (640 x 960 @ 320 dpi)
â˘High density (480 x 800 @ 240 dpi)
â˘Medium density (320 x 480 @ 160 dpi)
â˘Low density (240 x 400 @ 120 dpi)
â˘Physical width often ~ 2 inches (goldilocks
width for human hands)
â˘Height often between 2 - 4.5 inches
25. R. Vasa, 201225
Lecture Overview - Where are we?
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
26. R. Vasa, 201226
Next Generation Displays
â˘Most widely used are medium density and
high-density (320x480 @ 160 dpi and 480 x
800 @ 240 dpi )
â˘iPhone4 is ~ 320 dpi (more pixels per inch)
Image Source: Gizmodo
27. R. Vasa, 201227
What are the constraints?
â˘As a developer you need to,
â˘Know typical usage (minutes or hours)
â˘Understand sensors (efficiency / accuracy /
reliability / batt. drain)
â˘Know network is unreliable and offers erratic
speeds
â˘Be aware that the phone may/will/can ring
â˘Display size, DPI & processor speed are
variable
28. R. Vasa, 201228
More constraints....
â˘You must develop apps that,
â˘Use only a few MB of memory
â˘Are a couple of MB in size
â˘Store data as efficiently as possible
â˘Can work with sensors where precision is not
identical across devices (even iPhone has 3
generations in wide-spread use)
â˘Can work with a range of memory, cpu, and
GPU capabilities
29. R. Vasa, 201229
Biggest Constraint of ALL
â˘The Phone can (will) RING
â˘When the phone rings,
â˘Your app. is put in the background by O/S
â˘If you want to save state -- you have to manage
this
â˘When the phone call ends,
â˘The O/S will try to bring your app. back into
the foreground (but not guaranteed)
30. R. Vasa, 201230
Time for distraction...
⢠Guess how much effort went into the design and
construction of the core font (Droid Font) for the
Android platform?
⢠This was followed by even more work on the new
Roboto Font.
31. R. Vasa, 201231
Short Problem 1
â˘Scenario:
â˘You are developing a âStopwatch + Count Down
timerâ App.
â˘Use case: The user has set the count down
timer for 2 minutes -- pressed âstartâ. After 45
seconds, phone rings
â˘What is the behaviour of your app. when the
phone rings?
32. R. Vasa, 201232
Short Problem 2
â˘Scenario: You developed an app that âneedsâ
to download ~ 30MB of data daily (Common
for newspaper apps)
â˘How long will it take on,
â˘Home broadband/WiFi (3 Mbps), 3G (1.5
Mbps), GPRS (48 Kbps)
â˘Design choices will you make in terms of,
â˘How data is downloaded? Protocols supported?
Dealing with dropped connections?
33. R. Vasa, 201233
Short Problem 3
â˘Scenario: You are planning to develop an app.
that will show the weather forecast for a
particular location. You want to use the GPS to
obtain the location.
â˘However, obtaining an initial GPS lock takes
time (30 seconds -- 2 minutes)
â˘Do you think it is reasonable to ask the user
to wait a couple of minutes to get the location?
If not, what will you do different?
34. R. Vasa, 201234
Short Problem 4
â˘Scenario: Weather App.
â˘Phone (at home) has not been used for around
30 minutes.
â˘User wants to check the weather.
â˘The app. opens a network connection --
downloads the weather information.
â˘The app takes about 60 - 90 seconds to
download weather data. Why is it taking so
long? Is this a reasonable delay?
35. R. Vasa, 201235
Lecture Overview - Where are we?
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
36. R. Vasa, 201236
Mobile Operating System
â˘Operating System == Resource Manager
â˘Tight resource constraints on mobile
â˘Low powered (Batt. 1200 - 1500 mAh)
â˘Limited RAM (256 - 512 MB)
â˘Relatively small disk (8GB - 16GB)
â˘Small (yet power draining) display
â˘Network access - expensive yet needed!
â˘If phone rings -- call gets highest priority
37. R. Vasa, 201237
Mobile Operating Systems
â˘Very different to how PC operating systems
are designed
â˘The life cycle of an application is very tightly
controlled by O/S
â˘If an app. is a resource hog -- it will get killed
(or suspended) by the O/S
â˘O/S trickle allocates memory to apps, but
aggressively de-allocates it
â˘If a view/image is not in the
foreground/running -- then it will be destroyed
38. R. Vasa, 201238
Mobile Op. Systems are e-VIL?
â˘If you request a network connection -- but
have not used it for a while,
â˘O/S will power down network hardware
â˘O/S may close the connection / port
â˘If the devices goes to sleep (default is few
min.) then the memory allocated to app. is de-
allocated.
â˘O/S (thankfully) provide a short warning and
you have options to save data.
39. R. Vasa, 201239
Android App Life Cycle
Key feature of
a Mobile O/S
Remember: ~ 256MB only
available in RAM
Image Source:
http://developer.android.co
m
39
40. R. Vasa, 201240
iOS Application Life Cycle (is similar)
â˘Memory management is different in iOS
compared to Android
â˘iOS will still,
â˘Terminate apps. if memory needed (test for
yourself -- load few large games on an iPhone)
â˘Send an app. into background if Phone rings
â˘Flush caches (used by images mainly) at
regular intervals to free resources
41. R. Vasa, 201241
States of an App.
â˘An app. can be in one of the following states:
â˘Not Running (not launched)
â˘Running (foreground or background)
â˘Active
â˘In-Active (waiting for I/O)
â˘Suspended (background)
â˘Process state information is saved, but RAM
used is generally purged
42. R. Vasa, 201242
Short Problem 5
â˘Consider this hypothetical situation,
â˘Each time you minimise the IDE on your laptop
computer, the O/S will suspend the application
for 15 minutes -- then terminates the
application.
â˘If you were developing the IDE -- and want to
offer a reasonable user experience on this OS -
- what can you do?
43. R. Vasa, 201243
Mobile File Systems
â˘Designed to work with Flash memory
â˘Flash memory is designed for max. 10k writes
â˘File system is optimised to ensure that the
same block does not receive too many writes
(known as wear levelling)
â˘Write operation -> (erase first), then write data
â˘Read operations are faster than write
â˘Read speed ~ 6 MB/sec, Write ~ 3 MB/sec
â˘I/O speed optimisation critical in games
44. R. Vasa, 201244
Short Problem 6
â˘You have created a new âappâ for the Android
platform --
â˘App Size is 25MB (20M is media)
â˘What is the minimum load time for this app?
â˘Do you think this is a reasonable size for a
weather app.?
45. R. Vasa, 201245
When building mobile apps...
â˘Assume phone will ring
â˘Save state regularly (in fact, be paranoid)
â˘Assume resources are allocated reluctantly
â˘Assume erratic network connectivity
â˘Assume slow read/write speed to Flash card
â˘Use RAM carefully, minimise sensor use
â˘Inform user if any operation takes over 3 sec.
â˘Keep core use case as short as possible
46. R. Vasa, 201246
Lecture Overview - Where are we?
â˘Eco Systems and Development Journey
â˘Smartphone - Hardware Overview
â˘Hardware Constraints (Dev. perspective)
â˘Mobile Operating Systems
â˘Convention Over Configuration
47. R. Vasa, 201247
Convention Over Configuration
â˘Software design paradigm
â˘Aims to reduce decisions developers make
â˘Why is this needed?
â˘When we build software, there is a lot of
routine and repetitive decision making
â˘By following a certain development style, we
reduce the decisions we need to make
â˘What do we lose? -- Some flexibility, and
developers have to accept the convention
48. R. Vasa, 201248
Example ....
â˘Software systems often make use of a large
number of images (icons, background etc.)
â˘Developers now have to make a decision:
1. Store the images in a central directory?
2. Distribute them into different directories (closer to
modules?)
3. Store them in a database system?
4. Naming of images, meta-data?
â˘What is the best option? Will it work? Risk?
49. R. Vasa, 201249
Decision making process..
â˘In order to make a decision,
â˘Options must be identified (takes effort)
â˘Options must be ranked (opinions and ideas of
different developers will come into play)
â˘An option must be selected
â˘Team must accept the selected option
â˘May results in ... âdecision paralysisâ
â˘Worse, sub-optimal decision making +
increase in stress
50. R. Vasa, 201250
Coding by configuration...
â˘Consider the âimage storage exampleâ
â˘Assume developers have made a choice
â˘Developers have to explicitly write code to,
â˘Load these image resources
â˘Manage the location that they are stored in
â˘Find a consistent way to refer to these images
â˘Agree on a naming style etc...
â˘Work is done -- but has minimal value add
51. R. Vasa, 201251
Coding by convention..
â˘All images are stored in the âimagesâ directory
â˘Framework will automatically,
â˘Generate references to these images
â˘Provide code to load these images
â˘Enforce naming rules to identify different types
of images
â˘e.g. Icons will be named with ic_ prefix.
â˘We improve productivity -- in terms of reduced
decision making
52. R. Vasa, 201252
Why does this matter?
â˘Android prefers and dictates âconventionâ
â˘However,
â˘You can ignore the convention and fallback to
configuration
â˘Benefits of convention,
â˘Productivity improvement
â˘Improve team coordination
â˘Reduces unnecessary stress
â˘iOS development has its own conventions!
54. R. Vasa, 201254
Demo -- Hello World
â˘Create a âHello Worldâ app.
â˘Quick overview of the IDE & Emulator
â˘Create + Run app. (in emulator)
â˘Change the font size (run again)
â˘Display âHello, HIT3328 / HIT8328â
â˘Why do we have generated code?
55. R. Vasa, 201255
Lecture Review - Key points
â˘Understand the hardware and sensors
â˘Constraints are real -- must work within them
â˘Mobile Operating Systems
â˘Be paranoid about storing state
â˘Convention Over Configuration
â˘Follow the pattern -- increase productivity