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
This commit is contained in:
Diego Vela
2021-10-15 09:47:10 -07:00
parent 6717096333
commit ca79b467c7

View File

@@ -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());
}
/**