Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps...

52
www.kandroid.org 운영자 : 양정수 (yangjeongsoo at gmail.com), 닉네임:들풀 The passion is not speed, but Direction ! 2010.10.15. Google GMS(Google Mobile Services) 분석 [1] 6 th Kandroid Conference “Android, Basic & Cloud”

Transcript of Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps...

Page 1: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

www.kandroid.org 운영자 : 양정수 (yangjeongsoo at gmail.com), 닉네임:들풀

The passion is not speed, but Direction !

2010.10.15.

Google GMS(Google Mobile Services) 분석 [1]

6th Kandroid Conference “Android, Basic & Cloud”

Page 2: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

26th Kandroid Conference - www.kandroid.org

Why GMS ?

Page 3: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

1. GMS(Google Mobile Services) Overview

- Features of User, Developer and Platform

- Analysis Tool and Environment

2. GSF(Google Service Framework) Internal

3. GMS Case Study

4. Android and GMS

The passion is not speed, but Direction !

6th Kandroid Conference “Android, Basic & Cloud”

Page 4: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

46th Kandroid Conference - www.kandroid.org

Source : www.google.com/googlephone/AndroidUsersGuide.pdf

GMS Overview : User Features

Page 5: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

56th Kandroid Conference - www.kandroid.org

GMS Overview : User Features

Page 6: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

66th Kandroid Conference - www.kandroid.org

Android 1.1 Android 1.5 (Cupcake)

Android 1.6(Donut)

Android 2.1(Eclair)

Android 2.2(Froyo)

GMS Overview : App. Developer Features

Page 7: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

76th Kandroid Conference - www.kandroid.org

GenieWidget.apkGmail.apkGoogleBackupTransport.apkGoogleCalendarSyncAdapter.apkGoogleContactsSyncAdapter.apkGoogleFeedback.apkGooglePartnerSetup.apkGoogleQuickSearchBox.apkGoogleServicesFramework.apkLatinImeTutorial.apkMaps.apkMarketUpdater.apkMediaUploader.apkNetworkLocation.apkSetupWizard.apkStreet.apkTalk.apkVending.apkVoiceSearch.apkYouTube.apk

com.google.android.maps.jar

libspeech.so

GMS Overview : Platform Developer Features

Page 8: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

86th Kandroid Conference - www.kandroid.org

GMS Application Application DescriptionGenieWidget News and Weather widget

Gmail Gmail client application

GoogleBackupTransport Allows backup of user's personal data to Googler servers with Google account.

GoogleCalendarSyncAdapter Provides sync adapter for Google calendar sync

GoogleContactsSyncAdapter Provides sync adapter for Google contacts sync

GoogleFeedback Collects data for developers whenever a running Market application freezes or crashes

GooglePartnerSetup A set of shared components used by Google applications to configure partner-specific parameters

GoogleQuickSearchBox Google search provider for enhanced Google search results

GoogleServicesFramework Google checkin service which retrieves application configuration parameters

LatinImeTutorial Tutorial for IME

Maps Google Maps application, including Latitude and Navigation

MarketUpdater Updater for Android Market application

MediaUploader YouTube and Picasa media upload service

NetworkLocation The Google Location Service network-based location provider

SetupWizard The Google Account setup wizard.

Street The Street view apk that is part of the Maps application

Talk The Google Talk application

Vending The Android Market application

VoiceSearch Voice Search and VoiceIME

YouTube The YouTube application

GMS Overview : Platform Developer Features

Page 9: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

96th Kandroid Conference - www.kandroid.org

Eclipse(ADT Plug-in)

Javacompiler

dx / aaptconverter

Result :Unsigned APK

Java(classes)

Resources

Dalvik(.dex)

Manifest

Ref. Libs

XML Res. Compilation

+Other Res.

Pre-process

UnsignedAndroid

Application(.apk)

Zip Compressed

File

Key(Debug Key

Custom Key)

Android Application Build Process

GMS Overview : Analysis Tool & Env. – Basic Knowledge

jarsigner(keytool)

adb(pm)install

amstart

zipalign

Page 10: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

