Remove ProcessPhoenix

This commit is contained in:
topjohnwu
2020-08-22 22:49:03 -07:00
parent 0e5a32b476
commit 31681c9c5f
9 changed files with 22 additions and 96 deletions

View File

@@ -1,13 +1,12 @@
@file:JvmName("a")
package a
import com.topjohnwu.magisk.ProcessPhoenix
import com.topjohnwu.magisk.core.App
import com.topjohnwu.magisk.core.GeneralReceiver
import com.topjohnwu.magisk.core.SplashActivity
import com.topjohnwu.magisk.core.download.DownloadService
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import com.topjohnwu.magisk.ui.MainActivity
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import com.topjohnwu.signing.BootSigner
fun main(args: Array<String>) {
@@ -28,5 +27,3 @@ class h : GeneralReceiver()
class j : DownloadService()
class m : SuRequestActivity()
class r : ProcessPhoenix()

View File

@@ -16,7 +16,6 @@ import android.content.res.Configuration
import android.content.res.Resources
import androidx.annotation.RequiresApi
import com.topjohnwu.magisk.DynAPK
import com.topjohnwu.magisk.ProcessPhoenix
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.download.DownloadService
import com.topjohnwu.magisk.core.utils.refreshLocale
@@ -152,8 +151,7 @@ private object ClassMap {
SplashActivity::class.java to a.c::class.java,
GeneralReceiver::class.java to a.h::class.java,
DownloadService::class.java to a.j::class.java,
SuRequestActivity::class.java to a.m::class.java,
ProcessPhoenix::class.java to a.r::class.java
SuRequestActivity::class.java to a.m::class.java
)
operator fun get(c: Class<*>) = map.getOrElse(c) { c }

View File

@@ -3,15 +3,14 @@ package com.topjohnwu.magisk.core.download
import androidx.core.net.toFile
import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.DynAPK
import com.topjohnwu.magisk.ProcessPhoenix
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.download.Action.APK.Restore
import com.topjohnwu.magisk.core.download.Action.APK.Upgrade
import com.topjohnwu.magisk.core.intent
import com.topjohnwu.magisk.core.isRunningAsStub
import com.topjohnwu.magisk.core.utils.PatchAPK
import com.topjohnwu.magisk.ktx.relaunchApp
import com.topjohnwu.magisk.ktx.writeTo
import com.topjohnwu.magisk.utils.APKInstall
import com.topjohnwu.superuser.Shell
@@ -46,7 +45,7 @@ private suspend fun DownloadService.upgrade(apk: File, id: Int) {
patch(apk, id)
} else {
// Simply relaunch the app
ProcessPhoenix.triggerRebirth(this, intent<ProcessPhoenix>())
relaunchApp(this)
}
} else {
patch(apk, id)

View File

@@ -1,5 +1,7 @@
package com.topjohnwu.magisk.ktx
import android.content.Context
import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers
@@ -9,4 +11,12 @@ fun reboot(reason: String = if (Info.recovery) "recovery" else "") {
Shell.su("/system/bin/svc power reboot $reason || /system/bin/reboot $reason").submit()
}
fun relaunchApp(context: Context) {
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName) ?: return
val args = mutableListOf("am", "start", "--user", Const.USER_ID.toString())
val cmd = intent.toCommand(args).joinToString(separator = " ")
Shell.su("run_delay 1 \"$cmd\"").exec()
Runtime.getRuntime().exit(0)
}
suspend fun Shell.Job.await() = withContext(Dispatchers.IO) { exec() }