Android Network Layer; Location Management - PowerPoint PPT Presentation

Loading...

PPT – Android Network Layer; Location Management PowerPoint presentation | free to download - id: 792727-YjA1M



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Android Network Layer; Location Management

Description:

Android Network Layer; Location Management Y. Richard Yang 3/2/2011 – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 35
Provided by: YangR46
Learn more at: http://zoo.cs.yale.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Android Network Layer; Location Management


1
AndroidNetwork Layer Location Management
  • Y. Richard Yang
  • 3/2/2011

2
Admin
  • Assignment 3
  • Schedule project meetings

3
Recap Android Software Framework
  • Components
  • Activity and view
  • Service
  • Broadcast receiver
  • Data providers
  • Resources and manifest
  • Intent as a component glue
  • Non-blocking/zippy processing
  • Thread, Handler, AsyncTask, IntentService
  • Notification

4
Recap Accessing Data in Cloud
  • A typical setting is that a device accesses data
    in the cloud
  • Two design points
  • poll
  • Tx more expensive than Rx
  • 5 min frequency 144 mAh / day
  • push

5
Solution Push
  • Google Contacts, Calendar, Gmail, etc., use push
    sync
  • A single persistent connection from device to
    Google
  • Android Cloud to Device Messaging (C2DM) to make
    it a public service

6
C2DM Overview
  • Uses existing connection for Google services
  • Your servers send lightweight data messages to
    apps
  • Tell app new data available
  • Intent broadcast wakes up app
  • App supplies UI, e.g., Notification, if/as
    necessary

7
C2DM Flow
  • Enabling cloud to device messaging
  • App (on device) registers with Google, gets
    registration ID
  • App sends registration ID to its App Server
  • Per message
  • App Server sends (authenticated) message to
    Google
  • Google sends message to device
  • Disabling cloud to device messaging
  • App can unregister ID, e.g., when user no longer
    wants push

