Android Container
frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
,which is a class of threadContainer.registerContainer()
to register current container when createdContainer.waitingForNewPosition()
to wait for the change of current container's position while runningframeworks/base/services/java/com/android/server/wm/WindowManagerService.java
,which is a class of threadWhen ContainerHandler receives CONTAINER_POSITION_CHANGED
message:
1. Set WMS's member variable-mContainerAdjustment as the current container's position * 1,000,000
2. call WMS.scheduleAnimationLocked() to refresh Z value of windows
mContainerAdjustment
,WMS's member variable,is to save adjusted Z value of current containermContainerAdjustment
on the normal Z valuemLastContainerAdjustment
,WindowStateAnimator's member variable,is to save last value of WMS.mContainerAdjustment
createSurfaceLocked()
and prepareSurfaceLocked()
of WindowStateAnimator class to set Z valuefunction createSurfaceLocked()
is to create a surface for windows,when calling:
1. Get WMS.mContainerAdjustment's value
2. Save it by mLastContainerAdjustment
3. Set windows's Z value as mAnimLayer + WMS.mContainerAdjustment
function prepareSurfaceLocked()
is to refresh windows's state,when calling:
1. Get WMS.mContainerAdjustment's value
2. Judge the value,if it's same as mLastContainerAdjustment's value
3. If the same,refresh Z value as mAnimLayer + WMS.mContainerAdjustment
4. Update mLastContainerAdjustment's value as WMS.mContainerAdjustment
/frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
/frameworks/base/services/java/com/android/server/wm/WindowStateAnimator.java
Android.mk
Linux Kernel中的Container device drive保存了当前各个container的前后顺序,当不同container进行切换时,如何在屏幕上及时准确地显示出来呢?
我们首先在WMS(WindowManagerService)借助ContainerThread,创建线程时注册当前的Container;线程运行时监测当前Container的位置是否发生改变,当前Container的位置发生变化时,ContainerThread会发送一个message给ContainerHandler;
ContainerHandler收到message后,将当前container的位置乘以1,000,000,新值赋给WMS的成员变量mContainerAdjustment
;并刷新窗口的Z值;WMS设置SurfaceFlinger中的Z值时会在正常的Z值之上加上mContainerAdjustment
;
通过WindowStateAnimator的成员变量mLastContainerAdjustment
和WMS.mContainerAdjustment
比较,并更新值。