Skip to content

Commit

Permalink
feat: add toggle to alter KEY_ALLOW_ADDING_APNS_BOOL (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyujin-cho authored May 28, 2023
1 parent 8bb5a43 commit 4af69b0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/dev/bluehouse/enablevolte/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ fun UserAgentPropertyView(label: String, value: String?, onUpdate: ((String) ->
Row(modifier = Modifier.align(Alignment.End)) {
TextButton(
onClick = {
onUpdate(typedText)
openTextEditDialog = false
},
) {
Text(stringResource(R.string.confirm))
Text(stringResource(R.string.dismiss))
}
TextButton(
onClick = {
onUpdate(typedText)
openTextEditDialog = false
},
) {
Text(stringResource(R.string.dismiss))
Text(stringResource(R.string.confirm))
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/dev/bluehouse/enablevolte/Moder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,32 @@ class SubscriptionModer(val subscriptionId: Int) : Moder() {
val isVoLteConfigEnabled: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL)

val isVonrConfigEnabled: Boolean
val isVoNrConfigEnabled: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_VONR_ENABLED_BOOL) &&
this.getBooleanValue(CarrierConfigManager.KEY_VONR_SETTING_VISIBILITY_BOOL)

val isCrosssimConfigEnabled: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL) &&
this.getBooleanValue(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL)
val isCrossSIMConfigEnabled: Boolean
get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
this.getBooleanValue(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL) &&
this.getBooleanValue(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL)
} else {
false
}
}

val isVoWifiConfigEnabled: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL)

val isVoWifiWhileRoamingEnabled: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_ENABLED_BOOL)

val showIMSinSIMinfo: Boolean
val showIMSinSIMInfo: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL)

val allowAddingAPNs: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL)

val showVoWifiMode: Boolean
get() = this.getBooleanValue(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL)

Expand Down
49 changes: 31 additions & 18 deletions app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.bluehouse.enablevolte.pages

import android.os.Build
import android.telephony.CarrierConfigManager
import android.widget.Toast
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -29,7 +30,6 @@ import dev.bluehouse.enablevolte.UserAgentPropertyView
import dev.bluehouse.enablevolte.ValueType
import dev.bluehouse.enablevolte.checkShizukuPermission
import java.lang.IllegalStateException
import java.util.*

