- 论坛徽章:
- 0
|
(hanchao3c Android开发者论坛原创,转载请注明)
第一部分 libutils概述 libutils是Android的底层库,这个库以C++实现,它提供的API也是C++的。Android的层次的C语言程序和库,大都基于libutils开发。 libutils中的头文件如下所示:[color="blue"]frameworks/base/include/utilslibutils的源文件:[color="blue"]frameworks/base/libs/utilslibutils的库名称:[color="red"]libutils.so 这个库可以分成两个部分,一个部分是底层的工具,另外一个就是实现主要为实现IPC(进程间通讯)的Binder机制。第二部分 公共库概述libutils中的公共库部分主要包含的头文件如下所示:Errors.h:定义宏表示错误代码Endian.h:定义表示大小端的宏misc.h:几个字符串和文件相关的功能函数TextOutput.h:定义文本输出的基类TextOutputBufferedTextOutput.h:类BufferedTextOutput,它是一个TextOutput的实现Pipe.h:定义管道类PipeBuffer.h:定义内存缓冲区域的类BufferList.h:定义链表的模版类SharedBuffer.h:定义类SharedBuffer表示共享内存。String16.h:定义表示双字节字符串的类String16String8.h:定义表示单字节字符串的类String8,并包含了从String16转换功能VectorImpl.h:定义表示向量的类VectorImplVector.h:定义继承VectorImpl的类模版Vector,以及排序向量类SortedVectorImplSortedVector.h:定义排序向量的模版SortedVectorKeyedVector.h:定义使用关键字的向量模板KeyedVectorthreads.h:定义线程相关的类,包括线程Thread、互斥量Mutex、条件变量Condition、读写锁ReadWriteLock等socket.h:定义套结字相关的类Socket[color="red"]Timers.h[color="red"]:定义时间相关的函数和定时器类[color="red"]DurationTimer[color="red"]。[color="red"][color="blue"]ZipEntry.h[color="blue"]、[color="blue"]ZipFileCRO.h[color="blue"]、[color="blue"]ZipFile.h[color="blue"]、[color="blue"]ZipFileRO.h[color="blue"]、[color="blue"]ZipUtils.h[color="blue"]:与[color="blue"]zip[color="blue"]功能相关的类。[color="blue"][color="blue"][color="blue"]第三部分 Binder进程间通讯部分 Binder是进程间通讯部分的核心,它为不同的系统提供了可移植的进程间通讯手段。RefBase.h :引用计数,定义类RefBase。Parcel.h :为在IPC中传输的数据定义容器,定义类ParcelIBinder.h:Binder对象的抽象接口, 定义类IBinderBinder.h:Binder对象的基本功能, 定义类Binder和BpRefBaseBpBinder.h:BpBinder的功能,定义类BpBinderIInterface.h:为抽象经过Binder的接口定义通用类,定义类IInterface,类模板BnInterface,类模板BpInterfaceProcessState.h表示进程状态的类,定义类ProcessStateIPCThreadState.h表示IPC线程的状态,定义类IPCThreadState[color="red"]IServiceManager.h:表示服务管理器的类,供其它需要构造服务的类使用[color="red"]IPermissionController.h:权限控制类。 几个与内存相关的类的头文件如下所示:[color="darkred"]IMemory.h:定义内存相关类的接口,表示堆内存的类IMemoryHeap和BnMemoryHeap,表示一般内存的类IMemory和BnMemory。[color="darkred"]MemoryHeapBase.h:定义类MemoryHeapBase,继承并实现BnMemoryHeap[color="darkred"]MemoryBase.h:定义类MemoryBase,继承并实现BnMemory 在一般的使用过程中,通常是以使用MemoryHeapBase类分配一块堆内存(类似malloc),而MemoryBase表示从一块分配好堆内存中的一部分内存。 此外内存相关的功能中还包含了头文件MemoryDealer.h和MemoryHeapPmem.h。[color="blue"][color="blue"]Binder[color="blue"]功能中各个类之间的关系如下图所示:
![]()
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/87328/showart_1681064.html |
|