Your SlideShare is downloading. ×
MobiCom on Android: Process Management; Processes & Applications; Process Importance Hierarchy; Sharing Data Among Apps in the Same Process
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MobiCom on Android: Process Management; Processes & Applications; Process Importance Hierarchy; Sharing Data Among Apps in the Same Process

1,466

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,466
On Slideshare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MobiCom on Android Processes & Applications, Process Management, Process Importance Hierarchy, Sharing Data among Apps in the Same Process Vladimir Kulyukinhttp://www.youtube.com/vkedco www.vkedco.blogspot.com
  • 2. Outline ● Processes – Process Management – Process Importance Hiearchy – Process Sharing ● Sharing Data among Apps in the Same Process via Class Loader Bootstrappinghttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 3. Processeshttp://www.youtube.com/vkedco www.vkedco.blogspot.com
  • 4. Linux Process Launch ● Android OS starts a new process with a single thread of execution when an apps component must run and no other components of that app are running ● The default behavior is to run all components of a given app in the same process and thread (the main thread) ● If an app component must start and there is a process for that app, i.e., another component of this app exists), the starting component is placed into the existing process and the same thread of executionhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 5. Processes & Apps ● Most apps run in the same process and do not need to change this default ● Developers can mount different components on different processes through explicit declarations in the manifest files ● Each of the four component element types (<activity>, <service>, <receiver>, <provider>) supports the android:process attribute ● The <application> element also supports the android:process attributehttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 6. Attribute android:process ● android:processs value is a string ● The default value is the package name set in the <manifest> element ● If the value starts with “:”, then a new process, private to the current app, is created ● If the value starts with a lowercase character, a global process of that name is created ● Global processes can be shared by other applications if they share the same user ID and are signed by the same certificatehttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 7. Attribute android:sharedUserID ● android:sharedUserID is an attribute the <manifest> element ● <manifest android:sharedUserID=”string” >...</manifest> ● The string value, if it is the same for several apps, allows multiple apps with this ID to access each others data and, if necessary or desired, run in the same processhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 8. Process Management ● Android OS terminates a process when there is insufficient memory for other processes ● All apps components running in the process that is being terminated by the OS are destroyed ● A new process will be started for those components when those components must run again ● Android OS decides which processes to terminate based on their relative importance to the user, e.g., all components in a process are not visible)http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 9. Process Importance Hierarchy ● Android OS places each process into an importance hierarchy based on the components and their states in that process ● Processes with the lowest importance are terminated first, then processes with the next lowest importance, and so on as required by the system resource recovery ● There are five levels in the importance hierarchy from most important to least important: 1) Foreground, 2) Visible, 3) Service, 4) Background, & 5) Emptyhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 10. Foreground Processes ● A Process is foreground if 1) Hosts an activity with which the user currently interacts 2) Hosts a service bound to the activity with which the user interacts 3) Hosts a foreground service (service called startForeground()) 4) Hosts a service in the process of executing a lifecycle callbacks (oneCreate(), onStart(), onDestroy()) 5) Hosts a BroadcastReceiver executing its onReceive() methodhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 11. Visible Processes ● A Process is visible if 1) Hosts an activity that is not in the foreground but is visible to the user (the activitys onPause() method has been called); for example, the activity starts a dialog box that partially obscures its screen 2) Hosts a service bound to a visible or foreground activityhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 12. Service Processes ● A service process is a process that runs a service started with startService() ● Service processes are typically doing some background work that are important to the user, e.g., play music, download date but they are not directly relevant to what the user currently sees on the screenhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 13. Background Processes ● A background process holds an activity not visible to the user (the activitys onStop() method has been called) ● Background processes have no immediate impact on user experience ● The OS can terminate background process at any time to reclaim resources for foreground, visible, and service processes ● Background processes are kept in the Least Recently Used (LRU) list ● LRU ensures that the process with the activity most recently used is the last to terminatehttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 14. Empty Processes ● A empty process does not hold any active app components ● The OS may keep empty processes for caching to increase efficiency ● Process caching is done to improve process launch timeshttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 15. Process Importance Hierarchy ● Android OS places each process into an importance hierarchy based on the components and their states in that process ● Processes with the lowest importance are terminated first, then processes with the next lowest importance, and so on as required by the system resource recovery ● There are five levels in the importance hierarchy from most important to least important: 1) Foreground, 2) Visible, 3) Service, 4) Background, & 5) Emptyhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 16. Process Sharinghttp://www.youtube.com/vkedco www.vkedco.blogspot.com
  • 17. ClassLoader ● ClassLoaders are used by the VM for loading classes dynamically ● The ClassLoader class uses a delegation model to look for classes and resources ● Each ClassLoader instance has an associated parent ClassLoader ● A ClassLoader instance delegates the search for the class or other resource to its parent ● The only ClassLoader that does not have a parent is the VM built-in ClassLoader called bootstrap class loaderhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 18. Process to VM Mapping ● An app receives its own VM process ● It is possible to have apps share the same process ● This is done in two steps: – Define android:sharedUserId attribute in the manifest file; the value must be a unique string – Define the android:process attribute inside the required <application> node (this can also be placed under <activity> or <service> nodes)http://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 19. Process to VM Mapping ● If an application wants to start in a process and that process is still running, Android OS mounts it on that process ● If two or more apps are mounted on the same process, they delegate the resolution of the system classes to the bootstrap class loader ● Consequently, we grab hold of the boostrap loader and then get the System class common to all the apps running in the same process ● Once we have the System class at the bootstrap loader level, we can use System.setProperty and System.getProperty to share values among the appshttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 20. Process to VM Mapping ● If an application wants to start in a process and that process is still running, Android OS mounts it on that process ● If two or more apps are mounted on the same process, they delegate the resolution of the system classes to the bootstrap class loader ● Consequently, we grab hold of the boostrap loader and then get the System class common to all the apps running in the same process ● Once we have the system class, we can use System.setProperty and System.getProperty to share values among the appshttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 21. Example ● Two two applications run in different packages ● But: – They have the same android:sharedUserID values under the <manifest> node – They have the same android:process values under the <application> node – The are both signed with the same default debug certificate – They know the the name of the key property that ProcessSharingApp01 puts into System and ProcessSharingApp02 gets from Systemhttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 22. Example ● Develop two applications, ProcessSharingApp01 and ProcessSharing02, that are mapped into the same VM process ● ProcessSharingApp01 bootstraps to the System class and puts a URL string into its properties by calling System.setProperty(key_string, value_string) ● ProcessSharingApp02 bootstraps to the System class and retrieves the value of the property via System.getProperty(key_string) ● Source can be downloaded from herehttp://www.youtube.com/vkedco http://www.vkedco.blogspot.com
  • 23. References ● http://developer.android.com/reference/android/app/Activity.html ● http://developer.android.com/guide/components/fundamentals.html ● http://developer.android.com/guide/components/processes-and-threads.html ● http://www.linfo.org/process.html ● http://en.wikipedia.org/wiki/Sandbox_(software_development) ● http://en.wikipedia.org/wiki/Sandbox_(computer_security) ● http://www.youtube.com/vkedcohttp://www.youtube.com/vkedco www.vkedco.blogspot.com

×