Archive for ‘Android Framework’

October 16, 2013

Activity Manager

In the last post we talked about Zygote, and how that special process launched applications. But for Zygote to launch an application is necessary to be requested. Users request to launch an application via a tap on an App icon from the home screen. The home screen as users know it is an application and the only one listening for onClick(). When this happens the launcher contact the ActivityManager. That is, request a handler through the Binder and call startActivity() method from the Activity Manager. If you remember from the Binder post, when an application wants to contact a remote method from another service, it first request a handler to the Binder, this will ask for that service to the Service Manager and pass that handler to the originator. When the Activity Manager receives the request to startActivity() it contacts Zygote to fork itself and start that new VM to run the application. It does this via startViaZygote() method which will open a connection to the Zygote socket (/dev/socket/zygote).

Now you can see how all the previous posts fall together in Android, cool eh 🙂 (images: from Embedded Android)

Android Boot sequence

Android Boot sequence (from Embedded Android)

Service Manager and Binder Interaction

Service Manager and Binder Interaction (from Embedded Android)

But the Activity Manager not only do this. It is responsible for many other tasks. This service is responsible for such an important task as broadcasting intents. You probably saw that scary pop up message saying “Application Not Responding” aka ANR. Then you should know that the Activity Manager is the responsible for this. Not only that, it also sends the intent INTENT.CATEGORY_HOME once it finish booting and reports System Ready, broadcasting the rest of the system this information. If you check the documentation of the service (http://developer.android.com/reference/android/app/ActivityManager.html), you will see the available public methods and make yourself an idea of how much this guy is doing.

This service is tremendously big, is huge and has lots of tasks to talk about. This is an the introductory post to the service but we will certainly come back to those tasks and see on code how are done. In the meanwhile you might want to talk a look to the public code, you can located in google source. That exposes the public API.

Embedded Android

October 12, 2013

Android Framework

The Android Framework is not a specific component of the Android platform. It is a very broad naming of a specific layer in all the Android architecture. In the picture below (from Embedded Android), I like to place the Android Framework in the android.* rectangle. But other people also include System Services, Android Runtime and some native daemons. Binder and User Apps and Stock Android Apps. Sometimes even Dalvik and Zygote. Basically everything that you can find in the frameworks directory in the AOSP (plus something more :).

As you can see the Android Framework is what most people know as Android. It is where most developers base their applications on. The Android Platform includes also other frameworks to help and support developers, like Apache Harmony, but that is not part of the Android Framework. Those are externals.

AndroidArquitechture

AndroidArquitechture (from Embedded Android)

Since Android Framework is just those Dev APIs, you can imagine that you can build AOSP without the framework. It might look weird but Android can be suitable for other kind of systems that is not running a hand-held with Apps. AOSP provides a specific configuration in the build system for this. To do this, just do the next

$ BUILD_TINY_ANDROID=true make -j16

This is what is called Tiny Android. It is specially useful if you are in an early stage of a porting process to a new platform. It will build Init, Bionic, Toll-box, adbd, logcat, and some other binaries and libraries.

So, as a resume, there is a bit of confusion out there on what really is the Android Framework. You can check the sources here and see it by yourself. As you see in the picture the frameworks rely on many services and key components, some of them we already discussed in previous posts like Service Manager, and others we did not discussed yet. But we will in later posts, like Zygote, Surfaceflinger, Android Runtime and Dalvik.

AndroidArquitechture