Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9eee4075 authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Do not leak launcher context from the SettingsAwareViewCapture.

Bug: 273614966
Test: Ran MemoryTests.testAppLaunchFromWorkspace and
MemoryTests.testActivityRecreation and they both passed after this fix, and failed before this fix was implemented.

Change-Id: Ic8daad6436fea60fff96c1be735d0c1cfb2c991d
parent 0f4dce84
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -68,8 +68,9 @@ internal constructor(private val context: Context, choreographer: Choreographer,
        @JvmStatic
        fun getInstance(context: Context): ViewCapture = when {
            INSTANCE != null -> INSTANCE!!
            Looper.myLooper() == Looper.getMainLooper() -> SettingsAwareViewCapture(context,
                    Choreographer.getInstance(), createAndStartNewLooperExecutor("SAViewCapture",
            Looper.myLooper() == Looper.getMainLooper() -> SettingsAwareViewCapture(
                    context.applicationContext, Choreographer.getInstance(),
                    createAndStartNewLooperExecutor("SAViewCapture",
                    Process.THREAD_PRIORITY_FOREGROUND)).also { INSTANCE = it }
            else -> try {
                MAIN_EXECUTOR.submit { getInstance(context) }.get()