Fix manager update after hidden

Fix #1828
This commit is contained in:
topjohnwu 2019-09-09 17:24:29 -04:00
parent 087b451e17
commit d73f39c706

View File

@ -16,7 +16,7 @@ import com.topjohnwu.superuser.Shell
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
private fun RemoteFileService.patchPackage(apk: File, id: Int): File { private fun RemoteFileService.patchPackage(apk: File, id: Int) {
if (packageName != BuildConfig.APPLICATION_ID) { if (packageName != BuildConfig.APPLICATION_ID) {
update(id) { notification -> update(id) { notification ->
notification.setProgress(0, 0, true) notification.setProgress(0, 0, true)
@ -37,13 +37,11 @@ private fun RemoteFileService.patchPackage(apk: File, id: Int): File {
PatchAPK.patch(apk.path, patched.path, packageName) PatchAPK.patch(apk.path, patched.path, packageName)
} }
apk.delete() apk.delete()
return patched patched.renameTo(apk)
} else {
return apk
} }
} }
private fun RemoteFileService.restore(apk: File, id: Int): File { private fun RemoteFileService.restore(apk: File, id: Int) {
update(id) { notification -> update(id) { notification ->
notification.setProgress(0, 0, true) notification.setProgress(0, 0, true)
.setProgress(0, 0, true) .setProgress(0, 0, true)
@ -53,11 +51,11 @@ private fun RemoteFileService.restore(apk: File, id: Int): File {
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) if (Shell.su("pm install $apk").exec().isSuccess) {
RootUtils.rmAndLaunch(packageName, val component = ComponentName(BuildConfig.APPLICATION_ID,
ComponentName(BuildConfig.APPLICATION_ID, ClassMap.get<Class<*>>(SplashActivity::class.java).name)
ClassMap.get<Class<*>>(SplashActivity::class.java).name)) RootUtils.rmAndLaunch(packageName, component)
return apk }
} }
fun RemoteFileService.handleAPK(subject: DownloadSubject.Manager) fun RemoteFileService.handleAPK(subject: DownloadSubject.Manager)