Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Ronan Schwarz; Context is Magic
1. Context is Magic
(short version)
http://generalzoi.deviantart.com/art/Pony-Creator-Full-Version-254295904
2. 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
5. 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
8. 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
10. 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
11. 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
_
12. TL;DL
_ context matters
_ choose carefully
_ don't leak it
_ don't get surprised, be surprising