8
C2DM
9
Android Code Registration to C2DM
  • // Use the Intent API to get a registration ID
  • // Registration ID is compartmentalized per
    app/device
  • Intent regIntent new
  • Intent(com.google.android.c2dm.intent.REGISTE
    R)
  • // Identify your app
  • regIntent.putExtra(app,
  • PendingIntent.getBroadcast(this, 0, new
    Intent(), 0)
  • // Identify role account server will use to send
  • regIntent.putExtra(sender, emailOfSender)
  • // Start the registration process
  • startService(regIntent)

10
Receiving Registration ID
  • // Registration ID received via an Intent
  • public void onReceive(Context context, Intent
    intent)
  • String action intent.getAction()
  • if (REGISTRATION.equals(action))
  • handleRegistration(context, intent)
  • private void handleRegistration(Context context,
    Intent intent)
  • String id intent.getExtra(registration_id)
  • if ((intent.getExtra(error) ! null)
  • // Registration failed. Try again later, with
    backoff.
  • else if (id ! null)
  • // Send the registration ID to the apps
    server.
  • // Be sure to do this in a separate thread.

11
Receiving Registration ID
  • App receives the ID as an Intent
  • com.google.android.c2dm.intent.REGISTRATION
  • App should send this ID to its server
  • Service may issue new registration ID at any time
  • App will receive REGISTRATION Intent broadcast
  • App must update server with new ID

12
Android Data Storage Model
  • Storage methods
  • Shared preference
  • Built-in SQLite database
  • Java file system using InputFileStream and
    OutputFileStream

13
Shared Preference
  • A per-application key-value store
  • SharedPreference prefs getSharedPreferences(myD
    ataStorage)
  • Editor mEditor prefs.edit()
  • mEditor.putString(username, myid)
  • mEditor.putString(password, mySecret)
  • mEditor.commit()

SharedPreference prefs getSharedPreferences(myD
ataStorage) String u prefs.getString(username
, null) String p prefs.getString(password,
null)
14
Content Provider
  • Each provider can expose its data as a simple
    table on a database model
  • Each content provider exposes a public URI that
    uniquely identifies its data set
  • android.provider.Contacts.Phones.CONTENT_URI
    android.provider.Contacts.Photos.CONTENT_URI
    android.provider.CallLog.Calls.CONTENT_URI
    android.provider.Calendar.CONTENT_URI

15
Intent and Content Provider
  • private void pickContact()     // Create
    an intent to "pick" a contact, as defined by the
    content provider URI    Intent intent new
    Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI)
        startActivityForResult(intent,
    PICK_CONTACT_REQUEST)_at_Overrideprotected
    void onActivityResult(int requestCode, int
    resultCode, Intent data)     // If the request
    went well (OK) and the request was
    PICK_CONTACT_REQUEST    if (resultCode
    Activity.RESULT_OK
    requestCode PICK_CONTACT_REQUEST)         //
    Perform a query to the contact's content provider
    for the contact's name        Cursor cursor
    getContentResolver().query(data.getData(),     
      new String
    Contacts.DISPLAY_NAME, null, null, null)     
      if (cursor.moveToFirst()) // True if the
    cursor is not empty            int columnIndex
    cursor.getColumnIndex(Contacts.DISPLAY_NAME)   
            String name cursor.getString(columnIndex
    )            // Do something with the selected
    contact's name...           

16
Andriod
17
Android Debug
  • Dalvik Debugging Monitoring Service (DDMS)
  • Eclipse Window -gt Open Perspective -gt Other -gt
    DDMS
  • Android tools
  • Android debug bridge (adb)
  • LogCat
  • Hierarchical viewr
  • TraceView

18
References
  • Online development guide
  • http//developer.android.com/guide/index.html
  • Book resources
  • The Android Developers Cookbook
  • Professional Android 2 Application Development,
    by Reto Meier, from Yale Internet Resource

19
Recap Wireless Link Layer
  • The basic services of the link layer
  • framing, link reliability, etc
  • link access interference, quality of service
    (and fairness) control
  • Guided by network layer
  • transmit to which neighbor at what quality

20
Network Layer Services
  • Transport packets from source to dest
  • Network layer protocol in host and router
  • Basic functions
  • Control plane
  • compute routing from sources to destinations
  • Data plane forwarding
  • move packets from input interface to appropriate
    output interface(s)

21
Network Layer API
  • API (provided to upper layer)
  • transmit( info, src, dest, )
  • A key decision in network layer design is how to
    represent destinations?
  • we refer to how applications specify destinations
    as the addressing scheme
  • the supported addressing scheme(s) can have
    profound impacts on usability, flexibility, and
    scalability

22
Discussion How to Specify a Destination?
23
Two Basic Approaches for Identifying Destinations
  • Locators
  • Encode locations on network topology
  • Identifiers (ID)
  • independent of network topology

24
Addressing Scheme Sensornet Example
  • Destination message to a sensor (e.g., who
    detected fire)
  • ltID Dgt //
    id.
  • ltLat37.3169 Long-121.8740gt // loc
  • lttemperature highestgt // prop.

25
Addressing Scheme Printer
  • How may we specify the destination as the color
    printer on the 2nd floor of AKW
  • Internet domain name lw2c.cs.yale.edu
  • Internet protocol (IP) address 128.36.231.8
  • building AKW floor2 entity printer
    quality color

26
Addressing Scheme Telephone
  • Very first scheme connection by operators to
    business
  • ID or locator?

27
Addressing Scheme Telephone
  • The telephone numbering scheme
  • invented in 1888 by Almon Strowger, an
    undertaker No longer will my competitor steal
    all my business just because his wife is a BELL
    operator.

28
Addressing Scheme Telephone
  • E.164 Maximum 15 digits
  • Hierarchical addressing scheme country code
    national destination (area) code (optional)
    subscriber number
  • e.g., 1-203-432-6400
  • Why hierarchical addressing scheme?
  • 203-432 uniquely determines the switch upon which
    the telephone is attached to

29
Summary
  • Evolution of telephone addressing scheme
  • Identifier (business type)
  • Identifier (person)
  • Locator (hierarchical phone )
  • Nowadays identifier (person again w/ mobile
    phones)

30
Internet Addressing Scheme
223.1.1.1
  • Also a hierarchical locator addressing scheme
  • IP address 32-bit identifier for an interface
  • An IP address is associated with an interface
    /sbin/ifconfig -a

223.1.2.9
223.1.1.4
223.1.1.3
223.1.3.2 11011111 00000001 00000011 00000010
223
1
2
3
31
IP Addressing
223.1.1.2
223.1.1.1
223.1.1.4
  • Hierarchical scheme
  • network part (high order bits)
  • host part (low order bits)
  • Whats a network? (from IP address perspective)
  • device interfaces with same network part of IP
    address
  • link layer can reach each other

223.1.1.3
223.1.7.0
223.1.9.2
223.1.9.1
223.1.7.1
223.1.8.1
223.1.8.0
223.1.2.6
223.1.3.27
223.1.2.1
223.1.2.2
223.1.3.2
223.1.3.1
32
Why Hierarchy?
223.1.1.2
223.1.1.1
223.1.1.4
  • The hierarchy is important for the scalability of
    Internet routing
  • The routing system handles only the number of
    networks
  • 350,679 networks on Mar. 2 2011
  • 818 mil hosts in Jan. 2011)

223.1.1.3
223.1.7.0
223.1.9.2
223.1.9.1
223.1.7.1
223.1.8.1
223.1.8.0
223.1.2.6
223.1.3.27
223.1.2.1
223.1.2.2
223.1.3.2
223.1.3.1
http//ftp.isc.org/www/survey/reports/current/
33
Routing in IP/Telephone Networks
  • Represent network as a graph
  • Determine a pathto each destination on the
    graph
  • Q what does a nodein the graph represent?

34
Key Problems
  • Location management
  • E.g., due to user mobility (roaming)
  • Dynamic routing
  • E.g., due to node mobility/wireless connectivity,
    link connectivity/quality can be highly dynamic
  • Interference management
About PowerShow.com