ronan schwarz; context is magic

14
Context is Magic (short version) http://generalzoi.deviantart.com/art/Pony-Creator-Full-Version-254295904

Upload: droidcon-berlin

Post on 27-Jan-2015

105 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Ronan Schwarz; Context is Magic

Context is Magic(short version)

http://generalzoi.deviantart.com/art/Pony-Creator-Full-Version-254295904

Page 2: Ronan Schwarz; Context is Magic

What it is

_Definition of Context (Merriam-Webster)

_1: the parts of a discourse that surround a word or

passage and can throw light on its meaning

_2: the interrelated conditions in which something

exists or occurs

http://www.merriam-webster.com/dictionary/context

Page 3: Ronan Schwarz; Context is Magic

http://www.merriam-webster.com/dictionary/context

Page 4: Ronan Schwarz; Context is Magic

Defect Unicorns

http://www.merriam-webster.com/dictionary/context

Page 5: Ronan Schwarz; Context is Magic

What it does

_ holds references to:

– ActivityThread

– ContentResolver

– PackageManager

_ caches Theme and Resources

_ has a HashMap of SharedPreferences

_ can comunicate with the ActivityManager

_ keeps track of Permissions

Page 6: Ronan Schwarz; Context is Magic

There is no App

Page 7: Ronan Schwarz; Context is Magic

Context + Code

Page 8: Ronan Schwarz; Context is Magic

Explore

_ two types of objects:

derived from context or using context

_ most classes derive ContextWrapper

– just a delegate (service, application,..)

_ 'nearer' to the front: ContextThemeWrapper

– delegate with theme (activity,..)

_ getBaseContext() returns the parent

Page 9: Ronan Schwarz; Context is Magic

The Tree

Page 10: Ronan Schwarz; Context is Magic

Exchange

_ using the wrong context can result in leaks

– context leaks are nasty to debug

– using Activity as context is mostly wrong

_ use application context for non-UI

_ construct a themed context for UI if needed

_ understand where context changes take place

Page 11: Ronan Schwarz; Context is Magic

Exploit

_ contexts are bound to APKs

_ intents can imply context changes

– gain additional permissions

– content might not be available

_ context lifecycle is slow

– uses lazy-initialization

– make sure lifecycle matches

_

Page 12: Ronan Schwarz; Context is Magic

TL;DL

_ context matters

_ choose carefully

_ don't leak it

_ don't get surprised, be surprising

Page 13: Ronan Schwarz; Context is Magic

Kontakt

Ihr Ansprechpartner:Ronan 'zero' Schwarz+49 173 240 28 [email protected]

Page 14: Ronan Schwarz; Context is Magic

TL;DR

_