@Composable
fun Config(navController: NavController, subId: Int) {
Expand All @@ -41,10 +41,11 @@ fun Config(navController: NavController, subId: Int) {
var configurable by rememberSaveable { mutableStateOf(false) }
var voLTEEnabled by rememberSaveable { mutableStateOf(false) }
var voNREnabled by rememberSaveable { mutableStateOf(false) }
var crosssimEnabled by rememberSaveable { mutableStateOf(false) }
var crossSIMEnabled by rememberSaveable { mutableStateOf(false) }
var voWiFiEnabled by rememberSaveable { mutableStateOf(false) }
var voWiFiEnabledWhileRoaming by rememberSaveable { mutableStateOf(false) }
var showIMSinSIMinfo by rememberSaveable { mutableStateOf(false) }
var showIMSinSIMInfo by rememberSaveable { mutableStateOf(false) }
var allowAddingAPNs by rememberSaveable { mutableStateOf(false) }
var showVoWifiMode by rememberSaveable { mutableStateOf(false) }
var showVoWifiRoamingMode by rememberSaveable { mutableStateOf(false) }
var showVoWifiInNetworkName by rememberSaveable { mutableStateOf(false) }
Expand All @@ -61,11 +62,12 @@ fun Config(navController: NavController, subId: Int) {

fun loadFlags() {
voLTEEnabled = moder.isVoLteConfigEnabled
voNREnabled = moder.isVonrConfigEnabled
crosssimEnabled = moder.isCrosssimConfigEnabled
voNREnabled = moder.isVoNrConfigEnabled
crossSIMEnabled = moder.isCrossSIMConfigEnabled
voWiFiEnabled = moder.isVoWifiConfigEnabled
voWiFiEnabledWhileRoaming = moder.isVoWifiWhileRoamingEnabled
showIMSinSIMinfo = moder.showIMSinSIMinfo
showIMSinSIMInfo = moder.showIMSinSIMInfo
allowAddingAPNs = moder.allowAddingAPNs
showVoWifiMode = moder.showVoWifiMode
showVoWifiRoamingMode = moder.showVoWifiRoamingMode
showVoWifiInNetworkName = (moder.showVoWifiInNetworkName == 1)
Expand Down Expand Up @@ -129,16 +131,18 @@ fun Config(navController: NavController, subId: Int) {
true
}
}
BooleanPropertyView(label = stringResource(R.string.enable_crosssim), toggled = crosssimEnabled) {
crosssimEnabled = if (crosssimEnabled) {
moder.updateCarrierConfig(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, false)
moder.updateCarrierConfig(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL, false)
false
} else {
moder.updateCarrierConfig(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, true)
moder.updateCarrierConfig(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL, true)
moder.restartIMSRegistration()
true
BooleanPropertyView(label = stringResource(R.string.enable_crosssim), toggled = crossSIMEnabled, enabled = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
crossSIMEnabled = if (crossSIMEnabled) {
moder.updateCarrierConfig(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, false)
moder.updateCarrierConfig(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL, false)
false
} else {
moder.updateCarrierConfig(CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, true)
moder.updateCarrierConfig(CarrierConfigManager.KEY_ENABLE_CROSS_SIM_CALLING_ON_OPPORTUNISTIC_DATA_BOOL, true)
moder.restartIMSRegistration()
true
}
}
}
BooleanPropertyView(label = stringResource(R.string.enable_vowifi), toggled = voWiFiEnabled) {
Expand Down Expand Up @@ -184,6 +188,15 @@ fun Config(navController: NavController, subId: Int) {
true
}
}
BooleanPropertyView(label = stringResource(R.string.allow_adding_apns), toggled = allowAddingAPNs) {
allowAddingAPNs = if (allowAddingAPNs) {
moder.updateCarrierConfig(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL, false)
false
} else {
moder.updateCarrierConfig(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL, true)
true
}
}

HeaderText(text = stringResource(R.string.string_values))
UserAgentPropertyView(label = stringResource(R.string.user_agent), value = configuredUserAgent) {
Expand Down Expand Up @@ -288,8 +301,8 @@ fun Config(navController: NavController, subId: Int) {
true
}
}
BooleanPropertyView(label = stringResource(R.string.show_ims_status_in_sim_status), toggled = showIMSinSIMinfo) {
showIMSinSIMinfo = if (showIMSinSIMinfo) {
BooleanPropertyView(label = stringResource(R.string.show_ims_status_in_sim_status), toggled = showIMSinSIMInfo) {
showIMSinSIMInfo = if (showIMSinSIMInfo) {
moder.updateCarrierConfig(CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL, false)
false
} else {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="show_vowifi_roaming_preference_in_settings">显示 VoWiFi漫游 选项</string>
<string name="add_wifi_calling_to_network_name">网络名中添加 \"Wi-Fi Calling\"</string>
<string name="show_ims_status_in_sim_status">在 SIM 信息中显示 IMS 状态</string>
<string name="allow_adding_apns">Allow adding APNs</string>
<string name="show_wifi_only_for_vowifi">VoWiFi 显示 \"仅WiFi\" 模式</string>
<string name="enable_video_calling_vt">启用视频通话(VT)</string>
<string name="enable_ss_over_ut">UT接口下启用补充业务</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="add_wifi_calling_to_network_name">Add \"Wi-Fi Calling\" to Network Name</string>
<string name="show_wifi_only_for_vowifi">Show \"WiFi only\" mode for VoWiFi</string>
<string name="enable_video_calling_vt">Enable Video Calling (VT)</string>
<string name="allow_adding_apns">Allow adding APNs</string>
<string name="enable_ss_over_ut">Enable Supplementary Services over UT</string>
<string name="enable_ss_over_cdma">Enable Supplementary Services over CDMA</string>
<string name="sim_detected">SIM Detected</string>
Expand Down

0 comments on commit 4af69b0

Please sign in to comment.