Merge "WindowProcessController: Fix potential memory leak" am: 447f3f2f22 am: 3826929d4c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2485123 Change-Id: I1db07266eaedeb05df080c0ae2bf3c43910ed9f4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1340,6 +1340,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
unregisterDisplayAreaConfigurationListener();
|
unregisterDisplayAreaConfigurationListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the WindwoProcessController, after the process has been removed.
|
||||||
|
*/
|
||||||
|
void destroy() {
|
||||||
|
unregisterConfigurationListeners();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if activity configuration override for the activity process needs an update and perform
|
* Check if activity configuration override for the activity process needs an update and perform
|
||||||
* if needed. By default we try to override the process configuration to match the top activity
|
* if needed. By default we try to override the process configuration to match the top activity
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package com.android.server.wm;
|
|||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
final class WindowProcessControllerMap {
|
final class WindowProcessControllerMap {
|
||||||
|
|
||||||
@@ -67,6 +67,7 @@ final class WindowProcessControllerMap {
|
|||||||
mPidMap.remove(pid);
|
mPidMap.remove(pid);
|
||||||
// remove process from mUidMap
|
// remove process from mUidMap
|
||||||
removeProcessFromUidMap(proc);
|
removeProcessFromUidMap(proc);
|
||||||
|
proc.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
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.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
@@ -129,4 +131,14 @@ public class WindowProcessControllerMapTests extends WindowTestsBase {
|
|||||||
assertEquals(uid2processes.size(), 1);
|
assertEquals(uid2processes.size(), 1);
|
||||||
assertEquals(mProcessMap.getProcess(FAKE_PID1), pid1uid2);
|
assertEquals(mProcessMap.getProcess(FAKE_PID1), pid1uid2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemove_callsDestroy() {
|
||||||
|
var proc = spy(pid1uid1);
|
||||||
|
mProcessMap.put(FAKE_PID1, proc);
|
||||||
|
|
||||||
|
mProcessMap.remove(FAKE_PID1);
|
||||||
|
|
||||||
|
verify(proc).destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ public class WindowProcessControllerTests extends WindowTestsBase {
|
|||||||
assertEquals(displayBounds, mWpc.getConfiguration().windowConfiguration.getBounds());
|
assertEquals(displayBounds, mWpc.getConfiguration().windowConfiguration.getBounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDestroy_unregistersDisplayAreaListener() {
|
||||||
|
final TestDisplayContent testDisplayContent1 = createTestDisplayContentInContainer();
|
||||||
|
final DisplayArea imeContainer1 = testDisplayContent1.getImeContainer();
|
||||||
|
mWpc.registerDisplayAreaConfigurationListener(imeContainer1);
|
||||||
|
|
||||||
|
mWpc.destroy();
|
||||||
|
|
||||||
|
assertNull(mWpc.getDisplayArea());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetRunningRecentsAnimation() {
|
public void testSetRunningRecentsAnimation() {
|
||||||
mWpc.setRunningRecentsAnimation(true);
|
mWpc.setRunningRecentsAnimation(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user