diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca3199c --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/app/release +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..7c28446 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Carrier Vanity Name \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..a9f4e52 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..54d5acd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7288e65 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Carrier Vanity Name +Carrier Vanity Name is a very simple app to change the carrier names on unrooted Android devices. + +The changed names will persist through reboots. To revert them back, click the reset button in the app. + +The app uses [Shizuku](https://shizuku.rikka.app/) to achieve this using carrier config overrides. This method was inspired by Kyujin Cho's [pixel-volte-patch](https://github.com/kyujin-cho/pixel-volte-patch), which uses the same method to enable VoLTE on some Google Pixel and LG devices. + +**WARNING**: Anything using Shizuku might potentially cause harm to your device (and the data on it). I'm not responsible for any damage that might be caused by this app. +You have been warned. + +[You can download a prebuilt APK here](https://github.com/nullbytepl/CarrierVanityName) \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..6fb8196 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,55 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'gay.nullby.carriername' + compileSdk 33 + + defaultConfig { + applicationId "gay.nullby.carriername" + minSdk 28 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + viewBinding true + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1' + implementation 'androidx.navigation:navigation-ui-ktx:2.4.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + def shizuku_version = "13.1.0" + implementation "dev.rikka.shizuku:api:$shizuku_version" + implementation "dev.rikka.shizuku:provider:$shizuku_version" + + implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/gay/nullby/carriername/ExampleInstrumentedTest.kt b/app/src/androidTest/java/gay/nullby/carriername/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..2043b01 --- /dev/null +++ b/app/src/androidTest/java/gay/nullby/carriername/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package gay.nullby.carriername + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("gay.nullby.carriername", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..3afcd17 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/gay/nullby/carriername/MainActivity.kt b/app/src/main/java/gay/nullby/carriername/MainActivity.kt new file mode 100644 index 0000000..6163258 --- /dev/null +++ b/app/src/main/java/gay/nullby/carriername/MainActivity.kt @@ -0,0 +1,42 @@ +package gay.nullby.carriername + +import android.os.Build +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.WindowCompat +import androidx.navigation.findNavController +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.navigateUp +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.annotation.RequiresApi +import gay.nullby.carriername.databinding.ActivityMainBinding +import org.lsposed.hiddenapibypass.HiddenApiBypass + +class MainActivity : AppCompatActivity() { + + private lateinit var appBarConfiguration: AppBarConfiguration + private lateinit var binding: ActivityMainBinding + + override fun onCreate(savedInstanceState: Bundle?) { + WindowCompat.setDecorFitsSystemWindows(window, false) + super.onCreate(savedInstanceState) + + HiddenApiBypass.addHiddenApiExemptions("L") + HiddenApiBypass.addHiddenApiExemptions("I") + + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) + + setSupportActionBar(binding.toolbar) + + val navController = findNavController(R.id.nav_host_fragment_content_main) + appBarConfiguration = AppBarConfiguration(navController.graph) + setupActionBarWithNavController(navController, appBarConfiguration) + } + + override fun onSupportNavigateUp(): Boolean { + val navController = findNavController(R.id.nav_host_fragment_content_main) + return navController.navigateUp(appBarConfiguration) + || super.onSupportNavigateUp() + } +} \ No newline at end of file diff --git a/app/src/main/java/gay/nullby/carriername/SetupFragment.kt b/app/src/main/java/gay/nullby/carriername/SetupFragment.kt new file mode 100644 index 0000000..05bc594 --- /dev/null +++ b/app/src/main/java/gay/nullby/carriername/SetupFragment.kt @@ -0,0 +1,64 @@ +package gay.nullby.carriername + +import android.content.pm.PackageManager +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.navigation.fragment.findNavController +import gay.nullby.carriername.databinding.FragmentSetupBinding +import rikka.shizuku.Shizuku + +class SetupFragment : Fragment() { + + private var _binding: FragmentSetupBinding? = null + + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + _binding = FragmentSetupBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + if (Shizuku.getBinder() != null) { + // Shizuku is already bound + handleShizukuConnected() + } else { + Shizuku.addBinderReceivedListener { + // Shizuku connects after some time + handleShizukuConnected() + } + } + + Shizuku.addRequestPermissionResultListener { _, grantResult -> + if (grantResult == PackageManager.PERMISSION_GRANTED) { + findNavController().navigate(R.id.action_setup_to_target) + } + } + + binding.buttonFirst.setOnClickListener { + Shizuku.requestPermission(0) + } + } + + private fun handleShizukuConnected() { + if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) { + findNavController().navigate(R.id.action_setup_to_target) + } else { + binding.buttonFirst.isEnabled = true + } + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + +} \ No newline at end of file diff --git a/app/src/main/java/gay/nullby/carriername/TargetFragment.kt b/app/src/main/java/gay/nullby/carriername/TargetFragment.kt new file mode 100644 index 0000000..d7544c4 --- /dev/null +++ b/app/src/main/java/gay/nullby/carriername/TargetFragment.kt @@ -0,0 +1,141 @@ +package gay.nullby.carriername + +import android.content.Context +import android.os.Bundle +import android.os.PersistableBundle +import android.telephony.CarrierConfigManager +import android.telephony.SubscriptionManager +import android.telephony.TelephonyFrameworkInitializer +import android.telephony.TelephonyManager +import android.util.Log +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.EditText +import android.widget.RadioButton +import android.widget.RadioGroup +import android.widget.Toast +import com.android.internal.telephony.ICarrierConfigLoader +import gay.nullby.carriername.databinding.FragmentTargetBinding +import rikka.shizuku.ShizukuBinderWrapper + +class TargetFragment : Fragment() { + private val TAG: String = "TargetFragment" + + private var _binding: FragmentTargetBinding? = null + + private val binding get() = _binding!! + + private var subId1: Int = -1; + private var subId2: Int = -1; + + private var selectedSub: Int = 1; + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + + _binding = FragmentTargetBinding.inflate(inflater, container, false) + return binding.root + + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + var _subId1: IntArray? = SubscriptionManager.getSubId(0); + var _subId2: IntArray? = SubscriptionManager.getSubId(1); + + Log.d(TAG, "#onViewCreated(): subId1=$subId1 subId2=$subId2") + + if (_subId1 != null) { + subId1 = _subId1[0] + view.findViewById(R.id.sub1_button).text = "Network 1 (carrier: ${getCarrierNameBySubId(subId1)})" + } + if (_subId2 != null) { + subId2 = _subId2[0] + view.findViewById(R.id.sub2_button).text = "Network 2 (carrier: ${getCarrierNameBySubId(subId2)})" + } + + if (subId2 == -1) { + view.findViewById(R.id.sub2_button).visibility = View.GONE + } + + view.findViewById