Remove request uninstall code

unreachable
This commit is contained in:
vvb2060 2022-06-06 02:00:54 +08:00 committed by John Wu
parent 8b16bfbb54
commit c495b3d183
4 changed files with 2 additions and 44 deletions

View File

@ -2,8 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<application <application
android:name=".core.App" android:name=".core.App"
android:extractNativeLibs="true" android:extractNativeLibs="true"

View File

@ -14,17 +14,13 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultCallback import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.contract.ActivityResultContracts.GetContent import androidx.activity.result.contract.ActivityResultContracts.GetContent
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission import androidx.activity.result.contract.ActivityResultContracts.RequestPermission
import androidx.annotation.WorkerThread
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.isRunningAsStub
import com.topjohnwu.magisk.core.utils.RequestInstall import com.topjohnwu.magisk.core.utils.RequestInstall
import com.topjohnwu.magisk.core.utils.UninstallPackage
import com.topjohnwu.magisk.core.wrap import com.topjohnwu.magisk.core.wrap
import com.topjohnwu.magisk.ktx.reflectField import com.topjohnwu.magisk.ktx.reflectField
import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.utils.Utils
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
interface ContentResultCallback: ActivityResultCallback<Uri>, Parcelable { interface ContentResultCallback: ActivityResultCallback<Uri>, Parcelable {
fun onActivityLaunch() {} fun onActivityLaunch() {}
@ -50,11 +46,6 @@ abstract class BaseActivity : AppCompatActivity() {
contentCallback = null contentCallback = null
} }
private var uninstallLatch = CountDownLatch(1)
private val uninstallPkg = registerForActivityResult(UninstallPackage()) {
uninstallLatch.countDown()
}
private val mReferrerField by lazy(LazyThreadSafetyMode.NONE) { private val mReferrerField by lazy(LazyThreadSafetyMode.NONE) {
Activity::class.java.reflectField("mReferrer") Activity::class.java.reflectField("mReferrer")
} }
@ -114,13 +105,6 @@ abstract class BaseActivity : AppCompatActivity() {
} }
} }
@WorkerThread
fun uninstallAndWait(pkg: String) {
uninstallLatch = CountDownLatch(1)
uninstallPkg.launch(pkg)
uninstallLatch.await(3, TimeUnit.SECONDS)
}
override fun recreate() { override fun recreate() {
startActivity(Intent().setComponent(intent.component)) startActivity(Intent().setComponent(intent.component))
finish() finish()

View File

@ -1,21 +0,0 @@
package com.topjohnwu.magisk.core.utils
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.activity.result.contract.ActivityResultContract
class UninstallPackage : ActivityResultContract<String, Boolean>() {
@Suppress("DEPRECATION")
override fun createIntent(context: Context, input: String): Intent {
val uri = Uri.Builder().scheme("package").opaquePart(input).build()
val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri)
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true)
return intent
}
override fun parseResult(resultCode: Int, intent: Intent?) =
resultCode == Activity.RESULT_OK
}

View File

@ -135,13 +135,10 @@ abstract class SplashActivity<Binding : ViewDataBinding> : NavigationActivity<Bi
Shell.cmd("(pm uninstall $APPLICATION_ID)& >/dev/null 2>&1").exec() Shell.cmd("(pm uninstall $APPLICATION_ID)& >/dev/null 2>&1").exec()
} }
} else { } else {
if (Config.suManager.isNotEmpty()) if (!Const.Version.atLeast_25_0() && Config.suManager.isNotEmpty())
Config.suManager = "" Config.suManager = ""
pkg ?: return pkg ?: return
if (!Shell.cmd("(pm uninstall $pkg)& >/dev/null 2>&1").exec().isSuccess) { Shell.cmd("(pm uninstall $pkg)& >/dev/null 2>&1").exec()
// Uninstall through Android API
uninstallAndWait(pkg)
}
} }
} }