x1ongzhu 1 rok temu
rodzic
commit
c27b7f1d28

+ 19 - 0
app/src/main/java/com/example/modifier/Global.kt

@@ -1,5 +1,6 @@
 package com.example.modifier
 
+import android.annotation.SuppressLint
 import android.content.Context
 import android.os.Build
 import android.util.Log
@@ -94,6 +95,13 @@ object Global {
             }
 
             Utils.runAsRoot(
+                "setprop persist.spoof.mcc ${telephonyConfig.mcc}",
+                "setprop persist.spoof.mnc ${telephonyConfig.mnc}",
+                "setprop persist.spoof.number ${telephonyConfig.number}",
+                "setprop persist.spoof.country ${telephonyConfig.country}",
+                "setprop persist.spoof.iccid ${telephonyConfig.iccid}",
+                "setprop persist.spoof.imei ${telephonyConfig.imei}",
+                "setprop persist.spoof.imsi ${telephonyConfig.imsi}",
                 "cp " + file.path + " /data/data/com.android.phone/rcsConfig.json",
                 "echo 'copied to phone'",
                 "chmod 777 /data/data/com.android.phone/rcsConfig.json",
@@ -329,4 +337,15 @@ object Global {
             e.printStackTrace()
         }
     }
+
+    @JvmStatic
+    fun killPhoneProcess(){
+        try {
+            Utils.runAsRoot(
+                "pidof com.android.phone | xargs kill -9",
+            )
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
 }

+ 4 - 0
app/src/main/java/com/example/modifier/MainActivity.kt

@@ -2,6 +2,7 @@ package com.example.modifier
 
 import android.content.DialogInterface
 import android.content.Intent
+import android.os.Build
 import android.os.Bundle
 import android.provider.Settings
 import androidx.activity.enableEdgeToEdge
@@ -48,6 +49,9 @@ class MainActivity : AppCompatActivity() {
                     "settings put global transition_animation_scale 0.0",
                     "settings put global animator_duration_scale 0.0"
                 )
+                if (Build.MODEL.startsWith("SM-F707") || Build.MODEL.startsWith("SM-F711")) {
+                    Global.killPhoneProcess()
+                }
             } else {
                 withContext(Dispatchers.Main) {
                     MaterialAlertDialogBuilder(this@MainActivity)

+ 7 - 0
app/src/main/java/com/example/modifier/http/api/ChannelApi.kt

@@ -0,0 +1,7 @@
+package com.example.modifier.http.api
+
+import io.ktor.resources.Resource
+
+@Resource("api/channel")
+class ChannelApi {
+}

+ 1 - 1
app/src/main/java/com/example/modifier/http/RcsNumberApi.kt → app/src/main/java/com/example/modifier/http/api/RcsNumberApi.kt

@@ -1,4 +1,4 @@
-package com.example.modifier.http
+package com.example.modifier.http.api
 
 import io.ktor.resources.Resource
 

+ 1 - 1
app/src/main/java/com/example/modifier/http/SysConfigApi.kt → app/src/main/java/com/example/modifier/http/api/SysConfigApi.kt

@@ -1,4 +1,4 @@
-package com.example.modifier.http
+package com.example.modifier.http.api
 
 import io.ktor.resources.Resource
 

+ 5 - 1
app/src/main/java/com/example/modifier/http/request/RcsNumberRequest.kt

@@ -3,4 +3,8 @@ package com.example.modifier.http.request
 import kotlinx.serialization.Serializable
 
 @Serializable
-data class RcsNumberRequest(val deviceId: String, val taskId: Int? = null)
+data class RcsNumberRequest(
+    val deviceId: String,
+    val taskId: Int? = null,
+    val channelId: Int? = null
+)

+ 8 - 0
app/src/main/java/com/example/modifier/http/response/GetChannelListResponse.kt

@@ -0,0 +1,8 @@
+package com.example.modifier.http.response
+
+import com.example.modifier.model.Channel
+import com.example.modifier.model.ListMeta
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class GetChannelListResponse(val items: List<Channel>, val meta: ListMeta)

+ 12 - 0
app/src/main/java/com/example/modifier/model/Channel.kt

@@ -0,0 +1,12 @@
+package com.example.modifier.model
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class Channel(
+    val id: Int,
+    val mcc: String,
+    val mnc: String,
+    val country: String,
+    val operator: String,
+)

+ 12 - 0
app/src/main/java/com/example/modifier/model/ListMeta.kt

@@ -0,0 +1,12 @@
+package com.example.modifier.model
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class ListMeta(
+    val currentPage: Int,
+    val itemCount: Int,
+    val itemsPerPage: Int,
+    val totalItems: Int,
+    val totalPages: Int
+)

+ 1 - 4
app/src/main/java/com/example/modifier/service/ModifierService.kt

@@ -39,9 +39,8 @@ import com.example.modifier.TraverseResult
 import com.example.modifier.Utils
 import com.example.modifier.databinding.FloatingWindowBinding
 import com.example.modifier.enums.RcsConfigureState
-import com.example.modifier.extension.waitUntilValueIs
 import com.example.modifier.http.KtorClient
-import com.example.modifier.http.RcsNumberApi
+import com.example.modifier.http.api.RcsNumberApi
 import com.example.modifier.http.request.RcsNumberRequest
 import com.example.modifier.http.response.RcsNumberResponse
 import com.example.modifier.model.TelephonyConfig
@@ -63,7 +62,6 @@ import kotlinx.coroutines.launch
 import kotlinx.coroutines.runBlocking
 import kotlinx.coroutines.suspendCancellableCoroutine
 import kotlinx.coroutines.withContext
-import kotlinx.coroutines.withTimeout
 import kotlinx.coroutines.withTimeoutOrNull
 import org.apache.commons.collections4.queue.CircularFifoQueue
 import org.apache.commons.lang3.RandomStringUtils
@@ -76,7 +74,6 @@ import java.util.concurrent.ScheduledExecutorService
 import java.util.concurrent.ScheduledThreadPoolExecutor
 import java.util.concurrent.TimeUnit
 import java.util.concurrent.atomic.AtomicReference
-import kotlin.coroutines.coroutineContext
 import kotlin.coroutines.resume
 import kotlin.math.max
 import kotlin.math.min

+ 44 - 6
app/src/main/java/com/example/modifier/ui/settings/SettingsFragment.kt

@@ -12,7 +12,6 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.widget.Toast
-import androidx.core.content.ContextCompat
 import androidx.fragment.app.Fragment
 import androidx.lifecycle.lifecycleScope
 import com.example.modifier.Global
@@ -26,26 +25,32 @@ import com.example.modifier.R
 import com.example.modifier.Utils
 import com.example.modifier.databinding.FragmentSettingsBinding
 import com.example.modifier.http.KtorClient
-import com.example.modifier.http.RcsNumberApi
+import com.example.modifier.http.api.ChannelApi
+import com.example.modifier.http.api.RcsNumberApi
 import com.example.modifier.http.request.RcsNumberRequest
+import com.example.modifier.http.response.GetChannelListResponse
 import com.example.modifier.http.response.RcsNumberResponse
+import com.example.modifier.model.Channel
 import com.example.modifier.model.TelephonyConfig
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.google.gson.Gson
 import io.ktor.client.call.body
 import io.ktor.client.plugins.resources.get
 import io.ktor.client.plugins.resources.put
+import io.ktor.client.plugins.resources.post
+import io.ktor.client.request.post
 import io.ktor.client.request.setBody
+import io.ktor.client.statement.bodyAsText
 import io.ktor.http.ContentType
 import io.ktor.http.contentType
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 import kotlinx.coroutines.withTimeout
 import org.apache.commons.lang3.RandomStringUtils
 import org.apache.commons.lang3.StringUtils
 import org.apache.commons.validator.routines.UrlValidator
-import java.io.File
-import java.io.FileWriter
 import java.time.LocalDateTime
 import java.time.temporal.ChronoUnit
 import java.util.Objects
@@ -59,6 +64,8 @@ class SettingsFragment : Fragment() {
 
     var handler: Handler = Handler(Looper.getMainLooper())
     var executor: ScheduledThreadPoolExecutor = ScheduledThreadPoolExecutor(8)
+    var channels: List<Channel> = emptyList()
+    var channelId: Int? = null
 
     init {
         Log.i("SettingsFragment", "SettingsFragment")
@@ -136,10 +143,12 @@ class SettingsFragment : Fragment() {
                     contentType(ContentType.Application.Json)
                     setBody(
                         RcsNumberRequest(
-                            deviceId = Utils.getUniqueID()
+                            deviceId = Utils.getUniqueID(),
+                            channelId = channelId
                         )
                     )
                 }
+                Log.i(TAG, "response: ${response.bodyAsText()}")
                 var res = response.body<RcsNumberResponse>()
                 val id = res.id
                 val expiryTime = res.expiryTime
@@ -240,6 +249,35 @@ class SettingsFragment : Fragment() {
             }
         }
 
+        CoroutineScope(Dispatchers.IO).launch {
+            try {
+                val response = KtorClient.post(
+                    ChannelApi()
+                ) {
+                    contentType(ContentType.Application.Json)
+                }
+                Log.i(TAG, "response: ${response.bodyAsText()}")
+                val res = response.body<GetChannelListResponse>()
+                channels = res.items
+                withContext(Dispatchers.Main) {
+                    if (isAdded) {
+                        binding.etChannel.threshold = 1000
+                        binding.etChannel.setSimpleItems(res.items.map { "${it.country}-${it.mcc}-${it.mnc}-${it.operator}" }
+                            .toTypedArray())
+                        binding.etChannel.setOnItemClickListener { parent, view, position, id ->
+                            val channel = channels[position]
+                            binding.etMcc.setText(channel.mcc)
+                            binding.etMnc.setText(channel.mnc)
+                            binding.etCountry.setText(channel.country)
+                            channelId = channel.id
+                        }
+                    }
+                }
+            } catch (e: Exception) {
+                e.printStackTrace()
+            }
+        }
+
         return binding.root
     }
 

+ 16 - 0
app/src/main/res/layout/fragment_settings.xml

@@ -100,9 +100,24 @@
                             android:textSize="14sp"
                             android:textStyle="bold" />
 
+                        <com.google.android.material.textfield.TextInputLayout
+                            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            android:hint="Channel">
+
+                            <com.google.android.material.textfield.MaterialAutoCompleteTextView
+                                android:id="@+id/et_channel"
+                                android:layout_width="match_parent"
+                                android:layout_height="wrap_content"
+                                android:inputType="none" />
+
+                        </com.google.android.material.textfield.TextInputLayout>
+
                         <LinearLayout
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
+                            android:layout_marginTop="16dp"
                             android:orientation="horizontal">
 
                             <com.google.android.material.textfield.TextInputLayout
@@ -215,6 +230,7 @@
                                 android:lines="1" />
                         </com.google.android.material.textfield.TextInputLayout>
 
+
                         <LinearLayout
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"