106th Kandroid Conference - www.kandroid.org

Java(classes)

Resources

Dalvik(.dex)

Manifest

Ref. Libs

XML Res. Compilation

+Other Res.

Pre-process

UnsignedAndroid

Application(.apk)

Zip Compressed

File

Key(Debug Key

Custom Key)

jarsigner(keytool)

adb(pm)install

amstart

zipalign

http://code.google.com/p/android-apktool/

http://code.google.com/p/dex2jar/

http://java.decompiler.free.fr/

Dex2Jar

ApkTool

JAD

GMS Overview : Analysis Tool & Env. – Reverse & Sniffing

Packet sniffing• tcpdump• wireshark• ethereal• MITM

Device Hack• rooting• unyaffs

Page 11: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

116th Kandroid Conference - www.kandroid.org

Source : http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html

Proguard, Android, and the Licensing Server

GMS Overview : Tip – Protect Your Code

SDK Tools, Revision 7 (September 2010)

General notes: …

Adds support for extension targets in Ant build to perform tasks between the normal tasks: -pre-build, -pre-compile, and -post-compile.

Page 12: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

126th Kandroid Conference - www.kandroid.org

Python

GMS Overview : Analysis Tool & Env

Page 13: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

1. GMS(Google Mobile Services) Overview

2. GSF(Google Service Framework) Internal

- Auth (Authentication and Authorization)

- Protocol : GData, Protocol Buffer, XMPP

- GTalk Connection

3. GMS Case Study

4. Android and GMS

The passion is not speed, but Direction !

6th Kandroid Conference “Android, Basic & Cloud”

Page 14: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

146th Kandroid Conference - www.kandroid.org

GSF Internal : Overview

AndroidManifest.xml

Page 15: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

156th Kandroid Conference - www.kandroid.org

OAuth OAuth provides authorization for all Google APIs. This allows your application to request access to data associated with a user's Google Account.2-Legged OAuth : Access data for an entire Google Apps domain3-Legged OAuth : Access data for individual users

OpenID/OAuthHybrid protocol

Hybrid protocol provides authentication and authorization for web applications, allowing users to log in and authorize access to their data in a single step. This protocol uses OpenID to provide authentication services, and OAuth to provide authorization to Google APIs.

OpenID OpenID authenticates a user with their Google Account. This allows users to log in to your web site without having to sign up for a new account.

AuthSub AuthSub and ClientLogin are Google's proprietary authorization APIs, available as an alternative to OAuth for most Google APIs. If possible, you should migrate applications using these auth mechanisms to one of the recommended options above.

ClientLogin

Authentication and Authorization for Google APIs allow third-party applications to get limited access to a user's Google accounts for certain types of activities. This document explains the available auth mechanisms and what each one provides for your application.

GSF Internal : Auth (Authentication & Authorization)

Page 16: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

166th Kandroid Conference - www.kandroid.org

The ClientLoginauthorization process for Installed Applications

http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html

GSF Internal : Auth (Authentication & Authorization)

The AuthSubauthorization process for Web Applications

http://code.google.com/intl/ko-KR/apis/accounts/docs/AuthSub.html

Page 17: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

176th Kandroid Conference - www.kandroid.org

The OAuthauthorization process for Web Applications

http://xaop.com/blog/2010/03/05/authentication-with-oauth-in-ruby-on-rails/

GSF Internal : Auth (Authentication & Authorization)

Page 18: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

186th Kandroid Conference - www.kandroid.org

http://code.google.com/intl/ko-KR/apis/accounts/docs/OpenID.html

The OpenID authentication process for Federated Login for Google Account Users

GSF Internal : Auth (Authentication & Authorization)

Page 19: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

196th Kandroid Conference - www.kandroid.org

Google API Service nameGoogle Analytics Data APIs analyticsGoogle Apps APIs(Domain Information & Management) apps

Google Base Data API gbaseGoogle Sites Data API jotspotBlogger Data API bloggerBook Search Data API printCalendar Data API clGoogle Code Search Data API codesearchContacts Data API cpDocuments List Data API writelyFinance Data API financeGmail Atom feed mail

