Android 的Ashmem是一种共享内存的机制,它基于mmap系统调用,不同进程可以将同一段物理内存映射到各自的虚拟地址控制,从而实现共享。
它在dev目录下对应的设备文件为/dev/ashmem.
CursorWindow --> SQLiteClosable --> Object.
A buffer containing multiple cursor rows. A CursorWindow is read-write when initially created and used locally. When sent to a remote process (by writing it to a Parcel), the remote process receives a read-only view of the cursor window. Typically the cursor
window will be allocated by the producer, filled with data, and then sent to the consumer for reading.
SQLiteCursor --> AbstractWindowedCursor --> AbstractCursor --> Object.
A Cursor implementation that exposes results from a query on a SQLiteDatabase. SQLiteCursor is not internally synchronized so code using a SQLiteCursor from multiple threads should perform its own synchronization when using the SQLiteCursor.
AbstractCursor实现了CrossProcessCursor接口; CrossProcessCursor extends Cursor{ *** }
INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,原因:apk的AndroidManifest.xml中声明了android:sharedUserId="android.uid.system",但没有相应的签名。
找到编译目标系统时的签名证书platform.pk8和platform.x509.pem,在android源码目录build\target\product\security下。
执行签名命令:$signapk.jar platform.x509.pem platform.pk8 Demo.apk signedDemo.apk
在Android系统源码的环境下用make来编译,修改Android.mk文件,加入LOCAL_CERTIFICATE := platform;
eclypse打的apk包:打开apk文件,删掉META-INF目录下的CERT.SF和CERT.RSA两个文件。再使用目标系统的platform密钥来重新给apk文件签名。
通过Shared User id,拥有同一个User id的多个APK可以配置成运行在同一个进程中。那么把程序的UID配成android.uid.system,也就是要让程序运行在系统进程中,这样就有权限来修改系统时间了。
PID:为Process Identifier, PID就是各进程的身份标识,程序一运行系统就会自动分配给进程一个独一无二的PID。进程中止后PID被系统回收,可能会被继续分配给新运行的程序,但是在android系统中一般不会把已经kill掉的进程ID重新分配给新的进程,新产生进程的进程号,一般比产生之前所有的进程号都要大。
UID:一般理解为User Identifier,UID在linux中就是用户的ID,表明时哪个用户运行了这个程序,主要用于权限的管理。而在android 中又有所不同,因为android为单用户系统,这时UID 便被赋予了新的使命,数据共享,为了实现数据共享,android为每个应用几乎都分配了不同的UID,不像传统的linux,每个用户相同就为之分配相同的UID。(当然这也就表明了一个问题,android只能时单用户系统,在设计之初就被他们的工程师给阉割了多用户),使之成了数据共享的工具。
因此在android中PID,和UID都是用来识别应用程序的身份的,但UID是为了不同的程序来使用共享的数据。
Uid:system/root/app/shell/wifi