Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c60ac38f authored by Roy Chou's avatar Roy Chou
Browse files

chore(accessibility): adjust TestableWindowManager#getCurrentWindowMetrics

In #getCurrentWindowMetrics, it should return copied
windowBounds/windowInsets instead of the exact cached objects, in case
that if there is any calculation or changes on the returned bounds/insets
the value in windowManger would be changed and thus affect the tests.

Bug: 431922747
Flag: EXEMPT test fix
Test: atest systemui/accessibility/*
Change-Id: Ib53928e86b1b86ddf8fba3bfa18dee02542209eb
parent 9f757ebe
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -85,10 +85,15 @@ public class TestableWindowManager implements WindowManager {
    @Override
    public WindowMetrics getCurrentWindowMetrics() {
        final WindowMetrics realMetrics = mWindowManager.getCurrentWindowMetrics();
        final Rect windowBounds = mWindowBounds == null
                ? realMetrics.getBounds()
                : mWindowBounds;
        final WindowInsets windowInsets = mWindowInsets == null
                ? realMetrics.getWindowInsets()
                : mWindowInsets;
        final WindowMetrics windowMetrics = new WindowMetrics(
                mWindowBounds == null ? realMetrics.getBounds()
                        : mWindowBounds,
                mWindowInsets == null ?  realMetrics.getWindowInsets() : mWindowInsets);
                new Rect(windowBounds),
                new WindowInsets(windowInsets));
        return windowMetrics;
    }