Health Data API healthweaver (H9 sandbox)

Maps Data APIs localPicasa Web Albums Data API lh2Sidewiki Data API annotatewebSpreadsheets Data API wiseWebmaster Tools API sitemapsYouTube Data API Youtube

Google App Engine ah

GSF Internal : Auth (Authentication & Authorization)

Source : http://code.google.com/apis/gdata/faq.html#clientlogin

Page 20: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

206th Kandroid Conference - www.kandroid.org

Source : http://code.google.com/intl/en/apis/gdata/

What is the Google Data Protocol?

The Google Data Protocol is a REST-inspired technology for reading, writing, and modifying information on the web.Many services at Google provide external access to data and functionality through APIs that utilize the Google Data Protocol. The protocol currently supports two primary modes of access:

AtomPub:

Information is sent as a collection of Atom items, using the standard Atom syndication format to represent data and HTTP to handle communication. The Google Data Protocol extends AtomPub for processing queries, authentication, and batch requests.

JSON:

Information is sent as JSON objects that mirror the Atom representation.

GSF Internal : GData(Google Data API Protocol)

Page 21: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

216th Kandroid Conference - www.kandroid.org

The Google data APIs protocol providesa simple standard protocol for readingand writing data on the web.The Google Data APIs protocol is astandards-based protocol that usesAtom and RSS as XML-based formatsfor feeds and data interchange

Atom 1.0• Allows for extensions• Allows different type attribute values• (html/text/media/etc) for elements• Is associated with a schema (can be validated)• Allows for elements to be used• elsewhere• Uses xml:lang for localization

Atom Publishing Protocol (AtomPub) –• Defines PUT/POST/DELETE operations

RSS 2.0• Commonly accepted syndication format

GDataProtocol

Atom/AtomPub

RSS

SyndicationFormat O O O

Updates O O

Authentication O

Queries O

OptimisticConcurrency O

GSF Internal : GData(Google Data API Protocol)

Source : Google APIs, Pamela Fox

Page 22: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

226th Kandroid Conference - www.kandroid.org

Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.

.proto File proto toolCode- C- C++- Java- Python

Code- C- C++- Java- Python

Code- C- C++- Java- Python

Client --tcp=HOST:PORT Port to listen on for RPC clients.--unix=PATH Unix-domain socket to listen on. Server

GSF Internal : Protocol Buffer

Page 23: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

236th Kandroid Conference - www.kandroid.org

articleList = articlelist_pb2.ArticleList()

cursor = conn.cursor ()cursor.execute(query)count = 0while (1):

row = cursor.fetchone ()if row == None:

breakarticle = articleList.article.add()article.boardname = row[1]article.articleid = int(row[2])article.subject = unicode( row[4], "euc-kr" )count = count + 1

cursor.close ()conn.close ()

outString = base64.encodestring(articleList.SerializeToString())self.req.write(outString)

message Article {required string boardname = 1;required int32 articleid = 2;required string subject = 3;

}

message ArticleList {repeated Article article = 1;

}xxx.proto

python

GSF Internal : Protocol Buffer

Page 24: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

246th Kandroid Conference - www.kandroid.org

GSF Internal : Protocol Buffer

Page 25: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

256th Kandroid Conference - www.kandroid.org

Item Description

Resource from=“userid@domain/resource”ex ) [email protected]/androidxxxxxxxx

Stanza A stanza is an atomic command in XMPPex) <message/>, <presence/>, and <iq/>.

Presence presence is a method by which a client/user notifies buddies and the XMPP server of its current Status

Message Message is an XML stanza used to send messages between users.

IQ IQ (Info/Query) is an XML stanza that is similar to GET and POST requests in the HTTP protocol

Roster A roster in XMPP is basically a buddy list, which contains a presence attribute for each user item. Your roster contains a list of Jabber user IDs (called JIDs) and the state of your presence subscriptions with those entities.

XMPP (Extensible Messaging and Presence Protocol)

GSF Internal : XMPP

Page 26: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

266th Kandroid Conference - www.kandroid.org

GSF Internal : GTalk Connection

#!/usr/bin/env python

import xmppimport subprocess

