android system architecture

12

Upload: pvylale

Post on 01-Apr-2015

972 views

Category:

Documents


0 download

DESCRIPTION

What is android & how it works.. This gives the insights to the Android system architecture.

TRANSCRIPT

Page 1: Android System Architecture
Page 2: Android System Architecture

In 2007, people began to circulate rumors that the Google Corporation would introduce a smartphone to compete with Apple's iPhone. Speculation ran rampant -- would Google get into the hardware business? Would the company rely on established cell phone manufacturers for hardware? Would Google simply concentrate on building smartphone applications for other devices like the iPhone?

Google executives claimed that the company wasn't interested in building hardware. But some Web journalists and bloggers remained unconvinced. By early 2008, it became clear that the Google executives had been straightforward all along -- Google wasn't getting into the handset hardware game. But they were getting into the handset software business with a mobile operating system (OS) called Android.

Unlike the Apple iPhone, which has its own OS exclusive to the iPhone's hardware, Google's approach was to create an OS that could work on phones built by different manufacturers. Additionally, no single service provider would have exclusive rights to use the Android platform. In that respect, Android joins other mobile device operating systems like Symbian and Windows Mobile.

The first Google phone was the G1, a handset manufactured by a company based in Taiwan called the High Tech Computer Corporation (HTC). The first service provider to support Android in the United States was T-Mobile. As the OS debuted in the United States, other handset manufacturers announced plans to develop their own Android phones.

In January 2010, Google unveiled the Nexus One. This Android phone was the first handset you could purchase directly from Google. Like the G1, HTC provided the hardware for the Nexus One. Customers could choose to buy the phone for $179 if they signed up with T-Mobile for a two-year contract or $529 for an unsubsidized phone without a contract.

An important factor that sets Android apart from most other mobile operating systems is that it's based on an open source platform. That means Google allows anyone to look at and modify most of Android's source code. Ideally, this would mean that if a developer felt Android needed a specific feature or capability, he or she could build it and incorporate it into the OS. The software would constantly evolve.

Initially, the Android platform didn't support many of the features of other smartphone operating systems. For example, Android offered no Microsoft Exchange support upon release. Many companies use Microsoft Exchange as a platform for e-mail and scheduling applications. But because of the open source nature of Android and Google's support for third-party developers, it didn't take long before a company offered an application that would sync Exchange functions with the phone. The Android platform may have to play catch up with the other operating systems on the market, but it may have the ability to go even farther.

Page 3: Android System Architecture

Several handsets use the Android operating system. There's the HTC G1, the first smartphone to run on Android in the United States. Verizon offers the Droid, an Android phone built by Motorola. Several other phones also rely on Android but the Nexus One is the first true Google phone -- the first phone you can purchase directly from Google.

When Google first issued Nexus One models to its employees, the handsets had no manufacturer markings on the case [source: Abramson]. Once Google offered the phone to the general public, the hardware included an HTC logo.

The Nexus One is 4.7 inches (119 millimeters) tall, 2.4 inches (59.8 millimeters) wide and less than half an inch (11.5 millimeters) thick. It weighs just 4.6 ounces (130 grams) with the battery installed. It has a 3.7-inch (about 9.4-centimeter) active matrix organic light emitting diode (AMOLED) display. The display resolution is 800 by 400 pixels and its contrast ratio is 100,000 to 1.

The phone uses a 1 gigahertz Qualcomm processor and has 512 megabytes of RAM. It also has 512 megabytes of Flash memory and comes with a four-gigabyte micro SD storage card. Nexus One owners who want more storage can upgrade up to a 32-gigabyte SD card.

The phone works on the 850, 900, 1800 and 1900 megahertz frequencies on GSM/EDGE cellular networks. It also has a Wi-Fi receiver that is compatible with 802.11 b and g protocols. The phone supports Bluetooth 2.1 and A2DP stereo Bluetooth. It also has an assisted global positioning system receiver.

The phone's 5-megapixel camera comes with an LED flash. It also has a digital zoom feature that provides a zoom power of 2X. The camera can take video at 20 frames per second with a resolution of 720 by 480 pixels.

