Commit 5133e591 authored by topjohnwu's avatar topjohnwu

Don't relaunch app immediately

parent 1512c350
package com.topjohnwu.magisk.model.download 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.Restore
import com.topjohnwu.magisk.model.entity.internal.Configuration.APK.Upgrade import com.topjohnwu.magisk.model.entity.internal.Configuration.APK.Upgrade
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject 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.PatchAPK
import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import java.io.File import java.io.File
...@@ -35,9 +36,7 @@ private fun RemoteFileService.restore(apk: File, id: Int) { ...@@ -35,9 +36,7 @@ private fun RemoteFileService.restore(apk: File, id: Int) {
Config.export() Config.export()
// Make it world readable // Make it world readable
apk.setReadable(true, false) apk.setReadable(true, false)
if (Shell.su("pm install $apk").exec().isSuccess) { Shell.su("pm install $apk && pm uninstall $packageName").exec()
Utils.rmAndLaunch(packageName, SplashActivity::class.java.cmp())
}
} }
fun RemoteFileService.handleAPK(subject: DownloadSubject.Manager) fun RemoteFileService.handleAPK(subject: DownloadSubject.Manager)
......
...@@ -9,7 +9,6 @@ import com.topjohnwu.magisk.extensions.DynamicClassLoader ...@@ -9,7 +9,6 @@ import com.topjohnwu.magisk.extensions.DynamicClassLoader
import com.topjohnwu.magisk.extensions.get import com.topjohnwu.magisk.extensions.get
import com.topjohnwu.magisk.extensions.subscribeK import com.topjohnwu.magisk.extensions.subscribeK
import com.topjohnwu.magisk.extensions.writeTo import com.topjohnwu.magisk.extensions.writeTo
import com.topjohnwu.magisk.ui.SplashActivity
import com.topjohnwu.magisk.view.Notifications import com.topjohnwu.magisk.view.Notifications
import com.topjohnwu.signing.JarMap import com.topjohnwu.signing.JarMap
import com.topjohnwu.signing.SignAPK import com.topjohnwu.signing.SignAPK
...@@ -109,7 +108,7 @@ object PatchAPK { ...@@ -109,7 +108,7 @@ object PatchAPK {
Config.suManager = pkg Config.suManager = pkg
Config.export() Config.export()
Utils.rmAndLaunch(BuildConfig.APPLICATION_ID, SplashActivity::class.java.cmp(pkg)) Shell.su("pm uninstall ${BuildConfig.APPLICATION_ID}").submit()
return true return true
} }
......
package com.topjohnwu.magisk.utils package com.topjohnwu.magisk.utils
import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.res.Resources import android.content.res.Resources
...@@ -73,8 +72,4 @@ object Utils { ...@@ -73,8 +72,4 @@ object Utils {
if ((exists() && isDirectory) || mkdirs()) this else null if ((exists() && isDirectory) || mkdirs()) this else null
} }
fun rmAndLaunch(rm: String, component: ComponentName) {
Shell.su("(rm_launch $rm ${component.flattenToString()})").exec()
}
} }
...@@ -109,9 +109,3 @@ EOF ...@@ -109,9 +109,3 @@ EOF
touch hosts/auto_mount touch hosts/auto_mount
cd / cd /
} }
rm_launch() {
pm uninstall $1
am start -n $2
exit
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment