Merge "Update surface position once created." into pi-dev
am: 8a4af9c3e8
Change-Id: If8b087c21f5b3da6c701c03b814a081c8371c0d5
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.
|
* Used to make room for shadows in the pinned windowing mode.
|
||||||
*/
|
*/
|
||||||
int getStackOutset() {
|
int getStackOutset() {
|
||||||
if (inPinnedWindowingMode()) {
|
DisplayContent displayContent = getDisplayContent();
|
||||||
final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
|
if (inPinnedWindowingMode() && displayContent != null) {
|
||||||
|
final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();
|
||||||
|
|
||||||
// We multiply by two to match the client logic for converting view elevation
|
// We multiply by two to match the client logic for converting view elevation
|
||||||
// to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
|
// to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
|||||||
// build a surface.
|
// build a surface.
|
||||||
mSurfaceControl = makeSurface().build();
|
mSurfaceControl = makeSurface().build();
|
||||||
getPendingTransaction().show(mSurfaceControl);
|
getPendingTransaction().show(mSurfaceControl);
|
||||||
|
updateSurfacePosition();
|
||||||
} else {
|
} else {
|
||||||
// If we have a surface but a new parent, we just need to perform a reparent. Go through
|
// 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.
|
// surface animator such that hierarchy is preserved when animating, i.e.
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
import android.support.test.filters.FlakyTest;
|
import android.support.test.filters.FlakyTest;
|
||||||
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.SurfaceSession;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
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.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
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.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@@ -107,6 +112,21 @@ public class WindowContainerTests extends WindowTestsBase {
|
|||||||
assertTrue(layer0.mOnParentSetCalled);
|
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
|
@Test
|
||||||
public void testAdd_AlreadyHasParent() throws Exception {
|
public void testAdd_AlreadyHasParent() throws Exception {
|
||||||
final TestWindowContainerBuilder builder = new TestWindowContainerBuilder();
|
final TestWindowContainerBuilder builder = new TestWindowContainerBuilder();
|
||||||
@@ -825,4 +845,28 @@ public class WindowContainerTests extends WindowTestsBase {
|
|||||||
return new TestWindowContainer(mLayer, mIsAnimating, mIsVisible, mOrientation);
|
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