login = 'userid' # @gmail.compwd = 'passwd'

def message_handler(connect_object, message_node):message = "Hello World form Python :)"connect_object.send( xmpp.Message( message_node.getFrom() ,message))

cnx = xmpp.Client('gmail.com')

cnx.connect( server=('talk.google.com',5223) )# cnx.connect( server=('mtalk.google.com',5228) )

cnx.auth(login,pwd, 'kandroid')cnx.RegisterHandler('message', message_handler)

cnx.sendInitPresence()

while cnx.Process(1):pass

# http://xmpppy.sourceforge.net/

Google Lab“Green Robot”

Page 27: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

276th Kandroid Conference - www.kandroid.org

GSF Internal : GTalk Connection

mtalk.google.com

Page 28: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

1. GMS(Google Mobile Services) Overview

2. GSF(Google Service Framework) Internal

3. GMS Case Study

- Vending (Android Market Client)

- C2DM (Cloud to Device Messaging Framework)

4. Android and GMS

The passion is not speed, but Direction !

6th Kandroid Conference “Android, Basic & Cloud”

Page 29: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

296th Kandroid Conference - www.kandroid.org

www.android.com/market

기본 정보 :

- 등록비 : 25$- 수익배분 : 30 vs. 70 (개발자)- 제약사항 : Signing 관련 일부 제약.- Payment : Google Checkout

(일부 direct carrier billing 지원)- Application Update Notification- Bug Report- Merchant Account : Google Checkout- Browser to Device Installation

GMS Case Study : Vending (200,400,403,503)

Page 30: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

306th Kandroid Conference - www.kandroid.org

http://www.kandroid.org/app/index.php

Source Code :

http://www.kandroid.org/board/board.php?board=androidmarket&command=body&no=31

1. Market Protocol Buffer2. Gen Python Code

protoc --python_out=. market.proto3. Write Custom Code

Caution :

1. Account Blocking 2. IP Blocking

GMS Case Study : Vending (200,400,403,503)

Page 31: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

316th Kandroid Conference - www.kandroid.org

A n d r o i dF RAMEWORK

DownloadProvider

DownloadProvider

Browser / Gmail Market / UpdaterBrowser / Gmail Market / Updater

ViewerApp.

ViewerApp.

www.android.com/market www.google.comwww.google.com

android.client.google.comandroid.client.google.com

POST /accounts/ClientLogin HTTP/1.1\r\nContent-type: application/x-www-form-urlencoded\r\nContent-Length: length\r\n\r\nEmail=email&Passwd=pw&service=android&accountType=HOSTED_OR_GOOGLE

SID=SID_Token\r\nLSID=LSID_Token\r\nAuth=Auth_Token

1

2

3

GMS Case Study : Vending (200,400,403,503)

Page 32: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

326th Kandroid Conference - www.kandroid.org

Android-MarketAndroid-Market www.google.comwww.google.com android.client.google.comandroid.client.google.com

POST /accounts/ClientLogin HTTP/1.1\r\nContent-type: application/x-www-form-urlencoded\r\nContent-Length: length\r\n\r\nEmail=email&Passwd=pw&service=android&accountType=HOSTED_OR_GOOGLE

SID=SID_Token\r\nLSID=LSID_Token\r\nAuth=Auth_Token

