Skip to content

Commit

Permalink
fix: app crashing on latest beta
Browse files Browse the repository at this point in the history
  • Loading branch information
kyujin-cho committed Jan 20, 2024
1 parent 89e628c commit fd6feee
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/java/dev/bluehouse/enablevolte/Moder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -78,7 +79,21 @@ open class Moder {

class CarrierModer(private val context: Context) : Moder() {
val subscriptions: List<SubscriptionInfo>
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<SubscriptionInfo>)
}
}

val defaultSubId: Int
get() {
Expand Down

0 comments on commit fd6feee

Please sign in to comment.