Skip to content

Commit 32eaa8a

Browse files
committed
feat: add override_config_persistent to config
1 parent 9ec43ff commit 32eaa8a

6 files changed

Lines changed: 16 additions & 18 deletions

File tree

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ class BrokerInstrumentation : Instrumentation() {
2626
val configurationManager = this.context.getSystemService(CarrierConfigManager::class.java)
2727

2828
try {
29-
return configurationManager.overrideConfig(subId, overrideValues, true)
30-
} catch (e: SecurityException) {
31-
} catch (e: NoSuchMethodError) {
32-
}
33-
34-
try {
35-
return configurationManager.overrideConfig(subId, overrideValues, false)
36-
} catch (e: SecurityException) {
29+
return configurationManager.overrideConfig(subId, overrideValues, overrideConfigPersistent)
3730
} catch (e: NoSuchMethodError) {
3831
}
3932

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import android.os.Build
99
import android.os.Build.VERSION_CODES
1010
import android.os.Bundle
1111
import android.os.IInterface
12+
import android.os.PersistableBundle
1213
import android.telephony.CarrierConfigManager
1314
import android.telephony.SubscriptionInfo
1415
import android.telephony.TelephonyFrameworkInitializer
1516
import android.util.Log
1617
import androidx.annotation.RequiresApi
18+
import androidx.compose.runtime.getValue
19+
import androidx.compose.runtime.mutableStateOf
20+
import androidx.compose.runtime.setValue
1721
import com.android.internal.telephony.ICarrierConfigLoader
1822
import com.android.internal.telephony.IPhoneSubInfo
1923
import com.android.internal.telephony.ISub
@@ -27,6 +31,8 @@ object InterfaceCache {
2731
val cache = HashMap<String, IInterface>()
2832
}
2933

34+
var overrideConfigPersistent by mutableStateOf(true)
35+
3036
open class Moder {
3137
@Suppress("ktlint:standard:property-naming")
3238
val KEY_IMS_USER_AGENT = "ims.ims_user_agent_string"
@@ -140,22 +146,13 @@ class SubscriptionModer(
140146
var noSuchMethodError: NoSuchMethodError? = null
141147

142148
try {
143-
return iCclInstance.overrideConfig(subscriptionId, args, true)
149+
return iCclInstance.overrideConfig(subscriptionId, args, overrideConfigPersistent)
144150
} catch (e: SecurityException) {
145151
securityException = e
146152
} catch (e: NoSuchMethodError) {
147153
noSuchMethodError = e
148154
}
149155

150-
try {
151-
iCclInstance.overrideConfig(subscriptionId, args, false)
152-
throw securityException ?: noSuchMethodError!!
153-
} catch (e: SecurityException) {
154-
securityException = securityException ?: e
155-
} catch (e: NoSuchMethodError) {
156-
noSuchMethodError = noSuchMethodError ?: e
157-
}
158-
159156
val overrideConfigMethod =
160157
iCclInstance.javaClass.getMethod(
161158
"overrideConfig",

app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import dev.bluehouse.enablevolte.components.HeaderText
3535
import dev.bluehouse.enablevolte.components.InfiniteLoadingDialog
3636
import dev.bluehouse.enablevolte.components.RadioSelectPropertyView
3737
import dev.bluehouse.enablevolte.components.UserAgentPropertyView
38+
import dev.bluehouse.enablevolte.overrideConfigPersistent
3839
import kotlinx.coroutines.Dispatchers
3940
import kotlinx.coroutines.launch
4041
import kotlinx.coroutines.withContext
@@ -147,6 +148,10 @@ fun Config(
147148
InfiniteLoadingDialog()
148149
} else {
149150
Column(modifier = Modifier.padding(Dp(16f)).verticalScroll(scrollState)) {
151+
BooleanPropertyView(label = stringResource(R.string.override_config_persistent), toggled = overrideConfigPersistent) {
152+
overrideConfigPersistent = !overrideConfigPersistent
153+
}
154+
150155
HeaderText(text = stringResource(R.string.feature_toggles))
151156
BooleanPropertyView(label = stringResource(R.string.enable_volte), toggled = voLTEEnabled) {
152157
voLTEEnabled =

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@
8080
<string name="add_toggle_tile">VoLTE 設定の切り替えタイルを追加する</string>
8181
<string name="sim_config">SIM の設定</string>
8282
<string name="config_dump_viewer">設定ダンプビューワー</string>
83+
<string name="override_config_persistent">再起動後も変更を保持する (クラッシュ時はオフに)</string>
8384
</resources>

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@
8080
<string name="add_toggle_tile">添加 VoLTE 开关图块</string>
8181
<string name="sim_config">SIM 配置</string>
8282
<string name="config_dump_viewer">配置转储查看器</string>
83+
<string name="override_config_persistent">重启后保留修改 (崩溃时请关闭)</string>
8384
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@
7979
<string name="add_toggle_tile">Add VoLTE config toggle tile</string>
8080
<string name="sim_config">SIM Config</string>
8181
<string name="config_dump_viewer">Config Dump Viewer</string>
82+
<string name="override_config_persistent">Persist Changes across Reboot (Turn Off on Crash)</string>
8283
</resources>

0 commit comments

Comments
 (0)