Merge "Fix starting window leak when adding/removing quickly" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3047a5ea7a
@@ -107,7 +107,7 @@ public class AppWindowContainerController
|
|||||||
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Remove starting " + mContainer
|
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Remove starting " + mContainer
|
||||||
+ ": startingWindow=" + mContainer.startingWindow
|
+ ": startingWindow=" + mContainer.startingWindow
|
||||||
+ " startingView=" + mContainer.startingSurface);
|
+ " startingView=" + mContainer.startingSurface);
|
||||||
if (mContainer.startingWindow != null) {
|
if (mContainer.startingData != null) {
|
||||||
surface = mContainer.startingSurface;
|
surface = mContainer.startingSurface;
|
||||||
mContainer.startingData = null;
|
mContainer.startingData = null;
|
||||||
mContainer.startingSurface = null;
|
mContainer.startingSurface = null;
|
||||||
@@ -164,10 +164,9 @@ public class AppWindowContainerController
|
|||||||
if (surface != null) {
|
if (surface != null) {
|
||||||
boolean abort = false;
|
boolean abort = false;
|
||||||
synchronized(mWindowMap) {
|
synchronized(mWindowMap) {
|
||||||
if (container.removed || container.startingData == null) {
|
|
||||||
// If the window was successfully added, then
|
// If the window was successfully added, then
|
||||||
// we need to remove it.
|
// we need to remove it.
|
||||||
if (container.startingWindow != null) {
|
if (container.removed || container.startingData == null) {
|
||||||
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
|
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
|
||||||
"Aborted starting " + container
|
"Aborted starting " + container
|
||||||
+ ": removed=" + container.removed
|
+ ": removed=" + container.removed
|
||||||
@@ -175,7 +174,6 @@ public class AppWindowContainerController
|
|||||||
container.startingWindow = null;
|
container.startingWindow = null;
|
||||||
container.startingData = null;
|
container.startingData = null;
|
||||||
abort = true;
|
abort = true;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
container.startingSurface = surface;
|
container.startingSurface = surface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,18 +19,24 @@ package com.android.server.wm;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
|
import android.platform.test.annotations.SecurityTest;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import android.support.test.InstrumentationRegistry;
|
||||||
import android.support.test.filters.SmallTest;
|
import android.support.test.filters.SmallTest;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||||
import static android.content.res.Configuration.EMPTY;
|
import static android.content.res.Configuration.EMPTY;
|
||||||
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for {@link AppWindowContainerController}.
|
* Test class for {@link AppWindowContainerController}.
|
||||||
*
|
*
|
||||||
@@ -90,6 +96,9 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
|
|||||||
assertNull(atoken.startingSurface);
|
assertNull(atoken.startingSurface);
|
||||||
assertNull(atoken.startingWindow);
|
assertNull(atoken.startingWindow);
|
||||||
assertNull(atoken.startingData);
|
assertNull(atoken.startingData);
|
||||||
|
atoken.forAllWindows(windowState -> {
|
||||||
|
assertFalse(windowState.getBaseType() == TYPE_APPLICATION_STARTING);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -107,6 +116,22 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
|
|||||||
assertNoStartingWindow(atoken);
|
assertNoStartingWindow(atoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddRemoveRace() throws Exception {
|
||||||
|
|
||||||
|
// There was once a race condition between adding and removing starting windows
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
final WindowTestUtils.TestAppWindowContainerController controller =
|
||||||
|
createAppWindowController();
|
||||||
|
controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
|
||||||
|
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
|
||||||
|
false);
|
||||||
|
controller.removeStartingWindow();
|
||||||
|
waitUntilHandlersIdle();
|
||||||
|
assertNoStartingWindow(controller.getAppWindowToken(mDisplayContent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransferStartingWindow() throws Exception {
|
public void testTransferStartingWindow() throws Exception {
|
||||||
final WindowTestUtils.TestAppWindowContainerController controller1 =
|
final WindowTestUtils.TestAppWindowContainerController controller1 =
|
||||||
|
|||||||
Reference in New Issue
Block a user