From 28b1a1a0fc6a7172161c8a1f846fb20d1d7aa624 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 24 Sep 2022 19:21:29 -0400 Subject: [PATCH] Suppress more DeadObjectException --- .../main/java/be/mygod/vpnhotspot/net/TetheringManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt index 11eac3d9..036b5e13 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt @@ -10,6 +10,7 @@ import android.content.pm.PackageManager import android.net.ConnectivityManager import android.net.Network import android.os.Build +import android.os.DeadObjectException import android.os.Handler import androidx.annotation.RequiresApi import androidx.core.os.ExecutorCompat @@ -583,7 +584,11 @@ object TetheringManager { @RequiresApi(30) fun unregisterTetheringEventCallback(callback: TetheringEventCallback) { val proxy = synchronized(callbackMap) { callbackMap.remove(callback) } ?: return - unregisterTetheringEventCallback(instance, proxy) + try { + unregisterTetheringEventCallback(instance, proxy) + } catch (e: InvocationTargetException) { + if (!e.targetException.let { it is IllegalStateException && it.cause is DeadObjectException }) throw e + } } /**