From 1ca61eb5a7ebd4945021df23e28176ca0ba0fbe8 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 24 Sep 2022 19:16:57 -0400 Subject: [PATCH] Suppress DeadObjectException --- .../java/be/mygod/vpnhotspot/util/KillableTileService.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/KillableTileService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/KillableTileService.kt index 53142e11..2cbf8ff5 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/KillableTileService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/KillableTileService.kt @@ -4,6 +4,7 @@ import android.content.ComponentName import android.content.Intent import android.content.ServiceConnection import android.os.Build +import android.os.DeadObjectException import android.os.IBinder import android.service.quicksettings.Tile import android.service.quicksettings.TileService @@ -28,5 +29,9 @@ abstract class KillableTileService : TileService(), ServiceConnection { } } - override fun onBind(intent: Intent?) = super.onBind(intent).also { BootReceiver.startIfEnabled() } + override fun onBind(intent: Intent?) = try { + super.onBind(intent) + } catch (_: DeadObjectException) { + null + }.also { BootReceiver.startIfEnabled() } }