POST /market/api/ApiRequest HTTP/1.1\r\nCookie: ANDROID=Auth-Token\r\nUser-Agent: Android-Market/2 (sapphire PLAT-RC33); gzip\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nHost: android.clients.google.com\r\nAccept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\nConnection: keep-alive\r\nContent-Length: length\r\n\r\nversion= PROTOCOL_VERSION &) request=request_data(base64

response_data

Download ProviderDownload Provider

http://android.clients.google.com/market/download/Download?assetId=assetId&userId=userId&deviceId=deviceIdANDROID=Auth-Token

ParcelFileDescriptor

SSO

Google ProtobufGoogle Protobuf

GMS Case Study : Vending (200,400,403,503)

Page 33: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

336th Kandroid Conference - www.kandroid.org

ApplicationApplication Viewer App.Viewer App.Download ProviderDownload Provider

Initiate download

content provider URI

query download

Cursor

register ContentObserver

ContentObserver notification

intent “notification clicked”

intent “download completed”

update download

open downloaded file

ParcelFileDescriptor

delete download

intent “view”

<permission android:name="string“ android:protectionLevel=“signatureOrSystem”… />

GMS Case Study : Vending (200,400,403,503)

Page 34: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

346th Kandroid Conference - www.kandroid.org

DownloadProvider Constants : /frameworks/base/core/java/android/provider/Downloads.javaDownloadProvider Package : com.android.providers.downloadsDb : downloads.dbTable : downloads

Constant name Column name SQL Type Constant name Column name SQL Type

_ID _id INTEGER LAST_MODIFICATION lastmod BIGINT

URI uri TEXT NOTIFICATION_PACKAGE notificationpackage TEXT

method INTEGER NOTIFICATION_CLASS notificationclass TEXT

APP_DATA entity TEXT NOTIFICATION_EXTRAS notificationextras TEXT

NO_INTEGRITY no_integrity BOOLEAN COOKIE_DATA cookiedata TEXT

FILENAME_HINT hint TEXT USER_AGENT useragent TEXT

otaupdate BOOLEAN REFERER referer TEXT

_DATA _data TEXT TOTAL_BYTES total_bytes INTEGER

MIMETYPE mimetype TEXT CURRENT_BYTES current_bytes INTEGER

DESTINATION destination INTEGER etag TEXT

no_system BOOLEAN uid INTEGER

VISIBILITY visibility INTEGER OTHER_UID otheruid INTEGER

CONTROL control INTEGER TITLE title TEXT

STATUS status INTEGER DESCRIPTION description TEXT

numfailed INTEGER scanned BOOLEAN

GMS Case Study : Vending (200,400,403,503)

Page 35: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

356th Kandroid Conference - www.kandroid.org

200, 400, 403, 503

GMS Case Study : Vending (200,400,403,503)

Page 36: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

366th Kandroid Conference - www.kandroid.org

• It allows third-party application servers to send lightweight messages to their Android applications. The messaging service is not designed for sending a lot of user content via the messages. Rather, it should be used to tell the application that there is new data on the server, so that the application can fetch it.

• C2DM makes no guarantees about delivery or the order of messages. So, for example, while you might use this feature to tell an instant messaging application that the user has new messages, you probably would not use it to pass the actual messages.

• An application on an Android device doesn’t need to be running to receive messages. The system will wake up the application via Intent broadcast when the the message arrives, as long as the application is set up with the proper broadcast receiver and permissions.

• It does not provide any built-in user interface or other handling for message data. C2DM simply passes raw message data received straight to the application, which has full control of how to handle it. For example, the application might post a notification, display a custom user interface, or silently sync data.

• It requires devices running Android 2.2 or higher that also have the Market application installed. However, you are not limited to deploying your applications through Market.

• It uses an existing connection for Google services. This requires users to set up their Google account on their mobile devices.

GMS Case Study : C2DM

Page 37: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

376th Kandroid Conference - www.kandroid.org

http://www.kandroid.org/board/board.php?board=AndroidBeginner&command=body&no=101

Components : The physical entities that play a role in C2DM

The device that is running an Android application that uses C2DM. This must be a 2.2 Android device that has Market installed, and it must have at least one logged in Google account.

An application server that developers set up as part of implementing C2DM in their

applications. The third-party application server sends data to an Android application

on the device via the C2DM server.

The Google servers involved in taking messages from the third-party application server and sending them to the device.

GMS Case Study : C2DM

Page 38: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

386th Kandroid Conference - www.kandroid.org

Credentials - The IDs and tokens that are used in different stages of C2DM to ensure that all parties have been authenticated, and that the message is going to the correct place.

Credentials

Sender ID

An email account associated with the application's developer. The sender ID is used in the registration process to identify a Android application that is permitted to send messages to the device. This ID is typically role-based rather than being a personal account—- for example, [email protected].

Application ID

The application that is registering to receive messages. The application is identified by the package name from the manifest. This ensures that the messages are targeted to the correct application.

Registration ID

An ID issued by the C2DM servers to the Android application that allows it to receive messages. Once the application has the registration ID, it sends it to the third-party application server, which uses it to identify each device that has registered to receive messages for a given application. In other words, a registration ID is tied to a particular application running on a particular device.

Google User Account

For C2DM to work, the mobile device must include at least one logged in Google account.

Sender AuthToken

A ClientLogin Auth token that is saved on the third-party application server that gives the application server authorized access to Google services. The token is included in the header of POST requests that send messages. For more discussion of ClientLogin Auth tokens, see ClientLogin for Installed Applications.

GMS Case Study : C2DM

Page 39: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

396th Kandroid Conference - www.kandroid.org

1. senderID생성 : gmail id (ex, [email protected])

2. C2DM Singup : http://code.google.com/android/c2dm/signup.html

ex) App package Name : org.kandroid.xxxxAccount ID : [email protected]

