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

Commit 0c0fd656 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update Task surface position when bounds are changed"

parents bdda90fc 89f5c1de
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -316,6 +316,7 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta

        mRotation = rotation;

        updateSurfacePosition();
        return boundsChange;
    }

@@ -358,6 +359,7 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        } else {
            mOverrideDisplayedBounds.setEmpty();
        }
        updateSurfacePosition();
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.graphics.Point;
@@ -1331,6 +1332,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        mLastSurfacePosition.set(mTmpPos.x, mTmpPos.y);
    }

    @TestApi
    Point getLastSurfacePosition() {
        return mLastSurfacePosition;
    }

    /**
     * Displayed bounds specify where to display this container at. It differs from bounds during
     * certain operations (like animation or interactive dragging).
+17 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.graphics.Point;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;

import androidx.test.filters.SmallTest;
@@ -123,4 +125,19 @@ public class TaskTests extends WindowTestsBase {
        assertEquals(1, task2.positionInParent());
        assertTrue(task.mOnDisplayChangedCalled);
    }

    @Test
    public void testBounds() {
        final TaskStack stack1 = createTaskStackOnDisplay(mDisplayContent);
        final WindowTestUtils.TestTask task = WindowTestUtils.createTestTask(stack1);

        // Check that setting bounds also updates surface position
        Rect bounds = new Rect(10, 10, 100, 200);
        task.setBounds(bounds);
        assertEquals(new Point(bounds.left, bounds.top), task.getLastSurfacePosition());

        Rect dispBounds = new Rect(20, 30, 110, 220);
        task.setOverrideDisplayedBounds(dispBounds);
        assertEquals(new Point(dispBounds.left, dispBounds.top), task.getLastSurfacePosition());
    }
}