简单整理一下 window insets 的 日志添加,大部分都是加在方法入口,捋一下大概的过程,Android14,给安卓小白的自己使用。
- core/java/android/view/InsetsController.java
public void onControlsChanged(InsetsSourceControl[] activeControls);
public void show(@InsetsType int types, boolean fromIme, @Nullable ImeTracker.Token statsToken);
public void hide(@InsetsType int types, boolean fromIme, @Nullable ImeTracker.Token statsToken);
public void applyAnimation(@InsetsType final int types, boolean show, boolean fromIme, boolean skipAnim, @Nullable ImeTracker.Token statsToken);
- core/java/android/view/InsetsSourceControl.java
public InsetsSourceControl(int id, @InsetsType int type, @Nullable SurfaceControl leash, boolean initiallyVisible, Point surfacePosition, Insets insetsHint);
public void release(Consumer<SurfaceControl> surfaceReleaseConsumer);
- services/core/java/com/android/server/wm/DisplayPolicy.java
void addWindowLw(WindowState win, WindowManager.LayoutParams attrs){
... ...
/* 添加了一些日志 */
mDisplayContent.getInsetsStateController().getOrCreateSourceProvider( provider.getId(), provider.getType()).setWindowContainer(win, frameProvider, overrideProviders);
mInsetsSourceWindowsExceptIme.add(win);
}
void removeWindowLw(WindowState win);
- services/core/java/com/android/server/wm/InsetsSourceProvider.java
InsetsSourceProvider(InsetsSource source, InsetsStateController stateController, DisplayContent displayContent);
void updateFakeControlTarget(@Nullable InsetsControlTarget fakeTarget);
void updateControlForTarget(@Nullable InsetsControlTarget target, boolean force){
... ...
final SurfaceControl leash = mAdapter.mCapturedLeash;
if (mControllable){
/* 加了一些日志 */
}
}
void onSurfaceTransactionApplied();
void setClientVisible(boolean clientVisible);
void setServerVisible(boolean serverVisible);
protected void updateVisibility();
public void startAnimation(SurfaceControl animationLeash, Transaction t,
@AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback);
public void onAnimationCancelled(SurfaceControl animationLeash);
- services/core/java/com/android/server/wm/InsetsStateController.java
InsetsSourceProvider getOrCreateSourceProvider(int id, @InsetsType int type){
... ...
provider = id == ID_IME ? new ImeInsetsSourceProvider(source, this, mDisplayContent)
: new InsetsSourceProvider(source, this, mDisplayContent);
/* 添加了一些日志 */
mProviders.put(id, provider);
return provider;
}
void removeSourceProvider(int id);
void onRequestedVisibleTypesChanged(InsetsControlTarget caller); /* 这个方法在谷歌源码里面没找到,有点奇怪 */
void notifyControlChanged(InsetsControlTarget target);
- services/core/java/com/android/server/wm/SurfaceAnimator.java
static SurfaceControl createAnimationLeash(Animatable animatable, SurfaceControl surface,
Transaction t, @AnimationType int type, int width, int height, int x, int y,
boolean hidden, Supplier<Transaction> transactionFactory){
/* 打印 type = ANIMATION_TYPE_INSETS_CONTROL */
... ...
}
- services/core/java/com/android/server/wm/WindowManagerService.java
public int addWindow(Session session, IWindow client, LayoutParams attrs, int viewVisibility,
int displayId, int requestUserId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale){
WindowState parentWindow = null;
final int callingUid = Binder.getCallingUid();
final int callingPid = Binder.getCallingPid();
final long origId = Binder.clearCallingIdentity();
final int type = attrs.type;
/* 加了一些日志打印 */
synchronized (mGlobalLock) {
... ...
}
/* 加了一些日志打印 */
boolean needToSendNewConfiguration =
win.isVisibleRequestedOrAdding() && displayContent.updateOrientation();
... ...
}
- services/core/java/com/android/server/wm/WindowState.java
void setRequestedVisibleTypes(@InsetsType int requestedVisibleTypes);