From f575a7a1a903dd7ee9958c6c88f500d79468202a Mon Sep 17 00:00:00 2001 From: Jarvis Huang Date: Fri, 29 Oct 2021 12:21:52 +0800 Subject: [PATCH] ipc/android: Remove watchdog delay if surface comes from client When surface comes from client, it's not reuseable after client exits. Removing the timeout so runtime can release all the graphcis resources associated with surface. --- .../main/java/org/freedesktop/monado/ipc/MonadoService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt b/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt index fa319c3e1..2d87bdd22 100644 --- a/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt +++ b/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt @@ -27,7 +27,7 @@ import javax.inject.Inject class MonadoService : Service(), Watchdog.ShutdownListener { private lateinit var binder: MonadoImpl - private val watchdog = Watchdog(BuildConfig.WATCHDOG_TIMEOUT_MILLISECONDS, this) + private lateinit var watchdog: Watchdog @Inject lateinit var serviceNotification: IServiceNotification @@ -39,6 +39,12 @@ class MonadoService : Service(), Watchdog.ShutdownListener { surfaceManager = SurfaceManager(this) binder = MonadoImpl(surfaceManager) + watchdog = Watchdog( + // If the surface comes from client, just stop the service when client disconnected + // because the surface belongs to the client. + if (surfaceManager.canDrawOverlays()) BuildConfig.WATCHDOG_TIMEOUT_MILLISECONDS else 0, + this + ) watchdog.startMonitor() // start the service so it could be foregrounded