Merge "Fix WindowContext is removed unexpectedly" into sc-dev
This commit is contained in:
@@ -271,6 +271,21 @@ class WindowContextListenerController {
|
|||||||
if (mDeathRecipient == null) {
|
if (mDeathRecipient == null) {
|
||||||
throw new IllegalStateException("Invalid client token: " + mClientToken);
|
throw new IllegalStateException("Invalid client token: " + mClientToken);
|
||||||
}
|
}
|
||||||
|
final WindowToken windowToken = mContainer.asWindowToken();
|
||||||
|
if (windowToken != null && windowToken.isFromClient()) {
|
||||||
|
// If the WindowContext created WindowToken is removed by
|
||||||
|
// WMS#postWindowRemoveCleanupLocked, the WindowContext should switch back to
|
||||||
|
// listen to previous associated DisplayArea.
|
||||||
|
final DisplayContent dc = windowToken.mWmService.mRoot
|
||||||
|
.getDisplayContent(mLastReportedDisplay);
|
||||||
|
// If we cannot obtain the DisplayContent, the DisplayContent may also be removed.
|
||||||
|
// We should proceed the removal process.
|
||||||
|
if (dc != null) {
|
||||||
|
final DisplayArea da = dc.findAreaForToken(windowToken);
|
||||||
|
updateContainer(da);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
mDeathRecipient.unlinkToDeath();
|
mDeathRecipient.unlinkToDeath();
|
||||||
IWindowToken windowTokenClient = IWindowToken.Stub.asInterface(mClientToken);
|
IWindowToken windowTokenClient = IWindowToken.Stub.asInterface(mClientToken);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -17,8 +17,11 @@
|
|||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
|
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -162,6 +165,26 @@ public class WindowContextListenerControllerTests extends WindowTestsBase {
|
|||||||
false /* callerCanManagerAppTokens */, ANOTHER_UID);
|
false /* callerCanManagerAppTokens */, ANOTHER_UID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWindowContextCreatedWindowTokenRemoved_SwitchToListenToDA() {
|
||||||
|
WindowToken windowContextCreatedToken = new WindowToken.Builder(mWm, mClientToken,
|
||||||
|
TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY)
|
||||||
|
.setDisplayContent(mDefaultDisplay)
|
||||||
|
.setFromClientToken(true)
|
||||||
|
.build();
|
||||||
|
final DisplayArea da = windowContextCreatedToken.getDisplayArea();
|
||||||
|
|
||||||
|
mController.registerWindowContainerListener(mClientToken, windowContextCreatedToken,
|
||||||
|
TEST_UID, TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, null /* options */);
|
||||||
|
|
||||||
|
assertThat(mController.getContainer(mClientToken)).isEqualTo(windowContextCreatedToken);
|
||||||
|
|
||||||
|
// Remove WindowToken
|
||||||
|
windowContextCreatedToken.removeImmediately();
|
||||||
|
|
||||||
|
assertThat(mController.getContainer(mClientToken)).isEqualTo(da);
|
||||||
|
}
|
||||||
|
|
||||||
private class TestWindowTokenClient extends IWindowToken.Stub {
|
private class TestWindowTokenClient extends IWindowToken.Stub {
|
||||||
private Configuration mConfiguration;
|
private Configuration mConfiguration;
|
||||||
private int mDisplayId;
|
private int mDisplayId;
|
||||||
|
|||||||
Reference in New Issue
Block a user