45
Inside the Android AccountManager

Inside the Android AccountManager

Embed Size (px)

Citation preview

Page 1: Inside the Android AccountManager

Inside the Android AccountManager

Page 2: Inside the Android AccountManager

Account Manager

Account Manager Service

Authenticator

Integrated App

Page 3: Inside the Android AccountManager

Account Manager

Account Manager Service

Authenticator

Integrated App

Zoe, Backup, …

Page 4: Inside the Android AccountManager

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

Page 5: Inside the Android AccountManager

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

system_server

Page 6: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

system_server

Page 7: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

Method Invocation

system_server

Page 8: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

Binder IPC

Method Invocation

system_server

Page 9: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

HTC Account

Zoe, Backup, …

Binder IPC

Binder IPC

Method Invocation

system_server

Page 10: Inside the Android AccountManager

http://www.nds.rub.de/media/attachments/files/2012/03/binder.pdf

BinderNative IPC mechanism on Android.

Implemented as kernel driver and the Binder framework.

Page 11: Inside the Android AccountManager

http://www.nds.rub.de/media/attachments/files/2012/03/binder.pdf

Binder

Binder client uses a proxy approach.

Native IPC mechanism on Android.

Implemented as kernel driver and the Binder framework.

Page 12: Inside the Android AccountManager

http://www.nds.rub.de/media/attachments/files/2012/03/binder.pdf

Binder

The transaction data is called Parcel. Java objects implementing Paracelable interface can be converted to Parcels. Transaction data limit is around 1MB.

Native IPC mechanism on Android.

Implemented as kernel driver and the Binder framework.

Page 13: Inside the Android AccountManager

http://www.nds.rub.de/media/attachments/files/2012/03/binder.pdf

Binder

Binder server spawns binder threads to handle the incoming requests automatically.

Native IPC mechanism on Android.

Implemented as kernel driver and the Binder framework.

Page 14: Inside the Android AccountManager

Android Interface Definition Language (AIDL)

• To make customized Binder interface.

• Default supported data types include primitives, String, CharSequence, List, Map.

• Non-primitive type parameters require in / out or inout tag.

• Custom data types must implement Parcelable, and declare a corresponding AIDL file.

http://developer.android.com/guide/components/aidl.html

Page 15: Inside the Android AccountManager

frameworks/base/core/java/android/accounts/IAccountManager.aidl

Page 16: Inside the Android AccountManager

frameworks/base/core/java/android/accounts/Account.aidl

Page 17: Inside the Android AccountManager
Page 18: Inside the Android AccountManager

predefined in Binder framework

generated from AIDL

Page 19: Inside the Android AccountManager

frameworks/base/core/java/android/app/ContextImpl.java

AccountManager (binder client side) initialization.

Page 20: Inside the Android AccountManager

frameworks/base/core/java/android/app/ContextImpl.java

AccountManager (binder client side) initialization.

Page 21: Inside the Android AccountManager

frameworks/base/core/java/android/accounts/AccountManager.java

AccountManager (binder client side) initialization.

Page 22: Inside the Android AccountManager

AccountManagerService (binder server side) initialization.

frameworks/base/core/java/android/accounts/AccountManagerService.java

Page 23: Inside the Android AccountManager

AccountManagerService (binder server side) initialization.

frameworks/base/core/java/android/accounts/AccountManagerService.java

Page 24: Inside the Android AccountManager

Simplified addAccount()

Page 25: Inside the Android AccountManager

Simplified addAccount()

Binder IPC

Page 26: Inside the Android AccountManager

Simplified addAccount()

Binder IPC Binder IPC

Page 27: Inside the Android AccountManager

AccountManagerFuture

Page 28: Inside the Android AccountManager
Page 29: Inside the Android AccountManager

main thread

Page 30: Inside the Android AccountManager

main thread

bkg thread

Page 31: Inside the Android AccountManager
Page 32: Inside the Android AccountManager

main thread

Page 33: Inside the Android AccountManager

main thread

bkg thread

Page 34: Inside the Android AccountManager

main thread

bkg thread

main thread

Page 35: Inside the Android AccountManager

Callback through IPC

frameworks/base/core/java/android/accounts/IAccountManagerResponse.aidl

Page 36: Inside the Android AccountManager

AccountManager.AmsTask.Response

Page 37: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

Asynchronized Binder IPC call through interface IAccountManager;

Response returned through interface IAccountManagerResponse

Page 38: Inside the Android AccountManager

frameworks/base/core/java/android/accounts/IAccountAuthenticator.aidl

Page 39: Inside the Android AccountManager

AccountManagerService.Session

AccountManagerService (binder client side) initialization.

Page 40: Inside the Android AccountManager

ServiceConnection

Page 41: Inside the Android AccountManager

ServiceConnection

always on main thread

Page 42: Inside the Android AccountManager

AbstractAccountAuthenticator (binder server side) initialization.

frameworks/base/core/java/android/accounts/AbstractAccountAuthenticator.java

Page 43: Inside the Android AccountManager

Callback through IPC

frameworks/base/core/java/android/accounts/IAccountAuthenticatorResponse.aidl

Page 44: Inside the Android AccountManager

AccountManagerService.Session

Page 45: Inside the Android AccountManager

Application Process

Account Manager

Account Manager Service

Authenticator

Integrated App

Asynchronized Binder IPC call through interface IAccountAuthenticator;

Response returned through interface IAccountAuthenticatorResponse