From ca79b467c75a5f2c4f5e900f15f9c9b33afbc04e Mon Sep 17 00:00:00 2001 From: Diego Vela Date: Fri, 15 Oct 2021 09:47:10 -0700 Subject: [PATCH] Update SidecarProvider to pass Application Context. Use Application Context in SidecarProvider to avoid a memory leak. There is a memory leak when an Activity is used that does not handle configuration changes. The leak happens because the Activity may be captured and retained longer than desired. Bug: 202989046 Bug: 202250276 Test: manual - Use an activity that ignores configuration changes. Test: Install leak canary. Test: Subscribe to WindowLayoutInfo changes using an Activity. Test: Rotate the device a few times. Change-Id: I953d0cb39d21af00aad7044678e256d16b2d1c85 --- .../Jetpack/src/androidx/window/sidecar/SidecarProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java index e6f8388b031f2..e199b0820c8f5 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/sidecar/SidecarProvider.java @@ -28,7 +28,7 @@ public class SidecarProvider { * an OEM by overriding this method. */ public static SidecarInterface getSidecarImpl(Context context) { - return new SampleSidecarImpl(context); + return new SampleSidecarImpl(context.getApplicationContext()); } /**