The Nexus One launched with the Android operating system version 2.1, codenamed Éclair. This version of the OS supports multiple contacts and synchronization applications, allowing developers to create apps that let users manage several e-mail accounts using one device.

Anyone wanting to buy an Android phone will have to create a Google account first. Google accounts are free and you can sign up at any time whether you own an Android phone or not. If you have a Google account, you can access services like Gmail, Google Calendar and Google Docs. Android's designers built the platform so that it interfaces with these functions smoothly.

As hardware becomes more advanced, Google is likely to tweak the Android OS to support new features and functions. And if Google doesn't do it, someone else will. That's the beauty of an open-source system.

Page 4: Android System Architecture

Google usually refers to the Android OS as a software stack. Each layer of the stack groups together several programs that support specific operating system functions.

The base of the stack is the kernel. Google used the Linux version 2.6 OS to build Android's kernel, which includes Android's memory management programs, security settings, power management software and several hardware drivers. Drivers are programs that control hardware devices. For example, the Nexus One has a camera. The Android kernel includes a camera driver, which allows the user to send commands to the camera hardware.

The next level of software includes Android's libraries. You can think of libraries as a set of instructions that tell the device how to handle different kinds of data. For example, the media framework library supports playback and recording of various audio, video and picture formats. Other libraries include a three-dimensional acceleration library (for devices with accelerometers) and a Web browser library.

Located on the same level as the libraries layer, the Android runtime layer includes a set of core Java libraries -- Android application programmers build their apps using the Java programming language. It also includes the Dalvik Virtual Machine.

A virtual machine is a software application that behaves as if it were an independent device with its own operating system. You can run a virtual machine on a computer that operates on a completely different OS than the physical machine's OS. The Android OS uses virtual machines to run each application as its own process. That's important for a few reasons. First, no application is dependent upon another. Second, if an application crashes, it shouldn't affect any other applications running on the device. Third, it simplifies memory management.

The next layer is the application framework. This includes the programs that manage the phone's basic functions like resource allocation, telephone applications, switching between processes or programs and keeping track of the phone's physical location. Application developers have full access to Android's application framework. This allows them to take advantage of Android's processing capabilities and support features when building an Android application. Think of the application framework as a set of basic tools with which a developer can build much more complex tools.

At the top of the stack are the applications themselves. This is where you find the basic functions of the device such as making phone calls, accessing the Web browser and accessing your contacts list. If you're an average user, this is the layer you'll use most. You do that with the user interface. Only Google programmers, application developers and hardware manufacturers access the other layers further down the stack.

You can change the way your Google Phone works by downloading applications to it.

Page 5: Android System Architecture

Figure: Android System Architecture.

1. Linux Kernel

Linux kernel provides an abstraction hardware layer for an Android. This allows an Android to be ported into variety of different devices. Furthermore the Linux kernel is used for android’s memory management, process management, networking and other underlined operating systems services.

Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.

2. Native Libraries

These shared libraries are pre-installed on an android device by each vendor. They are written in C/C++ language and allow 3D and 2D graphics, window manager, all sorts audio video formats, SQLite database and etc.

Page 6: Android System Architecture

Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:

* System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices

* Media Libraries - based on Packet Video’s Open CORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG

* Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications

* LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view

* SGL - the underlying 2D graphics engine

* 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer

* FreeType - bitmap and vector font rendering

* SQLite - a powerful and lightweight relational database engine available to all applications

3. Android Runtime

This layer includes Dalvik Virtual machine code and core Java Libraries.

Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language.

Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.

The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.

4. Application Framework

Page 7: Android System Architecture

Android Application framework is a high-level layer to provide a developer with a space for a new Android applications development.

By providing an open development platform, Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more.

Underlying all applications is a set of services and systems, including:

* A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser

* Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data

* A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files

* A Notification Manager that enables all applications to display custom alerts in the status bar

* An Activity Manager that manages the lifecycle of applications and provides a common navigation back stack

5. Applications and Widgets

