Regarding the output order:
- The windows are traversed top-to-bottom in z-order, so the top-most windows come first.
Regarding the fields:
The 793212d
is the (unique) ID of the window, obtained with System#identityHashCode.
The u0
refers to the user ID to which the window belongs. The user id is not the same as the Unix UID, it is a more high-level concept. Android groups several Unix UIDs to belong to one user ID, i.e. the first 100.000 Unix UIDs belong to user ID 0 and so on (reference). To determine the user ID of the window, Android would look up the Unix UID of the window (with each app having its own Unix UID), and then map the Unix UID to the user ID.
The NavigationBar
is the title of the window.
Technical details: When calling dumpsys window windows
, this will trigger a dump request at the WindowManagerService
(link). This class has a member mRoot
of type RootWindowContainer
, to which the dump request will be forwarded (link). The relevant code is:
forAllWindows((w) -> {
if (windows == null || windows.contains(w)) {
pw.println(" Window #" + index[0] + " " + w + ":");
w.dump(pw, " ", dumpAll || windows != null);
index[0] = index[0] + 1;
}
}, true /* traverseTopToBottom */);
The w
is of type WindowState
, which overrides toString
to obtain the String
representation you see in the dumpsys
output (link). The relevant code is:
mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
+ " u" + UserHandle.getUserId(mOwnerUid)
+ " " + mLastTitle + (mAnimatingExit ? " EXITING}" : "}");
The RootWindowContainer#forAllWindows
method traverses the mChildren
list, which is specified to be in z-order (link, link):
// List of children for this window container. List is in z-order as the children appear on
// screen with the top-most window container at the tail of the list.
protected final WindowList<E> mChildren = new WindowList<E>();
boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
if (traverseTopToBottom) {
for (int i = mChildren.size() - 1; i >= 0; --i) {
if (mChildren.get(i).forAllWindows(callback, traverseTopToBottom)) {
return true;
}
}
...