window
在dumpsys window中查看mCurrentFocus和mFocusedApp
mCurrentFocus=Window{f96644 u0 NotificationShade}
mFocusedApp=ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}
mCurrentFocus指的是当前的焦点窗口
mFocusedApp指的是当前的焦点Activity
input
在dumpsys input中查看FocusedApplications和FocusedWindows
FocusedApplications:
displayId=0, name='ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}', dispatchingTimeout=5000ms
FocusedWindows:
displayId=0, name='f96644 NotificationShade'
event log
request 和 entering正常情况下是一一对应,打印了entering则表示真正的焦点已经进入到对应的窗
发生Application does not hava focused window时,一般request 有打印,我们可以通过是否有entering的打印来分析
1.entering部分有打印,代表焦点已经在input里面,但是仍然有ANR,就需要从input等方面分析
2.entering部分未打印,代表input没有被触发焦点窗口设置到input,需排查SurfaceFlinger或WMS
焦点切换三部log打印位置
java层InputMonitor.java的requestFocus(); // "Focus request"
native层InputDispatcher.cpp的setFocusedWindow(),binder线程; // "Focus receive"
native层InputDispatcher.cpp的dispatchFocusLocked(),InputDispatcher线程 // "Focus " + ("entering " : "leaving ")