adb shell dumpsys窗口窗口输出描述 [英] adb shell dumpsys window windows output describing

查看:1814
本文介绍了adb shell dumpsys窗口窗口输出描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用应用在我的Android设备和Java代码之间进行交互。我遇到的问题是,在按下主页按钮后,在某些设备(包括仿真器)上,appium返回的当前活动不正确(它返回的previuos活动目前必须最小化)。我发现appium使用了 dumpsys窗口窗口 ,其中包含 mFocusedApp 值以获取当前应用。我阅读了关于获取Android当前活动的另一个答案,通常建议使用:

I'm using appuim for interaction between my Android device and java code. And I faced with problem that on some kind of devices(including emulators) after pressing on Home button, appium return incorrect current activity (it returns previuos activity which is currently must be minimized). I found that appium used dumpsys window windows with grabbing mFocusedApp value for getting current app. I read another answers about getting Android current activities, and mostly it recommend to use:

adb shell "dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'"

这是问题的根源,因为按下主页按钮 mCurrentFocus mFocusedApp 链接到不同的活动。但是我找不到任何解释说明这些字段之间的区别。为什么appuim仅使用 mFocusedApp

That was the source of the problem, because after pressing Home button mCurrentFocus and mFocusedApp linked to different activities. But I can't find any explanation the difference between these fields. And why appuim uses only mFocusedApp for it?

推荐答案

mCurrentFocus mFocusedApp 之间的差异解释正盯着您:

The explanation of the difference between mCurrentFocus and mFocusedApp stares right at you:


$ dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
    mCurrentFocus=Window{X uX package/.activity}
    mFocusedApp=AppWindowToken{X token=Token{X ActivityRecord{X uX package/.activity tX}}}

mCurrentFocus 是一个 Window (只是一个视图,可能没有 ActivityRecord 与之关联)

The mCurrentFocus is a Window (just a view which may or may not have an ActivityRecord associated with it)

mFocusedApp AppWindowToken (一个 app 令牌,它将始终具有 ActivityRecord

The mFocusedApp is an AppWindowToken (an app Token which will always have an ActivityRecord)

因此,当输入焦点切换到具有活动的视图时, / code>- mCurrentFocus mFocusedApp 都将显示相同的活动。但是有时焦点会切换到视图而没有活动(例如SystemUI的某些部分)-然后是 mCurrentFocus 将显示视图,但 mFocusedApp 仍将显示<$ app 中的c $ c> ActivityRecord ,它的焦点在最后一次切换之前。

So when input focus switches to a view with an activity - both mCurrentFocus and mFocusedApp would show the same activity. But sometimes focus switches to a view without an activity (like parts of SystemUI, etc) - then mCurrentFocus will be showing that view but mFocusedApp will still be showing the ActivityRecord of the app which had the focus before the last switch.

这篇关于adb shell dumpsys窗口窗口输出描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