3. Register Application to C2DM Server and then Receive Registration ID from C2DM Server

com.google.android.c2dm.intent.REGISTERcom.google.android.c2dm.intent.REGISTRATION

4. Send Registration ID to Your (3rd Party) Application Server

5. Send Message to C2DM Server

Get AuthToken : Email/Passwd/accountType/service // service; ac2dmSend Message : Auth Token/registation ID/Message // Message; data.<key>=<value>

6. Receive Message from C2DM Server

com.google.android.c2dm.intent.RECEIVEcom.google.android.c2dm.intent.RETRY

GMS Case Study : C2DM

Page 40: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

406th Kandroid Conference - www.kandroid.org

APP

C2DMSignup

Create NewGmail Account

Gmail

C2DM Signup

Register Your App. to C2DM Server

ReceiveRegistration ID

SendRegistration ID

Request Auth Tokenfor C2DM (ac2dm)

Receive Auth Token

Sendmessage

1 2

0

PublishYour Application

3

4

5

6

7

8

9

GMS Case Study : C2DM

Page 41: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

416th Kandroid Conference - www.kandroid.org

GMS Case Study : C2DM

Chrome to Phone

Page 42: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

1. GMS(Google Mobile Services) Overview

2. GSF(Google Service Framework) Internal

3. GMS Case Study

4. Android and GMS

- Device Registration

- Account and SyncAdapter

- Keeping GTalk Connection

The passion is not speed, but Direction !

6th Kandroid Conference “Android, Basic & Cloud”

Page 43: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

436th Kandroid Conference - www.kandroid.org

message RequestProperty {required string authToken = 1; // AuthTokenrequired int32 authTokenSecure = 2; // Secure Optionrequired int32 softwareVersion = 3; // ex) 1820required string androidId = 4; // ex) 3b6d9e8dc2394bb5 optional string productNameAndVersion = 5; // ex) generic:8 or passion:8optional string userLanguage = 6; // ex) ko or enoptional string userCountry = 7; // ex) KR or USoptional string operatorName = 8; // ex) KOR SK Telecom optional string simOperatorName = 9; // ex) SKTelecomoptional string operatorNumericName = 10; // ex) 45005 optional string simOperatorNumericName = 11; // ex) 45005 optional string clientId = 12; // ex) am-xxxxoptional string loggingId = 13; }

Android & GMS : Device Registration (Vending Req. Prop)

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

Uri gsfUri = Uri.parse("content://com.google.android.gsf.gservices");String[] selectionArgs = new String[1];selectionArgs[0] = "android_id";Cursor c = getContentResolver().query(gsfUri, null, null, selectionArgs, null);try {

if (c.moveToFirst()) { androidId = Long.toHexString(Long.parseLong(c.getString(1))); }} finally { if (c != null) c.close(); }

Page 44: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

446th Kandroid Conference - www.kandroid.org

Source : http://developer.android.com/guide/appendix/market-filters.html

Android & GMS : Device Registration (Market Filter)

Filtering Element Description

<supports-screens> Screen Size

<uses-configuration> Device Configuration: keyboard, navigation, touch screen

<uses-feature> Device Features, OpenGL-ES Version

<uses-library> Software Libraries (ex, com.google.android.maps library)

<uses-permission>

<uses-sdk> Minimum Framework Version / Maximum Framework Version

Publishing Status Only published applications will appear in searches and browsing within Android Market.

Priced StatusTo show paid apps, a device must have a SIM card and be running Android 1.1 or later, and it must be in a country (as determined by SIM carrier) in which paid apps are available.

Country / Carrier Targeting

When you upload your app to the Android Market, you can select specific countries to target.

Native Platform An application that includes native libraries that target a specific platform

Forward-Locked Applications

Market will not show copy-protected applications on developer devices or unreleased devices.

Page 45: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

456th Kandroid Conference - www.kandroid.org

Android & GMS : Account & SyncAdapter

1

2

Page 46: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

466th Kandroid Conference - www.kandroid.org

@Overridepublic Uri insert(Uri url, ContentValues initialValues) {

rowID=db.insert(getTableName(), getNullColumnHack(), values);if (rowID > 0) {

Uri uri=ContentUris.withAppendedId(getContentUri(), rowID);getContext().getContentResolver().notifyChange(uri, null);return uri;

}}

public void notifyChange(Uri uri, ContentObserver observer) {notifyChange(uri, observer, true /* sync to network */);

}

public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {try {

getContentService().notifyChange(uri, observer == null ? null : observer.getContentObserver(),observer != null && observer.deliverSelfNotifications(), syncToNetwork);

} catch (RemoteException e) {}

}

Ex) Provider Sample

