Rely on Display#getRealSize when dumping XML hierarchy

* Previously, the height returned by Display#getSize was used to
  determine visible objects. Based on the API level and the presence of
  system decorations (e.g. notches), this can cause objects near the
  bottom of the screen to be considered out of bounds (i.e. only objects
  within y=0 and y=partial_height are considered even if the omitted
  decorations are at the top of the screen).

Bug: 193270758
Bug: 188156320
Bug: 27537269
Test: manual
Change-Id: Iba21245c947cec0d0054f6d86e3585ba73233223
This commit is contained in:
Daniel Peykov
2022-10-25 21:32:46 +00:00
parent 3b60cd3b94
commit afebeb7b43
3 changed files with 3 additions and 3 deletions

View File

@@ -107,7 +107,7 @@ public class DumpCommand extends Command {
DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
int rotation = display.getRotation();
Point size = new Point();
display.getSize(size);
display.getRealSize(size);
AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x,
size.y);
}

View File

@@ -139,7 +139,7 @@ public class AccessibilityNodeInfoDumper {
serializer.attribute("", "id", Integer.toString(displayId));
int rotation = display.getRotation();
Point size = new Point();
display.getSize(size);
display.getRealSize(size);
for (int i = 0, n = windows.size(); i < n; ++i) {
dumpWindowRec(windows.get(i), serializer, i, size.x, size.y, rotation);
}

View File

@@ -767,7 +767,7 @@ public class UiDevice {
if(root != null) {
Display display = getAutomatorBridge().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
display.getRealSize(size);
AccessibilityNodeInfoDumper.dumpWindowToFile(root,
new File(new File(Environment.getDataDirectory(), "local/tmp"), fileName),
display.getRotation(), size.x, size.y);