android accounts & sync

15
Przemek Jakubczyk Senior Android Developer www.applause.com

Upload: przemyslaw-jakubczyk

Post on 15-Aug-2015

20 views

Category:

Mobile


0 download

TRANSCRIPT

Page 1: Android accounts & sync

Przemek JakubczykSenior Android Developer

www.applause.com

Page 2: Android accounts & sync

Android Accounts & Sync

Page 3: Android accounts & sync

Why ?

● Storing credentials is problem for nearly every app

● Inventing another wheel?

● It’s simple, it’s easy

Page 4: Android accounts & sync

What do we have?

● File System

● Shared Preferences

● Database

● Account Manager

Page 5: Android accounts & sync

File System

● User credentials are stored in a simple file

● Requires boilerplate code for handling FS

● File format

Page 6: Android accounts & sync

Shared Preferences

● Easy API

● Fast

Page 7: Android accounts & sync

Database

● Big deal to store two values

● Usually the table has only one row

● Useful when DB queries requires a user

Page 8: Android accounts & sync

Account Manager

● Higher initial cost

● It’s recommended by Google

● Perfect place to share user credentials

● Authenticator provider

Sync service :)

Page 9: Android accounts & sync

What about security?

Sandbox System storage

File System

Shared Preferences

Database

Account Manager

Page 10: Android accounts & sync

Root meWarn user about possible security issues

Page 11: Android accounts & sync

EncryptionRequire encrypted File System

Page 12: Android accounts & sync

Let’s sync

● Most apps fetch data from servers

● Can’t block UI

● Triggered periodically

Page 13: Android accounts & sync

Sync Adapter

● Triggered by Android Service

ContentResolver.addPeriodicSync()

● Implicit and/or periodic run

ContentResolver.requestSync()

● If required can work as a separate process

<service android:process=":sync"/>

Page 14: Android accounts & sync

Authentication

● Perfect solution for application which share credentials:

- Enterprise

- Products of the same company

● Android proxies queries for authorization (package name)

● Sharing same certificates along apps allow access to credentials “Just Like

That”

Page 15: Android accounts & sync

Stop talkingKeep coding!

https://github.com/pjakubczyk/AndroidSyncAndAccounts