安卓系统软键盘初步分析
初步分析的相关日志
复现log:
11-05 14:01:24.768 7991 7991 V InputMethodManager: onViewClicked: true
11-05 14:01:24.768 7991 7991 D InputMethodManager: showSoftInput() view=androidx.appcompat.widget.AppCompatEditText{bd0acc9 VFED..CL. .F.P..ID 0,0-900,91 #7f0801e3 app:id/etd_placeholder_main aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
11-05 14:01:24.768 6964 6964 I GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3301
11-05 14:01:24.769 6964 6964 V InputMethodService: CALL: onStartInput
11-05 14:01:24.770 6964 6964 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1979
11-05 14:01:24.772 6964 6964 V InputMethod: showSoftInput()
11-05 14:01:24.772 6964 6964 V InputMethodService: Showing window: showInput=true mShowInputRequested=false mViewsCreated=true mDecorViewVisible=false mWindowVisible=false mInputStarted=true mShowInputFlags=1
11-05 14:01:24.772 6964 6964 V InputMethodService: showWindow: updating UI
11-05 14:01:24.773 6964 6964 W InputMethodService: Window size has been changed. This may cause jankiness of resizing window: -1 -> -2
11-05 14:01:24.774 6964 6964 V InputMethodService: CALL: onStartInputView
11-05 14:01:24.774 6964 6964 I GoogleInputMethodService: GoogleInputMethodService.onStartInputView():2091
11-05 14:01:24.792 6964 6964 V InputMethodService: showWindow: draw decorView!
不复现log:
11-05 13:58:46.715 7991 7991 V InputMethodManager: onViewClicked: true
11-05 13:58:46.716 7991 7991 D InputMethodManager: showSoftInput() view=androidx.appcompat.widget.AppCompatEditText{d7f5c50 VFED..CL. .F.P..ID 0,0-3000,91 #7f0800af app:id/edt aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
11-05 13:58:46.716 6964 6964 V InputMethodService: CALL: onStartInput
11-05 13:58:46.716 6964 6964 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1979
11-05 13:58:46.730 6964 6964 V InputMethod: showSoftInput()
11-05 13:58:46.730 6964 6964 V InputMethodService: Showing window: showInput=true mShowInputRequested=false mViewsCreated=false mDecorViewVisible=false mWindowVisible=false mInputStarted=true mShowInputFlags=1
11-05 13:58:46.731 6964 6964 V InputMethodService: showWindow: updating UI
11-05 13:58:46.739 6964 6964 V InputMethodService: CALL: onCreateCandidatesView
11-05 13:58:46.739 6964 6964 V InputMethodService: showWindow: candidates=null
11-05 13:58:46.739 6964 6964 V InputMethodService: CALL: onStartInputView
11-05 13:58:46.739 6964 6964 I GoogleInputMethodService: GoogleInputMethodService.onStartInputView():2091
11-05 13:58:46.750 7991 7991 V InputMethodManager: DISPATCH INPUT EVENT: com.android.internal.view.IInputMethodSession$Stub$Proxy@79c7c09
11-05 13:58:46.806 6964 6964 V InputMethodService: showWindow: draw decorView!
输入法的生命周期
从SurfaceFlinger的dump信息看InputMethod 这个window没有画出来。但是从window的dump信息看,InputMethod 这个window是有的:
Window #12 Window{a13d60d u0 InputMethod}:mDisplayId=0 rootTaskId=10 mSession=Session{59ec9cd 4536:u0a10168} mClient=android.os.BinderProxy@12e08a4mOwnerUid=10168 showForAllUsers=false package=com.google.android.inputmethod.latin appop=NONEmAttrs={(0,0)(fillxfill) gr=BOTTOM CENTER_VERTICAL sim={adjust=pan} ty=INPUT_METHOD fmt=TRANSPARENT wanim=0x1030056 receive insets ignoring z-orderfl=NOT_FOCUSABLE LAYOUT_IN_SCREEN SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDSpfl=USE_BLAST FIT_INSETS_CONTROLLEDvsysui=LIGHT_NAVIGATION_BARapr=LIGHT_NAVIGATION_BARSbhv=DEFAULTfitTypes=STATUS_BARS NAVIGATION_BARSfitSides=LEFT TOP RIGHT}Requested w=3000 h=1828 mLayoutSeq=2144mIsImWindow=true mIsWallpaper=false mIsFloatingLayer=truemHasSurface=true isReadyForDisplay()=true mWindowRemovalAllowed=falseContainerAnimator:mLeash=Surface(name=Surface(name=a13d60d InputMethod)/@0x2fcb3d3 - animation-leash of insets_animation)/@0x321b72e mAnimationType=insets_animationAnimation: com.android.server.wm.InsetsSourceProvider$ControlAdapter@6262cebControlAdapter mCapturedLeash=Surface(name=Surface(name=a13d60d InputMethod)/@0x2fcb3d3 - animation-leash of insets_animation)/@0x321b72eWindowStateAnimator{afb4e85 InputMethod}:mAnimationIsEntrance=true Surface: shown=true layer=0 alpha=1.0 rect=(0.0,0.0) transform=(1.0, 0.0, 0.0, 1.0)mForceSeamlesslyRotate=false seamlesslyRotate: pending=null isOnScreen=trueisVisible=truekeepClearAreas: restricted=[], unrestricted=[]