Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb shell dumpsys window windows output describing

I'm using appium 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 previous 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'"

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 appium uses only mFocusedApp for it?

like image 224
t3ft3l--i Avatar asked Sep 28 '16 19:09

t3ft3l--i


People also ask

What is ADB shell Dumpsys?

dumpsys is a tool that runs on Android devices and provides information about system services. You can call dumpsys from the command line using the Android Debug Bridge (ADB) to get diagnostic output for all system services running on a connected device.

What does in adb shell Dumpsys Gfxinfo do?

If Profile GPU rendering is set to In adb shell dumpsys gfxinfo in Developer Options, the adb shell dumpsys gfxinfo command prints out timing information for the most recent 120 frames, broken into a few different categories with tab-separated-values.

How do I check battery health with ADB?

Type “ADB shell” and connect your phone to your PC. If the drivers are installed properly, the PC will promptly detect the phone and you will see the device codename on the command prompt.


Video Answer


1 Answers

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}}}

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

The mFocusedApp is an AppWindowToken (an app Token which will always have an 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.

like image 175
Alex P. Avatar answered Sep 29 '22 10:09

Alex P.