Mobile Computing
COMP5216
Week 03 Semester 2, 2020
Dr Kanchana Thilakarathna School of Computer Science
The University of Sydney
Page 1
Announcements
– Change in Assignment 1 submission.
The University of Sydney Page 2
Announcements
– 15studentsstillhavenotregisteredforagroup. – Pleasetalktoyourtutortohelpyoufindagroup.
– Thereare5groupswithlessthan5members. – Pleasetalktome!
– Recalltheproposal:
– Whatistheproblemthatyourappwillsolve?
– Whydoestheproblemmatter(e.g.,motivationandsignificance)?
– Whatistheappsolutiontotheproblem?
– Howwillthesolutionbeimplemented(whichshouldbeclearforothersto implement)?
– Discussyourideawithme.
– SometimesIaskquestions,argue,…
– Don’tagreewithmealways,comewithevidence! – HowdoIlookatyouridea…
– Asateacher,AsanEngineer/Developer,AsanInvestor The University of Sydney
Page 3
Outline
– Capabilities of modern smartphones – Sensors
– Audio
– Connectivity – Camera
– Android Basics 2
– Broadcast Receiver – Content Provider
– Services
The University of Sydney
Page 4
Capabilities of smartphones
The University of Sydney
Page 5
https://www.geckoandfly.com/13143/50-things-smartphone-replaced-will-replace-future/
Smartphone capabilities
Smartphone
– Motion–Accelerometer,Gyroscope
– Vision–MultipleCameras
– Connectivity–LTE,WiFi,Bluetooth,NFC
– Location–GPS,AssistedGPS
– Audio–Speaker,Microphone
– Haptic–Touch-screen,buttons
– Biometric–HRmonitor,Irisscan,Fingerprintscan
– Environment–Magnetometer,Barometer,Proximity, Ambient Temperature, Ambient Light, Humidity, Ultraviolet (UV), Moisture, Pressure
The University of Sydney
Page 6
Today’s Takeaway
– Smartphones are powerful.
– Allows developers to come up with innovative applications.
– How can we take advantage of capabilities of smartphones ? – Can you solve the problem you found using these capabilities ?
– Can you use these capabilities to improve a current solution ? – Can you exploit these capabilities for an innovative new app ?
The University of Sydney Page 7
Hardware vs Software
– Hardware capability/sensor
– Physical components built into a handset
– E.g. Accelerometer, Gyroscope, Ambient light, Pressure
– Software capability/sensor
– Derive their data from one or more of the hardware-based sensors
– E.g. Step Counter, Orientation – For sensors;
– Each sensor is accessible through the Android Sensor Framework [1]
– Sensor availability is based on the actual handset and Android version.
[1] https://developer.android.com/guide/topics/sensors/sensors_overview
The University of Sydney Page 8
Listing sensors in a device
E.g. List of sensors in Android
– Proximity
– Light
– Accelerometer
– Gyroscope
– Gyroscope (uncalibrated)
– Magnetometer
– Magnetometer (uncalibrated)
– Pressure
– Orientation
– Step detector
– Step counter
– Significant motion
– Gravity
– Linear Acceleration
– Rotation Vector
– Geomagnetic Rotation Vector
– Temperature
– Game Rotation Vector – Tilt Detector
– Pickup Gesture
– Sensors Sync
– Double Twist
– Double Tap
– Window Orientation
The University of Sydney
Page 9
Accelerometer
– Acceleration is the second derivative of displacement.
– One method is to get the displacement signal and calculate the
second derivative.
– There are various types of accelerometers. Smartphones usually comes with Tri-axial MEMS (Micro-Electro-Mechanical Systems) accelerometers.
The University of Sydney Page 10
Gyroscope
– Gyroscope measures the rate of rotation in rad/s around a device’s x, y, and z axis
– Providesprecisedeviceorientationthanaccelerometer
– Oftenusedincombinationwithaccelerometer
– WhatcanwedowithAccelerometers and Gyroscopes ?
– Camera/Photoapps
The University of Sydney
Page 11
Accelerometer + Gyroscope
– One of the most used sensors
– Provides the information of device movement across all three
axes.
– Determine device’s orientation – Portrait or Landscape
– Screen facing up or down
– Games
– Activity monitoring – Step counting
– Running or walking
– Speed of running
– Distance travelled (when GPS is not available)– How ?
– What else can we do? The University of Sydney
Page 12
Accelerometer + Gyroscope
The University of Sydney Page 13
Magnetometer
– Detect magnetic fields (e.g. earth magnetic field)
The University of Sydney
Page 14
What else can we do ?
Magnetometer
The University of Sydney Page 15
Proximity sensor
– Infrared (IR) LED (Transmitter) and IR Receiver – Not visible to human eye
IR transmitter
IR receiver
– What is the most common use case of proximity sensor ? – Whatelsecanwedo?
The University of Sydney
Page 16
Object
Environment sensors
– Ambient Light
– Adjust screen brightness – Why ?
– Atmospheric pressure sensor – Barometer – Improve GPS accuracy – How ?
– Temperature sensor
– Shuts device down if overheated
– Humidity sensor
– Contributes to air quality measurements
The University of Sydney
Page 17
Environment sensors
– Ambient Temperature, Ambient Light, Humidity, Ultraviolet (UV), Moisture, Pressure
– Crowdsourced weather apps
The University of Sydney Page 18
Haptic
– Touchscreen – Advanced user interaction methods – Multiple modes of touch
– Multiple modes of swipe
The University of Sydney
Page 19
What else can we do ?
Haptic
– Touch patterns for user authentication
– Alexander De Luca, Alina Hang, Frederik Brudy, Christian Lindner, and Heinrich Hussmann. 2012. Touch me once and i know it’s you! implicit authentication based on touch screen patterns. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems (CHI ’12). Association for Computing Machinery, New York, NY, USA, 987–996.
– Touch for cross-device tracking of usage
– Masood, R., Zhao, B. Z. H., Asghar, H. J.,&Kaafar, M. A. (2018). Touch and You’re Trapp (ck) ed: Quantifying the Uniqueness of Touch Gestures for Tracking. Proceedings on Privacy Enhancing Technologies, 2018(2), 122- 142.
– Soft biometric prediction using touch characteristics – Gender, age
– Emotion
– Miguel-Hurtado, O., Stevenage, S. V., Bevan, C.,&Guest, R. (2016). Predicting sex as a soft-biometrics from device
interaction swipe gestures. Pattern Recognition Letters, 79, 44-51.
– Touch to enable parental controlling on the phone
– X. Li, S. Malebary, X. Qu, X. Ji, Y. Cheng, and W. Xu, “icare: Automatic and user-friendly child identification on smartphones,” in Proceedings of the 19th International Workshop on Mobile Computing Systems; Applications, ser. HotMobile ’18. New York, NY, USA: ACM, 2018, pp. 43–48.
The University of Sydney
Page 20
Audio
– Speakers
– Microphones
The University of Sydney
Page 21
What else can we do ?
Audio
– Voice Recognition
– Personal assistants – “Hey Siri” and
“OK Google”
– Driven by the recent advances of deep machine learning
– Ultra-sound (beyond 18kHz) based solutions
– How can we user Audio as a sensor for Advertising ?
The University of Sydney
Page 22
Audio
– Acoustic motion tracking
– Wenguang Mao, Jian He, and Lili Qiu. 2016. CAT: high-precision acoustic motion tracking. In Proceedings of the 22nd Annual International Conference on Mobile Computing and Networking (MobiCom ’16). ACM, New York, NY, USA, 69-81
–
– Encounter profiling
– Huanle Zhang, Wan Du, Pengfei Zhou, Mo Li, and Prasant Mohapatra. 2016. DopEnc: acoustic-based encounter profiling using smartphones. In Proceedings of the 22nd Annual International Conference on Mobile Computing and Networking (MobiCom ’16). ACM, New York, NY, USA, 294-307.
– BreathPrint: breathing acoustic for user authentication
– Chauhan, J., Hu, Y., Seneviratne, S., Misra, A., Seneviratne, A.,&Lee, Y. (2017, June). BreathPrint: Breathing acoustics-based user authentication. In Proceedings of the 15th Annual International Conference on Mobile Systems, Applications, and Services (pp. 278-291). ACM.
Wei Wang, Alex X. Liu, and Ke Sun. 2016. Device-free gesture tracking using acoustic signals. In Proceedings of the 22nd Annual International Conference on Mobile Computing and Networking (MobiCom ’16). ACM, New York, NY, USA, 82- 94.
The University of Sydney Page 23
Biometric sensors
– Fingerprint and Iris scanning for authentication
– Samsung Galaxy S9 comes with a heart rate, blood oxygen level sensor
– Another IR base sensor
– Measure the characteristics of the received signal
The University of Sydney
Page 24
External Sensors
Seneviratne, S., Hu, Y., Nguyen, T., Lan, G., Khalifa, S., Thilakarathna, K., …&Seneviratne, A. (2017). A survey of wearable devices and challenges. IEEE Communications Surveys & Tutorials, 19(4), 2573-2620.
The University of Sydney Page 25
Connectivity
Wide Area Networks
Cellular Network Interface
Local Area Networks
WiFi (WLAN)
Near Field Communication
Bluetooth
WiFi-Direct AirDrop
The University of Sydney
Personal Area Networks
Page 26
Connectivity
– Connectivity empowers smartphones to control variety of smart devices
– New services through short-range connectivity
The University of Sydney
Page 27
Card-less Payment Location based services through
iBeacons
– Advertising, Indoor navigation, …
Connectivity
– Secure key-generation with wireless signal characteristics
– Zhang, J., Duong, T. Q., Marshall, A.,&Woods, R. (2016). Key generation from wireless channels: A
review. IEEE Access, 4, 614-626.
– Gesture recognition with wireless signals – http://witrack.csail.mit.edu
– Non-invasive Breathing disorder detection with smartphones
– Nandakumar, R., Gollakota, S.,&Watson, N. (2015, May). Contactless sleep apnea detection on smartphones.
In Proceedings of the 13th Annual International Conference on Mobile Systems, Applications, and Services (pp. 45-57). ACM.
The University of Sydney Page 28
Today’s Takeaway
– Smartphones are powerful.
– Allows developers to come up with innovative applications.
– How can we take advantage of capabilities of smartphones ? – Can you solve the problem you found using these capabilities ?
– Can you use these capabilities to improve a current solution ? – Can you exploit these capabilities for an innovative new app ?
The University of Sydney Page 29
Today’s Takeaway
– How can we take advantage of capabilities of smartphones ?
– Example Question 1: (solving an specific problem)
– You have one smart electric light and home WiFi. You want to switch-on your light when you move closer to the light (or a specific location). However, you do not have motion detection sensors with you. The developer of the smart electric light provides SDK to develop third party apps. How do you design a mobile app for this specific purpose ?
The University of Sydney Page 30
Camera
– 4K videos with 30fps
– Multiple cameras on one device
The University of Sydney
Page 31
What else can we do ?
Beyond photos and videos
The University of Sydney Page 32
Beyond photos and videos
– Document scanning apps
The University of Sydney Page 33
Beyond photos and videos
– VeinDeep – use vein patterns of your hand for authentication – Zhong, Henry, Salil S. Kanhere, and Chun Tung Chou. “VeinDeep: Smartphone unlock using vein patterns.” Pervasive Computing and
Communications (PerCom), 2017 IEEE International Conference on. IEEE, 2017.
The University of Sydney Page 34
Beyond photos and videos
– Visible light communication
– Stefan Schmid, Linard Arquint, and Thomas R. Gross. 2016. Using smartphones as continuous receivers in a visible light communication system. In Proceedings of the 3rd Workshop on Visible Light Communication Systems (VLCS ’16). ACM, New York, NY, USA, 61-66.
The University of Sydney Page 35
Beyond photos and videos
The University of Sydney Page 36
Mobile Augmented Reality
– Many AR SDKs
– Apple’s ARKit – https://developer.apple.com/arkit/
– Google’s ARCore – https://developers.google.com/ar/discover/ – Wikitude – https://www.wikitude.com/
– Cross-platform development – Unity – https://unity.com/solutions/mobile-ar
The University of Sydney
Page 37
Mobile AR
– Common features – Scene recognition – Object recognition – Tracking of objects – Motion tracking
The University of Sydney
Page 38
Mobile Mixed Reality
– Zapbox – http://www.zappar.com/zapbox/
– Mixed Reality Video – https://youtu.be/RnnZ3YQD4ig
– Google Cardboard – https://vr.google.com/cardboard/ – Google AR & VR – https://arvr.google.com
– Structure sensor for iPhone – https://structure.io/structure- sensor
The University of Sydney
Page 39
Today’s Takeaway
– Smartphones are powerful.
– Allows developers to come up with innovative applications.
– How can we take advantage of capabilities of smartphones ? – Can you solve the problem you found using these capabilities ?
– Can you use these capabilities to improve a current solution ? – Can you exploit these capabilities for an innovative new app ?
The University of Sydney Page 40
Today’s Takeaway
– How can we take advantage of capabilities of smartphones ?
– Example Question 2: (open-ended)
– You started a new company to sell small electronic items online. Smartphones can be used in numerous ways to enhance the efficiency of every business. How to do design an innovative mobile app to improve your productivity of your new business?
The University of Sydney Page 41
The University of Sydney
Page 42
Building blocks of Android – 2
Building blocks of Android
App components
– Activities
– Broadcast Receivers – Content Providers
– Services
– Activating components – Intent – Android Developer Page
– https://developer.android.com – Many books in the library
– Android App Development by Franceschi https://www.safaribooksonline.com/library/view/android-app- development/9781284092134/?ar
The University of Sydney
Page 43
Intents
– Intent is a messaging object to request an action from another app component.
– Primary use-cases:
– To start an activity
– To start a service
– To deliver a broadcast
– Intent types:
– Explicit Intents: Communicate within the same application. Need to
specify the exact name of the component , e.g. class name.
– Implicit Intents: Communicate between applications. Requested by declaring the general action to perform, e.g. location.
– https://developer.android.com/guide/components/intents-filters The University of Sydney
Page 44
Building bocks of an Intent
1. Component name
– Name of the component to start
• Must specify the name for Explicit Intent, e.g. class name of the new
Activity.
• Empty for Implicit Intent
2. Action
– String that specifies the desired operation, e.g. view or pick
The University of Sydney
Page 45
• • • •
ACTION_DIAL – Dial a number
ACTION_EDIT – Display data to edit
ACTION_SYNC – Synchronise device data with a server ACTION_MAIN – Start as initial activity of the app.
Building bocks of an Intent
3. Data
– –
– –
Data and type of data (MIME type) associated with the Intent
Type of data should be related to the action
• E.g. If the action is ACTION_DIAL, data should be the phone number.
Formatted as URI object (Uniform Resource Identifier)
• Uri.prase(“http://www.google.com”)
Note: To set both URI and MIME type, use setDataAndType()
The University of Sydney
Page 46
Building bocks of an Intent
4. Category
– String containing additional information about the component
• CATEGORY_BROWSABLE – To start a web browser to display data
– Specify the category with addCategory() 5. Extras
– Key-value pairs that carry additional information to complete the action
– Add extra info with putExtra()
6. Flags
– Metadata for the intent
• E.g. How to launch the activity, how to treat it after launching, etc.
– Can set flags using setFalgs()
The University of Sydney Page 47
Example
– Start another activity using an Intent – Example: Tutorial 2
– What type of an Intent is used ?
The University of Sydney Page 48
Example 2
– Communicate between apps.
– By declaring the general action to perform. In this case,
– Action:ACTION_VIEW
– Data: Formatted as Uniform Resource Identifier (URI object) to send Intent Data
– What type of intent is this?
– What can go wrong with the code above code block?
The University of Sydney
Page 49
Intent Filters
– Declare which Intents that your app can receive with intent- filter element in your AndroidManifest.xml
– This is how Android pass Implicit Intents to relevant apps
– Define
– E.g. Declaration to receive ACTION_SEND intent with text data
The University of Sydney Page 50
Intent Filters
– Who had a look at the AndroidManifest.xml files of Tutorial 1? – Were there any Intent filter?
The University of Sydney Page 51
Intent Filters
– ACTION_MAIN indicates this activity is the main entry point when the user launch the app and does not expect any intent data.
– CATEGORY_LAUNCHER indicates that activity’s icon should be placed in the system’s app launcher.
The University of Sydney
Page 52
Broadcast Receiver
– Things are happening all the time on an Android device.
– Many components need to know that some events have occurred.
– New package installed. – Phone call received.
– WiFi is connected.
– Device is rebooted.
– Android uses a Broadcast Intent to tell everyone about it.
– All intents can be found at BROADCAST_ACTIONS.TXT file in
the relevant SDK
– https://developer.android.com/guide/components/broadcasts The University of Sydney Page 53
Broadcast Receiver
– Broadcast Receivers register to receive events.
– Android routes the Broadcast Intents to Broadcast Receivers
that have registered to receive them. – Register for Broadcast Intents
– Statically:atAndroidManifest.xml
– Using
The University of Sydney
Page 54
Dynamic Registration
– At MainActivity.java – Steps:
– Create an Intent Filter
– CreateaBroadcastReceiver
– RegisterBroadcastReceiver(registerReceiver())
– UnregisterBroadcastReceiver(unRegisterReceiver()).
– To receive many broadcastsà?
The University of Sydney
Page 55
User permission
– To protect the privacy of the user
– Permissions are categorized as normal and dangerous – Declare permission at AndroidManifest.xml
The University of Sydney Page 56
Content Provider
– Provides access to a central repository of structured data.
– Use to securely exchange data between applications.
– AccessContentProvidersthroughaCursorLoaderand ContentResolver
– Database style interface.
– Android content providers
– Contacts, Audio, Video, Images, Calendar, User Dictionary
– For more info: http://developer.android.com/guide/topics/providers/content-
providers.html
The University of Sydney Page 57
Content Provider
– Accessing content provider – API “CURD” – Create (insert)
– Retrieve (query) – Update
– Delete
– Example: Accessing User Dictionary. Stores non-standard words that user wants to keep
The University of Sydney Page 58
Content Provider
– Querying from another app.
– mCursor = getContentResolver().query(
– Uri, à The content URI of the words table, FROM table-name
– projection, à The columns to return for each row
– selection, à Selection criteria, WHERE col = value
– selectionArgs, à Selection criteria
– sortOrder) à The sort order for the returned rows
– Content URI have the syntax:
– content://authority/path/id – E.g. //user_dictionary/words/5
– Remember to declare permission The University of Sydney
Page 59
Services
– Does not involve a GUI component. Runs in the background and suitable for long running processes.
– Example functionalities achieved through services are network communications, play music, and software updates.
– Three types of services: – Foreground
– Background – Bound
– For more info: https://developer.android.com/guide/components/services
The University of Sydney
Page 60
Services
– Foreground
– Operation is noticeable to the user and must display a Notification
– Does not require user interaction
– E.g. Audio playback
– Background
– Runs in the background
– E.g. downloading a movie
– Bound
– Offers client-server interface
– Allows other app components to interacts with the service
– E.g. for long running services and multiple operations
– https://developer.android.com/guide/components/bound-services
The University of Sydney
Page 61
Service Lifecycle
– Use explicit intent when starting a Service – Why ?
– Example:
– Design and app to increase the screen brightness to
maximum when phone is charging.
The University of Sydney
Page 62
Declaring components – AndroidManifest.xml
– Describes essential information about your app to Android OS – Examples:
– App package name
– Minimum API level required by the app
– User permissions
– Declare third party API libraries
– Declare app’s components, e.g. Activity
– Declare component capabilities through Intents and Intent filters
https://developer.android.com/guide/topics/manifest/manifest-intro
The University of Sydney
Page 63
What’s Next ?
Tutorial 3 – Data Storage and Management
– Each app is having its own storage where it can write – Internal Storage
– If it wants to write to the external storage it needs request for the permissions android.permission.WRITE_EXTERNAL_STORAGE.
– More details can be found at
– http://developer.android.com/training/basics/data-
storage/files.html
– Week 4: Challenges associated with mobile computing
The University of Sydney Page 64