Skip to content

Commit

Permalink
Implement ISO country code overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
nullbytepl committed Jan 25, 2024
1 parent fbe391f commit ba737e4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "gay.nullby.carriername"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/java/gay/nullby/carriername/TargetFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.widget.Toast
import com.android.internal.telephony.ICarrierConfigLoader
import gay.nullby.carriername.databinding.FragmentTargetBinding
import rikka.shizuku.ShizukuBinderWrapper
import java.util.Locale

class TargetFragment : Fragment() {
private val TAG: String = "TargetFragment"
Expand Down Expand Up @@ -64,24 +65,39 @@ class TargetFragment : Fragment() {
view.findViewById<View>(R.id.sub2_button).visibility = View.GONE
}

view.findViewById<Button>(R.id.button_set).setOnClickListener { onSetName(view.findViewById<EditText>(R.id.text_entry).text.toString()) }
view.findViewById<Button>(R.id.button_set).setOnClickListener { onSetName(view.findViewById<EditText>(R.id.text_entry).text.toString(), view.findViewById<EditText>(R.id.iso_region_input).text.toString()) }

view.findViewById<Button>(R.id.button_reset).setOnClickListener {
onResetName()
view.findViewById<EditText>(R.id.text_entry).setText("")
view.findViewById<EditText>(R.id.iso_region_input).setText("")
}

view.findViewById<RadioGroup>(R.id.sub_selection).setOnCheckedChangeListener { _, checkedId -> onSelectSub(checkedId) }

onSelectSub(0)
}

private fun onSetName(text: String) {
Toast.makeText(context, "Set carrier vanity name to \"$text\"", Toast.LENGTH_SHORT).show()
private fun onSetName(text: String, isoRegion: String) {
var p = PersistableBundle();
if (isoRegion.isNotEmpty()) {
if (isoRegion.length == 2) {
p.putString(CarrierConfigManager.KEY_SIM_COUNTRY_ISO_OVERRIDE_STRING, isoRegion.lowercase(
Locale.ROOT
)
)
} else {
Toast.makeText(context, "Invalid ISO region!", Toast.LENGTH_SHORT).show()
return
}
}
Toast.makeText(context, "Set carrier vanity name to \"$text\"", Toast.LENGTH_SHORT).show()

p.putBoolean(CarrierConfigManager.KEY_CARRIER_NAME_OVERRIDE_BOOL, true)
p.putString(CarrierConfigManager.KEY_CARRIER_NAME_STRING, text)
p.putString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING, /* trans rights! 🏳️‍⚧️*/ ":3")
p.putBoolean(CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL, true)

val subId: Int;
if (selectedSub == 1) {
subId = subId1!!
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/layout/fragment_target.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="hate crime"
android:hint="Vanity network name"
android:inputType="text"
android:paddingTop="16dp" />

<EditText
android:id="@+id/iso_region_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="ISO country code (leave empty to leave unchanged)"
android:inputType="text"
android:paddingTop="16dp" />

Expand Down

0 comments on commit ba737e4

Please sign in to comment.