From 5133e5910e536b155e20c378348db987e35acc6a Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 23 Oct 2019 07:07:51 -0400 Subject: [PATCH] Don't relaunch app immediately --- .../topjohnwu/magisk/model/download/ManagerUpgrade.kt | 11 +++++------ .../main/java/com/topjohnwu/magisk/utils/PatchAPK.kt | 3 +-- app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt | 5 ----- app/src/main/res/raw/utils.sh | 6 ------ 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/download/ManagerUpgrade.kt b/app/src/main/java/com/topjohnwu/magisk/model/download/ManagerUpgrade.kt index b4d6d8cc5..18cb448a7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/download/ManagerUpgrade.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/download/ManagerUpgrade.kt @@ -1,12 +1,13 @@ package com.topjohnwu.magisk.model.download -import com.topjohnwu.magisk.* +import com.topjohnwu.magisk.BuildConfig +import com.topjohnwu.magisk.Config +import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.isRunningAsStub import com.topjohnwu.magisk.model.entity.internal.Configuration.APK.Restore import com.topjohnwu.magisk.model.entity.internal.Configuration.APK.Upgrade import com.topjohnwu.magisk.model.entity.internal.DownloadSubject -import com.topjohnwu.magisk.ui.SplashActivity import com.topjohnwu.magisk.utils.PatchAPK -import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.superuser.Shell import java.io.File @@ -35,9 +36,7 @@ private fun RemoteFileService.restore(apk: File, id: Int) { Config.export() // Make it world readable apk.setReadable(true, false) - if (Shell.su("pm install $apk").exec().isSuccess) { - Utils.rmAndLaunch(packageName, SplashActivity::class.java.cmp()) - } + Shell.su("pm install $apk && pm uninstall $packageName").exec() } fun RemoteFileService.handleAPK(subject: DownloadSubject.Manager) diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt b/app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt index 91a4ab791..2d8d3b356 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt @@ -9,7 +9,6 @@ import com.topjohnwu.magisk.extensions.DynamicClassLoader import com.topjohnwu.magisk.extensions.get import com.topjohnwu.magisk.extensions.subscribeK import com.topjohnwu.magisk.extensions.writeTo -import com.topjohnwu.magisk.ui.SplashActivity import com.topjohnwu.magisk.view.Notifications import com.topjohnwu.signing.JarMap import com.topjohnwu.signing.SignAPK @@ -109,7 +108,7 @@ object PatchAPK { Config.suManager = pkg Config.export() - Utils.rmAndLaunch(BuildConfig.APPLICATION_ID, SplashActivity::class.java.cmp(pkg)) + Shell.su("pm uninstall ${BuildConfig.APPLICATION_ID}").submit() return true } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt index 48ca4d3c1..252b7b6d8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt @@ -1,6 +1,5 @@ package com.topjohnwu.magisk.utils -import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.res.Resources @@ -73,8 +72,4 @@ object Utils { if ((exists() && isDirectory) || mkdirs()) this else null } - fun rmAndLaunch(rm: String, component: ComponentName) { - Shell.su("(rm_launch $rm ${component.flattenToString()})").exec() - } - } diff --git a/app/src/main/res/raw/utils.sh b/app/src/main/res/raw/utils.sh index 4e2a298a1..136b6adf3 100644 --- a/app/src/main/res/raw/utils.sh +++ b/app/src/main/res/raw/utils.sh @@ -109,9 +109,3 @@ EOF touch hosts/auto_mount cd / } - -rm_launch() { - pm uninstall $1 - am start -n $2 - exit -}