Merge "Update surface position once created." into pi-dev am: 8a4af9c3e8
am: 85602dae12
Change-Id: I184b4d9545b11498b891e7442c3b92b4b27a3b59
This commit is contained in:
@@ -751,8 +751,9 @@ public class TaskStack extends WindowContainer<Task> implements
|
||||
* Used to make room for shadows in the pinned windowing mode.
|
||||
*/
|
||||
int getStackOutset() {
|
||||
if (inPinnedWindowingMode()) {
|
||||
final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
|
||||
DisplayContent displayContent = getDisplayContent();
|
||||
if (inPinnedWindowingMode() && displayContent != null) {
|
||||
final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();
|
||||
|
||||
// We multiply by two to match the client logic for converting view elevation
|
||||
// to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
|
||||
|
||||
@@ -183,6 +183,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
// build a surface.
|
||||
mSurfaceControl = makeSurface().build();
|
||||
getPendingTransaction().show(mSurfaceControl);
|
||||
updateSurfacePosition();
|
||||
} else {
|
||||
// If we have a surface but a new parent, we just need to perform a reparent. Go through
|
||||
// surface animator such that hierarchy is preserved when animating, i.e.
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.android.server.wm;
|
||||
|
||||
import android.support.test.filters.FlakyTest;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.SurfaceSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -43,6 +45,9 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyFloat;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -107,6 +112,21 @@ public class WindowContainerTests extends WindowTestsBase {
|
||||
assertTrue(layer0.mOnParentSetCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddChildSetsSurfacePosition() throws Exception {
|
||||
MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer();
|
||||
|
||||
final SurfaceControl.Transaction transaction = mock(SurfaceControl.Transaction.class);
|
||||
sWm.mTransactionFactory = () -> transaction;
|
||||
|
||||
WindowContainer child = new WindowContainer(sWm);
|
||||
child.setBounds(1, 1, 10, 10);
|
||||
|
||||
verify(transaction, never()).setPosition(any(), anyFloat(), anyFloat());
|
||||
top.addChild(child, 0);
|
||||
verify(transaction, times(1)).setPosition(any(), eq(1.f), eq(1.f));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdd_AlreadyHasParent() throws Exception {
|
||||
final TestWindowContainerBuilder builder = new TestWindowContainerBuilder();
|
||||
@@ -825,4 +845,28 @@ public class WindowContainerTests extends WindowTestsBase {
|
||||
return new TestWindowContainer(mLayer, mIsAnimating, mIsVisible, mOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
private class MockSurfaceBuildingContainer extends WindowContainer<WindowContainer> {
|
||||
final SurfaceSession mSession = new SurfaceSession();
|
||||
|
||||
MockSurfaceBuildingContainer() {
|
||||
super(sWm);
|
||||
}
|
||||
|
||||
class MockSurfaceBuilder extends SurfaceControl.Builder {
|
||||
MockSurfaceBuilder(SurfaceSession ss) {
|
||||
super(ss);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceControl build() {
|
||||
return mock(SurfaceControl.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
SurfaceControl.Builder makeChildSurface(WindowContainer child) {
|
||||
return new MockSurfaceBuilder(mSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user