This is the highest level of the Android system architecture. End user android applications and widgets layer. Android will ship with a set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.

These days, it's not enough for your smartphone to be able to check e-mail and surf the Web as well as make phone calls. You need to have at your disposal a host of useful, fun, productive or just plain pointless applications. The iPhone's success has proven that a strong application library can excite customers. Google's Android platform appears to be following suit.

Page 8: Android System Architecture

Months before the HTC G1 hit the shelves; Google unveiled the Android platform to developers. The company created a limited software developer kit (SDK) and distributed it to developers. Google even laid down the Android Developer Challenge -- a contest that had a collective prize pool of $10 million.

The top developers earned $275,000 for their applications. Here's a small sample of what made the grade:

Compare Everywhere and Go-cart are two different applications that let you compare prices and read reviews for merchandise while you're in the store. You take a picture of the item's bar code with the phone's camera. These applications identify the item and aggregate reviews and prices from different sources.

The Life360 application is part social networking, part news service. It lets you set up a neighborhood-centric online community and share information with other people in that group. It can alert you of emergencies like a tornado warning that affects your neighborhood. Even if you are miles away, you can keep up with what's going on back at home.

Locale is an application that taps into Android's GPS support. First, you identify various locations you frequent using Google Maps. Then, you create a list of phone settings for each location. For example, at work or in class you'd probably want your phone's ring tone to be appropriate and at a low volume. Once you create the settings for each location, your phone automatically switches to the proper setting based on your current location. Using Locale, you never have to worry about silencing your phone when you walk into your favorite movie theater!

For the green-conscious, there's Ecorio. This application tracks your global carbon footprint and offers suggestions to reduce your personal impact on the environment. You can use the Google Maps application to plot out a trip and Ecorio offers suggestions for carpooling, public transportation and other tips to create the smallest ecological impact.

The developers of the Soft race application wanted to build a program that inspires people to maintain an active lifestyle. Soft race lets people set up footraces, bicycle races and other competitions using the Google Maps function. Participants can travel to a race destination, begin the race and try to make the best time. They can compare their results with those of other participants.

There are many more Android applications in the $275,000 winners' circle and beyond. And several developers for some of the better-known iPhone applications have expressed interest in developing an Android version of their apps. While the iPhone has a head start, Android has the potential to equal and perhaps even surpass it on the application front.

Page 9: Android System Architecture

To build an Android application, a developer has to be familiar with the Java programming language. Assuming the developer is proficient in Java, he or she can download the software developer kit (SDK) and get started. The SDK gives the developer access to Android's application programming interface (API).

The SDK includes several tools, including sample applications and a phone emulator. Emulators are programs that duplicate the features and functions of a specific system or device. The Android emulator is a program that duplicates the functions of a phone running on the Android platform. When the developer finishes building an application, he or she can test it out on the emulator to see how the app will perform on actual hardware.

Google provides an extensive Android tutorial on its developer Web site. The company even provides tips on basic programming steps like testing and debugging software. Experienced developers can skip over the tutorial and go straight to building an application. Google even provides step-by-step instructions on how to build an application named Hello World to give developers the chance to become familiar with Android's architecture.

This brings us to another feature of Android that sets it apart from the iPhone -- developers can create complex applications that run in the background of other applications. Apple limits iPhone applications to the foreground -- if you switch to a different application, the first application you were in stops working until you return to it. This feature limits the types of applications developers can build for the iPhone. Android allows developers more extensive access to background processes.

Google breaks down all applications into four basic building blocks (not all applications will have every building block):

Activities: Whenever an application displays a screen to the user, that's an activity. For example, a map application could have a basic map screen, a trip planner screen and a route overlay screen. That's three activities.

Intents: Intents are the mechanisms for moving from one activity to another. If you were to plot a trip using our example of the mapping application, an intent would interpret your input and activate the route overlay screen. Android also allows for broadcast intent receivers, which are intents triggered by external events like moving to a new location or an incoming phone call.

