资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,2012/10/22,#,Android,长征开始,-,系统架构分析,Android System Analysis,3,Android,系统体系,概述,活动,用户界面,部件,通常,对应,一个屏幕,意向接收,设置并回应提示或状态改变,并激活应用程序,服务,没有前端界面的,后台任务,内容提供,应用程序可以共享数据,应用程序构建模块,Android,框架,4,JNI,JAVA,C/,汇编,1.,最低层是,linux kernel,,主要负责内存管理、进程调度等系统管理以及终端的硬件驱动。,Binder driver,,,google,为,android,设计的一个增强系统的进程间通信能力的模块,。,2.Kernel,的上一层是,libraries,,包含了核心库、第三方库和,android,虚拟机。,android,并没有直接采用传统的,j2se,或,j2me,的,java,虚拟机,而是自己建立了一个称为,dalvik,的虚拟机,号称更节省字节码的空间,性能更好。但这也成为了,google,与,sun,关于,java,版权争议点,。,3.Framework,是,android,为应用开发者设计的一套软件框架,提供了丰富的,api,和一些现成的开发元素。,Framework,是采用,java,语言实现的。在,NDK,出来之前,,android,应用开发者基本上只能用,java,来开发应用。,Android,使用,JNI,连接了,libraries,和,framework,。,4.Application,就是在,framework,的基础上开发的各种应用,。,6,本地库,Bionic Libc,函数库,(Funtion Libraries),本地服务,(Native Servers),硬件抽象库,(Hardware Abstraction Libraries),Libraries,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 PacketVideos OpenCORE;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,7,SQLite,轻量级事务数据存储,多数平台数据存储的后端,8,Dalvik,虚拟机,完全为,Android,定制的虚拟机,基于,QEMU,提供应用程序可移植性和运行环境的一致性,运行优化的,dex,格式文件和,Dalvik,字节码,Java.class/.jar,在创建的时候就被转换成为了,.dex,为嵌入式环境设计,支持每设备多个虚拟机进程,高度,CPU,优化的字节码解释器,高效内存使用,应用程序框架,活动管理器,包管理器,窗口管理器,资源管理器,内容提供器,视图系统,通知管理器,电话管理器,各种服务,Application Framework,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.,Developers have full access to the same framework APIs used by the core applications.The application architecture is designed to simplify the reuse of components;any application can publish its capabilities and any other application may then make use of those capabilities(subject to security constraints enforced by the framework).This same mechanism allows components to be replaced by the user.,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 backstack,应用程序,联系人,主页,电话,浏览器,愤怒的小鸟,Applications,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.,AJAX,网页应用程序,使,JavaScript,可直接绘图,DOM,可以创建,UI,特效,Android,目前不支持,HTML5,,但有,Gears,Google Reader,Gmail,Android 2.2,5,月,19,日,Google I/O 2010,新特性:,全新的,JIT,编译器,额外的可用,RAM,增强支持,OpenGL ES 2.0,支持,Flash 10.1,APP2SD,将支持软件安装到存储卡,修复多点触摸传感器的问题,激活轨迹球闪光色彩设置,增加,FM,收音机支持,Android,系统,深入探究,一、,进程管理,进程,当应用程序的第一个组件需要运行时,,Android,就创建一个只包含一个线程的,Linux,的进程,默认情况下,应用程序的所有组件都在这个进程中的线程中执行,每一个进程都被一个,manifest file,控制,当内存资源很紧张的时候,,Android,会暂时中止掉一些优先级较低的进程,线程,在一个进程的主线程中,所有的组件都将被初始化。,可以通过,Java,传统的,Thread,类进行创建,Android,操作系统会尽量长时间的保持线程,活动,控制,层次比线程和进程更高一些,如相册,短信编辑器,每个活动,包含以下四个关键状态,(1),一个活动被放在活动栈的最上方,并且开始运行,(2),该活动不再成为系统的焦点,但是它依然可见。系统保存了它的状态,它处于暂停状态。然而,如果内存情况十分糟糕,这个活动会被结束掉。,(3),该活动已经完全模糊,几乎被另一个活动替代。系统仍然保存了它的状态,对于用户来说,它处于不可见状态。一旦内存需要空间,该活动就会被结束掉。,(4),活动被暂停或中止,系统将这个活动的内存收回,直接结束该进程或者调用该活动的结束程序。,活动的状态过程,完全生命周期,开始于,onCreate(Bundle),结束于,onDestroy(),。,可见生命周期,开始于,onStart(),结束于,onStop(),前台生命周期,开始于,onResume(),结束于,onPause(),服务系统,没有可视化的用户接口,而是在后台运行,继承,service,类的子类,音乐播放器,播放界面为活动,后台播放为服务,广播接收系统,负责接收和反馈广播信息,时间变化,电池没电,用户切换了语言模式,BroadcastReceiver,的子类,二、,内存管理,存储选项,开发者根据自己特定的需要来选择存储解决方案,存储选项包括,:,共享机制,即便应用程序中止,数据依然保存,内部存储,一旦应用程序中止,内部存储的数据会被全部删除,外部存储,可以是可插拔的移动媒体,(,如,SD,
展开阅读全文