Download as PPT, PDF, TXT or read online from Scribd
Download as ppt, pdf, or txt
You are on page 1of 31
William W.-Y.
Liang @ NTUT CSIE
Note: The Copyrights of the referenced slides go to its original author listed in each slide. As a result, this slide is provided for internal reference only! System Integration for the Android Operating System William W.-Y. Liang (), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University of Technology NTUT CSIE William W.-Y. Liang @ NTUT CSIE Android Handsets 2 SJU 2004-04 Android Motorola Cliq HTC G1 HTC Hero Samsung i7500 Samsung Moment Motorola Droid HTC Magic HTC Tattoo Sony X10 NTUT CSIE William W.-Y. Liang @ NTUT CSIE What is Android? An Open Platform for Mobile Development A hardware reference design for mobiles A Linux operating system kernel Open source libraries A run time environment An application framework and UI framework Some pre-installed applications Software Development Kit Android brings Internet-style innovation and openness to mobile phones. 3 SJU 2004-04 Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE 2010 Prediction 4 SJU 2004-04 Android DIGITIMES2009/12 Near 9% Increment NTUT CSIE William W.-Y. Liang @ NTUT CSIE A Prediction by Gartner 5 SJU 2004-04 Android Android currently runs on less than 2% of all smartphones. Predicted forecast for smartphone OSs by 2012: Symbian, 203 million devices sold (39% of the market) Android, 76 million devices sold (14.5% of the market) iPhone, 71.5 million devices sold (13.7% of the market) Windows Mobile, 68.8 million devices sold (12.8% of the market) BlackBerry, 62.25 million devices sold (12.5% of the market) Palms WebOS, 11 million devices sold (2.1% of the market) NTUT CSIE William W.-Y. Liang @ NTUT CSIE 6 SJU 2004-04 Android About Android Based on Slides in Discussion on Android, Mobile SIG, Larry Copeland Android is a software platform and operating system mainly for mobile devices based on the Linux operating system developed by Google and later the Open Handset Alliance. It allows developers to write managed application code in Java language that utilizes Google-developed Java libraries. The unveiling of the Android platform on 5 November 2007 was announced with the founding of the Open Handset Alliance (OHA), a consortium of 34 hardware, software, and telecom companies, such as Qualcomm, TI, Broadcom, Intel, Marvell, Nvidia, SiRF, WindRiver, T-Mobile, Sprint Nextel, China Mobile, KDDI, NTT DoCoMo, Motorola, Samsung, HTC, etc., devoted to advancing open standards for mobile devices. Google has made most of the Android platform available under the Apache free-software and open-source license, in Oct. 2008 (to prevent the GPL obstacle problem in commercializing open sources for industry companies.) NTUT CSIE William W.-Y. Liang @ NTUT CSIE 7 SJU 2004-04 Android The First Complete Android Phone T-Mobile G1 Qualcomm MSM7201A, 528 MHz ROM: 256 MB, RAM: 192 MB Touch screen (320x480) Real Web browsing capabilities 3.2 MP camera Customizable screen QWERTY keyboard Trackball 3G WCDMA, Quad-band GSM, Wi-Fi, Bluetooth 2.0 Software: Easy access to Google applications Maps (including satellite, traffic, and street views), Gmail, YouTube, Calendar, Google Talk IM/text/e-mail Music player, Video playback One-click Google Search Android Market NTUT CSIE William W.-Y. Liang @ NTUT CSIE Google Nexus One 8 SJU 2004-04 Android Source: http://blog.xuite.net/jon 6773/blog/29930408 Estimated BOM Cost: US$174 NTUT CSIE William W.-Y. Liang @ NTUT CSIE SJU 2004-04 Android Android Architecture 9 9 NTUT CSIE William W.-Y. Liang @ NTUT CSIE 10 SJU 2004-04 Android The Linux Kernel Based on Slides in Smart Phone, by Xiaohua Du and Xiaoyi Sheng Android differs from the typical GNU/Linux in that it adopts only the Linux kernel, not everything. The first process init transfers to Androids own application environment. There is no shell by default, except using adb. BSD libc is used instead of glibc or uClibc. As a result, it is called Android/Linux, not GNU/Linux. Why Linux? Great memory and process management Permissions-based security model Proven driver model Support for shared libraries Its already open source! Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. Android relies on Linux version 2.6.25 and above for Android releases (1.0, 1.1, 1.5, and 2.0). The kernel also acts as an abstraction layer between the hardware and the rest of the software stack. NTUT CSIE William W.-Y. Liang @ NTUT CSIE 11 SJU 2004-04 Android Android Runtime 11 Provide 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 (Binary code) 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. NTUT CSIE William W.-Y. Liang @ NTUT CSIE 12 SJU 2004-04 Android Development Tools for Android Applications Currently supported development platforms include x86-based computers running Linux (any Linux Distribution), Mac OS X 10.4.8 or later, Windows XP or Vista. The Android SDK includes a comprehensive set of development tools, including a debugger, libraries, a handset emulator (QEMU), documentations, sample code, and tutorials. http://developer.android.com/sdk/ Android Virtual Device (AVD) Requirements also include Java Development Kit (JDK 5 or 6). The officially supported integrated development environment (IDE) is Eclipse (3.3 or 3.4) with the Android Development Tools (ADT) plugin. http://www.eclipse.org/downloads/ Eclipse Android Plug-in: https://dl-ssl.google.com/android/eclipse/ Android Developers Website http://developer.android.com/index.html NTUT CSIE William W.-Y. Liang @ NTUT CSIE 13 SJU 2004-04 Android The IDE for Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE 14 SJU 2004-04 Android Android SDK Based on slides from GreenLiff ADT: Android Development Tool, an Eclipe plugin Two debuggers adb: Android Debug Bridge ddms: Dalvik Debug Monitor Server aapk: Android Application package tool All resources are bundled into an archive, called apk file. dx: java byte code to Dalvik executable translator Android emulator: QEMU NTUT CSIE William W.-Y. Liang @ NTUT CSIE 15 SJU 2004-04 Android Major Elements in Application Framework Activity Intent and Intent-Filter Service Content Provider Broadcast Receiver
Activities UI component typically corresponding to one screen. BroadcastReceivers Respond to broadcast Intents. Services Faceless tasks that run in the background. ContentProviders Enable applications to share data. Android Version API Level Release Time 2.1 7 2010.01 2.0.1 6 2009.12 2.0 5 2009.10 1.6 4 2009.09 1.5 3 2009.04 1.1 2 2009.02 1.0 1 2008.09 NTUT CSIE William W.-Y. Liang @ NTUT CSIE 16 SJU 2004-04 Android Activity Slides from Deep inside Android, Gilles Printemps, Esmertec Displays a user interface component and responds to system/user. When an application has a user interface, it contains one or more Activities. An existing Activity can be replaced with a new one that fulfill the same contract (intent). Each Activity can be invoked from other applications. Adding a new Activity in an Android project The new Java class must extend the framework Activity class. Created Activity must be defined into the applications Manifest.xml. NTUT CSIE William W.-Y. Liang @ NTUT CSIE Activity (contd) Each activity is given a default window to draw in. Typically, the window fills the screen, but it might be smaller than the screen and float on top of other windows. The visual content of the window is provided by a hierarchy of views objects derived from the base View class. Android has a number of ready-made views that you can use including buttons, text fields, scroll bars, menu items, check boxes, and more. A view hierarchy is placed within an activity's window by the Activity.setContentView() method. The content view is the View object at the root of the hierarchy. 17 SJU 2004-04 Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE User Interface 18 SJU 2004-04 Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE 19 SJU 2004-04 Android Life Cycle of an Activity Life cycle not directly controlled by application System can kill an application to free up memory. Controll through onCreate(), onPause(), onStop() ... methods Based on Slides from GreenLiff NTUT CSIE William W.-Y. Liang @ NTUT CSIE An Example 20 SJU 2004-04 Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE 21 SJU 2004-04 Android Intents/Intent Filters Slides from Deep inside Android, Gilles Printemps, Esmertec Example: Intent newActivity = new Intent(MyActivity.this, OtherActivity.class); startActivity(newActivity); Provide a late runtime (asynchronous) binding between the code in different applications (for activities, services, and broadcast receivers) Intents: Simple message objects that represent an intention to do something Intent Filters: A declaration of capacity and interest in offering assistance to those in need An intent is made up a number of pieces of information describing the action or the service. (Specifically for activities and services) action -- The general action to be performed, such as ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc. data -- The data to operate on, such as a person record in the contacts database, expressed as a URI (Universe Resource Identifier). NTUT CSIE William W.-Y. Liang @ NTUT CSIE 22 SJU 2004-04 Android Services Similar to activities, but without UI For long-running background tasks Framework Service class must be extended Slides from Deep inside Android, Gilles Printemps, Esmertec Exampe: startService(new Intent(this_activity.this, some_service.class)); Core Services Activity Manager Package Manager Window Manager Resource Manager Content Providers View System Hardware Services Telephony Service Location Service Bluetooth Service WiFi Service USB Service Sensor Service NTUT CSIE William W.-Y. Liang @ NTUT CSIE 23 SJU 2004-04 Android Binder Slides from "Android Anatomy and Physiology," Patrick Brady Problem to solve Applications and Services may run in separate processes but must communicate and share data. IPC can introduce significant processing overhead and security holes. Solution Driver to facilitate inter-process communication (IPC) High performance through shared memory Reference counting, and mapping of object references across processes Synchronous calls between processes NTUT CSIE William W.-Y. Liang @ NTUT CSIE 24 Binder Example SJU 2004-04 Android Activity Mp3PlayerWithService Service mp3Service Binder Mp3PlayerBinder IBinder A more complex IPC: AIDL - Android Interface Definition Language NTUT CSIE William W.-Y. Liang @ NTUT CSIE The Library Layer 25 SJU 2004-04 Android NTUT CSIE William W.-Y. Liang @ NTUT CSIE 26 SJU 2004-04 Android App Runtime Service lib Slides from "Android Anatomy and Physiology," Patrick Brady NTUT CSIE William W.-Y. Liang @ NTUT CSIE 27 SJU 2004-04 Android Example Slides from "Android Anatomy and Physiology," Patrick Brady NTUT CSIE William W.-Y. Liang @ NTUT CSIE Traditional Linux Model vs. Android Model 28 SJU 2004-04 Android native C program glibc & shared libs Kernel Hardware System call Hardware System call Kernel JNI bionic & shared libs Android Framework Application Service getService () JNI Method NTUT CSIE William W.-Y. Liang @ NTUT CSIE Shared Library 29 SJU 2004-04 Android class HelloWorld { public native void helloworld(); static { System.loadLibrary("hello"); } public static void main(String[] args) { new HelloWorld().helloworld(); } } JNI: Java Native Interface Standard interface between Java and C/C++ Libraries offer some form of sharing, allowing the same library to be used by multiple programs at the same time. Dynamic loading Sharing Examples DLL (Dynamic Link Library): Windows SO (Shared Object): Linux/Unix NTUT CSIE William W.-Y. Liang @ NTUT CSIE 30 SJU 2004-04 Android Hardware Abstraction Layer Slides from "Android Anatomy and Physiology," Patrick Brady William W.-Y. Liang @ NTUT CSIE Note: The Copyrights of the referenced slides go to its original author listed in each slide. As a result, this slide is provided for internal reference only! Q & A