droidcon 2011: working with the android source, ronan schwarz, openintents
DESCRIPTION
Ronan Schwarz, OpenIntentsIn this talk, we will once again walk through the Android Application fundamentals- but this time from the Framework's point of View.- You will learn why there is, in fact, no app - only a bunch of Activities.- What a HistoryRecord is, what it is used for and it's implications for the lifecycle.- Why ContentProviders are a type of service.- How the Framework enforces Permissions across the system and what to make of it.- Why Intents are even way better for RPC calls then is seen at first sight.We will cover a lot of little tricks and some bigger parts of the Android framework andit's implementation, giving you new insights for everyday developmentTRANSCRIPT
![Page 2: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/2.jpg)
OpenIntentswww.OpenIntents.org
OpenIntents
● Founded in 2009● Open Source based Company● Two times winners of Google Android Developer Challenge● Over 15 Apps in the Market (Free + Paid )● Services:
● Reusable components ● Intents Registry● Developer Support● Consulting● App Development
● Mentoring organization in Summer of Code 2011
![Page 3: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/3.jpg)
![Page 4: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/4.jpg)
OpenIntentswww.OpenIntents.org Topics
● Activity Lifecycle
● Activity Manager
● Concepts
● Components
● Why there is no App
● Permissions
● Gingerbread
![Page 5: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/5.jpg)
![Page 6: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/6.jpg)
![Page 7: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/7.jpg)
OpenIntentswww.OpenIntents.org Who you're gonna call ?
![Page 8: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/8.jpg)
OpenIntentswww.OpenIntents.org Activities
ActivityManagerService
![Page 9: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/9.jpg)
OpenIntentswww.OpenIntents.org ActivityManagerService
● Project: frameworks/base.git
● Package: com.android.server.am
● Pure Java
● Started by SystemServer, running as system process
● Creates the System Context
● Keeps a reference of the Home Screen / Launcher App
![Page 10: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/10.jpg)
OpenIntentswww.OpenIntents.org What does ActivityManagerService do ?
● Start, stop, pause,... Activities
● Start, stop, pause,... Services
● Start, stop, pause,... ContentProviders
● Check Permission
● Broadcast Intents
● Start, stop, pause,... Animations
● Decide window focus
● Deliver Hardware Events
● Crash Activities
![Page 11: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/11.jpg)
OpenIntentswww.OpenIntents.org What does ActivityManagerService do ?
EVERYTHING
![Page 12: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/12.jpg)
OpenIntentswww.OpenIntents.org What does ActivityManagerService do ?
EVERYTHING
the window manager doesn't
![Page 13: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/13.jpg)
OpenIntentswww.OpenIntents.org What does ActivityManagerService do ?
EVERYTHING
the window manager doesn't
(ok, almost)
![Page 14: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/14.jpg)
OpenIntentswww.OpenIntents.org Starting an Activity
● startActivity is called (calls startActivity(Intent, -1)
● ActivityManagerNative.startActivity(..)
● Call gets dispatched via AIDL Binder to ActivityManagerService
● Call is queued in a Handler Message Queue
● startActivityXX is called
● startActivityLocked is called
![Page 15: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/15.jpg)
OpenIntentswww.OpenIntents.org Starting an Activity
● Class is resolved
● Permission check
● Inform Watchers
● Create HistoryRecord
● Check launch Flags
● Create Task or add to existing
● Grant Permissions
![Page 16: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/16.jpg)
OpenIntentswww.OpenIntents.org Starting an Activity
● Add to History Stack
● Prepare Animations
● Add to WindowManager (creates window)
● Pause currently running Activities
● Switch Visibility
● Calculate & update Configuration (may trigger reset)
● Resume (make call across Binder into Activity Thread)
● Set Focus
● Ensure visibility
![Page 17: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/17.jpg)
OpenIntentswww.OpenIntents.org Application ?
![Page 18: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/18.jpg)
OpenIntentswww.OpenIntents.org HistoryRecord
![Page 19: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/19.jpg)
OpenIntentswww.OpenIntents.org Application ?
![Page 20: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/20.jpg)
OpenIntentswww.OpenIntents.org Permissions
![Page 21: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/21.jpg)
OpenIntentswww.OpenIntents.org Permissions
![Page 22: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/22.jpg)
OpenIntentswww.OpenIntents.org Permissions
![Page 23: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/23.jpg)
![Page 24: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/24.jpg)
OpenIntentswww.OpenIntents.org Changes in Gingerbread
● HistoryRecord renamed to ActivityRecord
● Introduction of Heavyweight Process
● Only one at any given time
● Parts of lifecycle management moved to ActivityStack
● Hardware Event / Key input was re-written
● WindowManager now has an extra “secure” layer
● ...
● Beautified comments :)
![Page 25: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/25.jpg)
![Page 26: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/26.jpg)
![Page 27: Droidcon 2011: Working with the Android source, Ronan Schwarz, Openintents](https://reader036.vdocuments.net/reader036/viewer/2022081602/549825b7ac79590e2e8b5585/html5/thumbnails/27.jpg)