Skip to content

Commit 1c2a82e

Browse files
committed
fix: throw NoSuchMethodError in overrideConfig only if persistent=true
1 parent 32eaa8a commit 1c2a82e

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

app/src/main/java/dev/bluehouse/enablevolte/BrokerInstrumentation.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ class BrokerInstrumentation : Instrumentation() {
2626
val configurationManager = this.context.getSystemService(CarrierConfigManager::class.java)
2727

2828
try {
29-
return configurationManager.overrideConfig(subId, overrideValues, overrideConfigPersistent)
29+
configurationManager.overrideConfig(subId, overrideValues, overrideConfigPersistent)
3030
} catch (e: NoSuchMethodError) {
31+
configurationManager.overrideConfig(subId, overrideValues)
3132
}
32-
33-
configurationManager.overrideConfig(subId, overrideValues)
3433
} finally {
3534
am.stopDelegateShellPermissionIdentity()
3635
}

app/src/main/java/dev/bluehouse/enablevolte/Moder.kt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,21 @@ class SubscriptionModer(
142142
private fun overrideConfigDirectly(bundle: Bundle?) {
143143
val iCclInstance = this.loadCachedInterface { carrierConfigLoader }
144144
val args = bundle?.let(::toPersistableBundle)
145-
var securityException: SecurityException? = null
146-
var noSuchMethodError: NoSuchMethodError? = null
147145

148146
try {
149-
return iCclInstance.overrideConfig(subscriptionId, args, overrideConfigPersistent)
150-
} catch (e: SecurityException) {
151-
securityException = e
147+
iCclInstance.overrideConfig(subscriptionId, args, overrideConfigPersistent)
152148
} catch (e: NoSuchMethodError) {
153-
noSuchMethodError = e
149+
val overrideConfigMethod =
150+
iCclInstance.javaClass.getMethod(
151+
"overrideConfig",
152+
Int::class.javaPrimitiveType,
153+
PersistableBundle::class.java,
154+
)
155+
overrideConfigMethod.invoke(iCclInstance, subscriptionId, args)
156+
if (overrideConfigPersistent) {
157+
throw e
158+
}
154159
}
155-
156-
val overrideConfigMethod =
157-
iCclInstance.javaClass.getMethod(
158-
"overrideConfig",
159-
Int::class.javaPrimitiveType,
160-
PersistableBundle::class.java,
161-
)
162-
overrideConfigMethod.invoke(iCclInstance, subscriptionId, args)
163-
throw securityException ?: noSuchMethodError!!
164160
}
165161

166162
private fun overrideConfigUsingBroker(bundle: Bundle?) {
@@ -291,7 +287,6 @@ class SubscriptionModer(
291287
} catch (e: NoSuchMethodError) {
292288
telephony.disableIms(sub.getSlotIndex(this.subscriptionId))
293289
telephony.enableIms(sub.getSlotIndex(this.subscriptionId))
294-
throw e
295290
}
296291
}
297292

0 commit comments

Comments
 (0)