IWindow是很重要的,官方介绍是API back to a client window that the Window Manager uses to inform it of interesting things happening. 也就是说是是用于WMS回调客户端的,当窗口有一些改变时,WMS及时调用客户端接口,让客户端窗口立即更新。
IWindow.aidl - OpenGrok cross reference for /frameworks/base/core/java/android/view/IWindow.aidl
/**
* API back to a client window that the Window Manager uses to inform it of
* interesting things happening.
*
* {@hide}
*/
oneway interface IWindow {
/**
* ===== NOTICE =====
* The first method must remain the first method. Scripts
* and tools rely on their transaction number to work properly.
*/
/**
* Invoked by the view server to tell a window to execute the specified
* command. Any response from the receiver must be sent through the
* specified file descriptor.
*/
void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
void resized(in ClientWindowFrames frames, boolean reportDraw,
in MergedConfiguration newMergedConfiguration, in InsetsState insetsState,
boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
int syncSeqId, boolean dragResizing);
/**
* Called when this window retrieved control over a specified set of insets sources.
*/
void insetsControlChanged(in InsetsState insetsState, in InsetsSourceControl[] activeControls);
/**
* Called when a set of insets source window should be shown by policy.
*
* @param types internal insets types (WindowInsets.Type.InsetsType) to show
* @param fromIme true if this request originated from IME (InputMethodService).
* @param statsToken the token tracking the current IME show request or {@code null} otherwise.
*/
void showInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
/**
* Called when a set of insets source window should be hidden by policy.
*
* @param types internal insets types (WindowInsets.Type.InsetsType) to hide
* @param fromIme true if this request originated from IME (InputMethodService).
* @param statsToken the token tracking the current IME hide request or {@code null} otherwise.
*/
void hideInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
void moved(int newX, int newY);
void dispatchAppVisibility(boolean visible);
void dispatchGetNewSurface();
void closeSystemDialogs(String reason);
/**
* Called for wallpaper windows when their offsets or zoom level change.
*/
void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, float zoom, boolean sync);
void dispatchWallpaperCommand(String action, int x, int y,
int z, in Bundle extras, boolean sync);
/**
* Drag/drop events
*/
void dispatchDragEvent(in DragEvent event);
/**
* Pointer icon events
*/
void updatePointerIcon(float x, float y);
/**
* Called for non-application windows when the enter animation has completed.
*/
void dispatchWindowShown();
/**
* Called when Keyboard Shortcuts are requested for the window.
*/
void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId);
/**
* Called when Scroll Capture support is requested for a window.
*
* @param callbacks to receive responses
*/
void requestScrollCapture(in IScrollCaptureResponseListener callbacks);
}
IWindow是怎么赋值并一步步传入WMS端的呢,由下面代码可以看出,它是在ViewRootImpl中进行赋值的
//定义
final W mWindow;
...
public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, WindowLayout windowLayout) {
...
mWindow = new W(this);
...
}
W如下
static class W extends IWindow.Stub {
private final WeakReference<ViewRootImpl> mViewAncestor;
private final IWindowSession mWindowSession;
W(ViewRootImpl viewAncestor) {
mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
mWindowSession = viewAncestor.mWindowSession;
}
...
public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView, int userId) {
//此时将mWindow传入,这个方法会一步步调用到Server端WMS中
res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
getHostVisibility(), mDisplay.getDisplayId(), userId,
mInsetsController.getRequestedVisibleTypes(), inputChannel, mTempInsets, mTempControls, attachedFrame, compatScale);