|
|
@@ -1,24 +1,27 @@
|
|
|
package com.example.modifier.utils
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
-import android.app.role.RoleManager
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.net.Uri
|
|
|
import android.os.Build
|
|
|
+import android.os.Environment
|
|
|
import android.telephony.SmsManager
|
|
|
import android.telephony.SmsMessage
|
|
|
import android.util.Log
|
|
|
import androidx.core.content.ContextCompat
|
|
|
import androidx.core.content.FileProvider.getUriForFile
|
|
|
import com.example.modifier.BuildConfig
|
|
|
-import com.example.modifier.MainActivity
|
|
|
import com.example.modifier.MainActivity.Companion.TAG
|
|
|
import com.example.modifier.Utils
|
|
|
+import com.example.modifier.constants.PACKAGE_CLEAN_SMS
|
|
|
import com.example.modifier.constants.PACKAGE_MESSAGING
|
|
|
import com.example.modifier.constants.PACKAGE_TELEPHONY
|
|
|
+import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.delay
|
|
|
+import kotlinx.coroutines.withContext
|
|
|
import java.io.File
|
|
|
+import java.io.FileOutputStream
|
|
|
|
|
|
fun injectOTP(otp: String) {
|
|
|
if (ROOT_ACCESS) {
|
|
|
@@ -120,21 +123,45 @@ suspend fun clearConv() {
|
|
|
)
|
|
|
resumePackage(PACKAGE_MESSAGING)
|
|
|
} else {
|
|
|
- shellRun("cmd role add-role-holder android.app.role.SMS com.example.cleansms")
|
|
|
-
|
|
|
val packageManager = context.packageManager
|
|
|
- packageManager.getLaunchIntentForPackage("com.example.cleansms")?.let {
|
|
|
+ try {
|
|
|
+ packageManager.getPackageInfo(PACKAGE_CLEAN_SMS, 0)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ Log.wtf(TAG, "clearConv: error", e)
|
|
|
+ val apkFile = File(
|
|
|
+ Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
|
|
|
+ "cleanSms.apk"
|
|
|
+ )
|
|
|
+ val fileOutputStream =
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
+ FileOutputStream(apkFile)
|
|
|
+ }
|
|
|
+ fileOutputStream.use {
|
|
|
+ context.assets.open("cleanSms.apk").copyTo(it)
|
|
|
+ Log.i(TAG, "clean sms apk copied to $apkFile")
|
|
|
+ shellRun(
|
|
|
+ "cp ${apkFile.path} /data/local/tmp/cleanSms.apk",
|
|
|
+ "pm install -r /data/local/tmp/cleanSms.apk", "sleep 1"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ packageManager.getLaunchIntentForPackage(PACKAGE_CLEAN_SMS)?.let {
|
|
|
+ shellRun("cmd role add-role-holder android.app.role.SMS $PACKAGE_CLEAN_SMS")
|
|
|
context.startActivity(
|
|
|
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
|
.putExtra("clean", true)
|
|
|
)
|
|
|
+ delay(3000)
|
|
|
+ shellRun("cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING")
|
|
|
}
|
|
|
- delay(5000)
|
|
|
-
|
|
|
- shellRun("cmd role add-role-holder android.app.role.SMS $PACKAGE_MESSAGING")
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
|
}
|
|
|
+
|
|
|
+ fun installCleanSms() {
|
|
|
+ val imageDir = ContextCompat.getExternalFilesDirs(getContext(), "images")[0]
|
|
|
+ }
|
|
|
}
|