ContentResolver.java

Android & GMS : Account & SyncAdapter (ContentObserver)

1

Page 47: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

476th Kandroid Conference - www.kandroid.org

/** @hide */public static final String CONTENT_SERVICE_NAME = "content";

/** @hide */public static IContentService getContentService() {

if (sContentService != null) {return sContentService;

}

IBinder b = ServiceManager.getService(CONTENT_SERVICE_NAME);

if (Config.LOGV) Log.v("ContentService", "default service binder = " + b);

sContentService = IContentService.Stub.asInterface(b);

if (Config.LOGV) Log.v("ContentService", "default service = " + sContentService);

return sContentService;}

ContentResolver.java

Android & GMS : Account & SyncAdapter (ContentObserver)

1

Page 48: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

486th Kandroid Conference - www.kandroid.org

Android & GMS : Account & SyncAdapter

Settings > Accounts & sync setting2

Page 49: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

496th Kandroid Conference - www.kandroid.org

2

Android & GMS : Account & SyncAdapter

<service android:name=".authenticator.AuthenticationService" android:exported="true"><intent-filter>

<action android:name="android.accounts.AccountAuthenticator" /></intent-filter><meta-data android:name="android.accounts.AccountAuthenticator"

android:resource="@xml/authenticator" /></service>

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"android:accountType="com.example.android.samplesync"

/>

<service android:name=".syncadapter.SyncService" android:exported="true"><intent-filter>

<action android:name="android.content.SyncAdapter" /></intent-filter><meta-data android:name="android.content.SyncAdapter"

android:resource="@xml/syncadapter" /></service>

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"android:contentAuthority="com.android.contacts"android:accountType="com.example.android.samplesync"

/>

ContactsProvider

Page 50: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

506th Kandroid Conference - www.kandroid.org

Android & GMS : Keeping GTalk Connection

Page 51: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

516th Kandroid Conference - www.kandroid.org

Android & GMS : Keeping GTalk Connection

Heartbeat

Heartbeat------------Heartbeat interval: 28:00 or 15:00heartbeat type: cell or wifi (ACTIVIT/IDLE/SYNC/NOSYNC)Current timer: 28:00Next heartbeat alarm will trigger in 10:23

Last data msg received at 23:00:22 (3:33:47 ago)

Page 52: Google GMS(Google Mobile Services) 분석[1]...LatinImeTutorial Tutorial for IME Maps Google Maps application, including Latitude and Navigation MarketUpdater Updater for Android Market

6th Kandroid Conference “Android, Basic & Cloud”

Q & A

The passion is not speed, but Direction !