Don't relaunch app immediately

This commit is contained in:
topjohnwu 2019-10-23 07:07:51 -04:00
parent 1512c350df
commit 5133e5910e
4 changed files with 6 additions and 19 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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()
}
}

View File

@ -109,9 +109,3 @@ EOF
touch hosts/auto_mount
cd /
}
rm_launch() {
pm uninstall $1
am start -n $2
exit
}