Services: A service is a program that runs on its own without a user interface. For example, let's say you are participating in a Soft race event. Midway through the race, you decide you want to listen to music as you burn up the track. You can switch over to a media player application and start a song while Soft race continues to track your progress. If Softrace were simply an activity, you would have ended the application as soon as you switched to the media player.

Page 10: Android System Architecture

Content provider: A content provider allows an application to share information with other applications. This allows developers to work together to create a suite of applications that are more robust and complex than each individual component.

There are other considerations developers must keep in mind while building applications. They include Android's graphics rendering engine, process management software, user interface support and other technical details. Google provides guides for all of these elements on its Android developer Web site.

The journey of the Google Phone has not always been a smooth one. Some vendors have been quick to accept the OS, while others have dismissed it. Let's take a look at who is and who isn't thrilled about Android.

There are two kinds of vendors you have to consider when you talk about a smartphone operating system: the handset manufacturers and the cell phone service providers. Handset manufacturers produce the actual hardware. Service providers are the phone companies like T-Mobile or AT&T. Some handset manufacturers work exclusively with a specific cell phone provider. In a few cases, a cell phone service provider will also produce its own hardware.

As we mentioned earlier, the first handset to feature the Android OS was the High Tech Computer Corporation's HTC G1. Before the phone even went on sale, bloggers and journalists began to speculate on who would be the next handset manufacturer to get into the Android game. Gradually, other companies like Motorola, Samsung and Dell debuted their own Android handsets.

The first cell phone provider in the United States to support an Android phone was T-Mobile. The company first offered the HTC G1 on its 3G network to customers in October 2008 for $179 with a contract. A month earlier, T-Mobile offered current customers the opportunity to reserve an HTC G1 in advance. The pre-sale was a huge success -- T-Mobile had to end the sale early when orders exceeded the company's stock of 1.5 million phones [source: Bylund].

But some cell phone service providers have gone so far as to criticize the Android OS in public. Sprint CEO Dan Hesse said that Android wasn't "good enough to put the Sprint brand on it" [source: Carew]. Hesse did leave open the possibility that Sprint would work with the Android platform in the future. Meanwhile, Peter Michaels, the CEO of Hop-on, criticized Hesse's statements. Michaels alleged that Sprint makes it hard for inexpensive handset vendors to join its network. He also pointed out that Sprint was a founding member of the Open Handset Alliance -- a project that spawned Android. But Michaels

Page 11: Android System Architecture

said that while the company says it supports open platforms, its actions seem to contradict those claims [source: Hop-on].

Hesse must have changed his mind about the Android operating system. Sprint now supports the HTC Hero and the Samsung Moment, both Android phones.

Verizon debuted two Android phones in 2009: the Motorola Droid and the HTC Eris. AT&T announced at the beginning of 2010 that it would soon carry Android phones made by HTC, Motorola and Dell.

With Android spreading to all major cell phone carriers across the globe, we may see Google dominate the mobile phone market the same way it has for online search. Maybe this is the droid you're looking for.

In Android, the applications are run as a separate Linux process. So the application lifecycle is closely related to the process lifecycle. The application process lifecycle is handled by the system depending on the current system memory state.

In case of low memory, the Android system kills some less important process. The process importance is decided depending on the state of the process components.

The process types depending on the importance are as follows (from most important to least important):

1. Foreground process: A foreground process is the application process with which the user is currently interacting. The process is considered to be foreground if its Activity is at the top of the Activity stack (its onResume() has been called) or BroadcastReceiver is currently running (onReceive() method is currently getting executed) or its Service is executing callback functions like onCreate(), onStart() or onDestroy() methods.

2. Visible Process: A visible process is the process which has an Activity visible to the user (its onPause() method has been called).

3. Service Process: Service process contains a Service for which startService method is called and the service is running.

Page 12: Android System Architecture

4. Background Process: The background process does not have any visible activities to the user. (Activity onStop() method has been called).

5. Empty Process: Empty process is the one that does not have any active application components. These processes are kept on for caching purpose.

It is important that application developers understand lifecycle of the application process. Not using these correctly can result in the system killing the application’s process while it is doing important work.

THE END