From fd6feee294460eb42746fb2ec010b2efe6057835 Mon Sep 17 00:00:00 2001 From: Kyujin Cho Date: Sat, 20 Jan 2024 15:18:05 +0900 Subject: [PATCH] fix: app crashing on latest beta --- .../java/dev/bluehouse/enablevolte/Moder.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/dev/bluehouse/enablevolte/Moder.kt b/app/src/main/java/dev/bluehouse/enablevolte/Moder.kt index 00c8228..19fb1c4 100644 --- a/app/src/main/java/dev/bluehouse/enablevolte/Moder.kt +++ b/app/src/main/java/dev/bluehouse/enablevolte/Moder.kt @@ -15,6 +15,7 @@ import com.android.internal.telephony.IPhoneSubInfo import com.android.internal.telephony.ISub import com.android.internal.telephony.ITelephony import rikka.shizuku.ShizukuBinderWrapper +import java.lang.IllegalArgumentException private const val TAG = "CarrierModer" @@ -78,7 +79,21 @@ open class Moder { class CarrierModer(private val context: Context) : Moder() { val subscriptions: List - get() = this.loadCachedInterface { sub }.getActiveSubscriptionInfoList(null, null) + get() { + val sub = this.loadCachedInterface { sub } + try { + return sub.getActiveSubscriptionInfoList(null, null) + } catch (e: IllegalArgumentException) { + val getActiveSubscriptionInfoListMethod = sub.javaClass.getMethod( + "getActiveSubscriptionInfoListMethod", + String.Companion::class.java, + String.Companion::class.java, + Boolean.Companion::class.java, + ) + // FIXME: lift up reflect as soon as official source code releases + return (getActiveSubscriptionInfoListMethod.invoke(sub, null, null, null) as List) + } + } val defaultSubId: Int get() {