Android Container
drivers/staging/android/container.c
in kernelCONTAINER_REGISTER
:its parameter is a pointer to int;to register the container's ID to which the pointer pointsCONTAINER_GET_FRONT_ID
:parameter is a pointer to int;to write in running container's IDCONTAINER_GET_STACK_POS
:parameter is a pointer to int;to write in container's ID which need get position before calling;to write in the container's position in stack after callingCONTAINER_SET_FRONT_ID
:parameter is a pointer to int;to set the container's ID to which the pointer points activeCONTAINER_WAIT_FOR_NEW_POS
:parameter is a pointer to int;to write in container's ID which need wait for position before calling;to write in the container's new position after callingC++ layer's encapsulation code is in frameworks/native/libs/container/Container.cpp
;it generates libcontainer.so
from compilation;the definition of interface is as follow:
int getCurrentContainer(void) get container's ID in which current process is
int registerContainer(int container) register a container's ID
int getFrontContainer(void) judge the container's ID in front
int isCurrentContainerTheFront(void) judge the container's ID if is in front
int getContainerPosition(int container) get the container's position in stack
int setFrontContainer(int container) set a container in front
int waitForNewPosition(int container) make current process sleep until specified container's position changes
int getAvailableContainers(int containers[]) get all running containers' ID
Java Interface is a kind of android.util.Container class;its source code is in /frameworks/base/core/java/android/util/Container.java
;it accesses C++ Interface by JNI(its code is in /frameworks/base/core/jni/android_util_Container.cpp
)
int getCurrentContainer()
:return the ID of container in which current process isint registerContainer(int container)
:register a container ID to tell kernel the container has startedint getFrontContainer()
:return the present active containerint setFrontContainer(int container)
:set a container activeint getContainerPosition(int container)
:get the position of a containerint waitForNewPosition(int container)
:current process stay sleep after calling;until specified container's position changes,it'll return the container's new positionint registerCurrentContainer()
:register the container in which current process isframeworks/base/core/java/android/util/IContainerManager.aidl
Functions which IContainerManager defines as follow:
int switchToContainer(int container) switch to specified container
int getCurrentContainer() get container in which current process is
int getFrontContainer() get the front-end container
boolean isCurrentContainerInFront() judge the container in which current process is if front-end
int[] getAvailableContainers() get all running containers
/frameworks/base/core/java/android/util/IContainerManager.aidl
/frameworks/base/Android.mk
,src_files
add line /frameworks/base/core/java/android/util/IContainerManager.aidl
;if you hope the interface is open for sdk,add it in following file aidl_files
frameworks/base/services/java/com/android/server/ContainerManagerService.java
/frameworks/base/services/java/com/android/server/ContainerManagerService.java
/frameworks/base/servcies/java/com/android/server/SystemServer.java
,add instantiation and call to ContainerManagersystem/frameworks/services.jar
ContainerManager is a client of CMS;its code is in development/contain and it generates ermanager;generated jar package from compilation is in
out/target/common/obj/JAVA_LIBRARIES/containermanager_intermediates/classes.jar
switchToContainer(int)
of ContainerManager classswitchToContainer(int)
interface of ContainerManagerService by Binder mechanismsetFrontContainer(int)
function of android.util.Container
classsetFrontContainer(int)
function of container in libcontainer.soioctl(CONTAINER_SET_FRONT_ID)
operation on it