Move things around
This commit is contained in:
parent
7fc7809cfc
commit
0b87108174
@ -15,7 +15,6 @@ import com.topjohnwu.magisk.di.ActivityTracker
|
||||
import com.topjohnwu.magisk.di.koinModules
|
||||
import com.topjohnwu.magisk.extensions.get
|
||||
import com.topjohnwu.magisk.extensions.unwrap
|
||||
import com.topjohnwu.magisk.utils.DynAPK
|
||||
import com.topjohnwu.magisk.utils.RootInit
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
@ -25,7 +24,7 @@ import timber.log.Timber
|
||||
open class App() : Application() {
|
||||
|
||||
constructor(o: Any) : this() {
|
||||
ClassMap.data = DynAPK.load(o)
|
||||
Info.stub = DynAPK.load(o)
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -23,13 +23,10 @@ import com.topjohnwu.magisk.ui.MainActivity
|
||||
import com.topjohnwu.magisk.ui.SplashActivity
|
||||
import com.topjohnwu.magisk.ui.flash.FlashActivity
|
||||
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity
|
||||
import com.topjohnwu.magisk.utils.DynAPK
|
||||
import com.topjohnwu.magisk.utils.currentLocale
|
||||
import com.topjohnwu.magisk.utils.defaultLocale
|
||||
import java.util.*
|
||||
|
||||
val isRunningAsStub get() = ClassMap.data != null
|
||||
|
||||
private val addAssetPath by lazy {
|
||||
AssetManager::class.java.getMethod("addAssetPath", String::class.java)
|
||||
}
|
||||
@ -69,19 +66,19 @@ private fun Resources.patch(config: Configuration = Configuration(configuration)
|
||||
|
||||
fun Class<*>.cmp(pkg: String = BuildConfig.APPLICATION_ID): ComponentName {
|
||||
val name = ClassMap[this].name
|
||||
return ComponentName(pkg, ClassMap.data?.componentMap?.get(name) ?: name)
|
||||
return ComponentName(pkg, Info.stub?.componentMap?.get(name) ?: name)
|
||||
}
|
||||
|
||||
fun Context.intent(c: Class<*>): Intent {
|
||||
val cls = ClassMap[c]
|
||||
return ClassMap.data?.let {
|
||||
return Info.stub?.let {
|
||||
val className = it.componentMap.getOrElse(cls.name) { cls.name }
|
||||
Intent().setComponent(ComponentName(this, className))
|
||||
} ?: Intent(this, cls)
|
||||
}
|
||||
|
||||
fun resolveRes(idx: Int): Int {
|
||||
return ClassMap.data?.resourceMap?.get(idx) ?: when(idx) {
|
||||
return Info.stub?.resourceMap?.get(idx) ?: when(idx) {
|
||||
DynAPK.NOTIFICATION -> R.drawable.ic_magisk_outline
|
||||
DynAPK.DOWNLOAD -> R.drawable.sc_cloud_download
|
||||
DynAPK.SUPERUSER -> R.drawable.sc_superuser
|
||||
@ -172,7 +169,7 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler
|
||||
// We need to patch the component of JobInfo to access WorkManager SystemJobService
|
||||
|
||||
val name = service.className
|
||||
val component = ComponentName(service.packageName, ClassMap.data?.componentMap?.get(name)
|
||||
val component = ComponentName(service.packageName, Info.stub?.componentMap?.get(name)
|
||||
?: name)
|
||||
|
||||
// Clone the JobInfo except component
|
||||
@ -226,7 +223,5 @@ object ClassMap {
|
||||
SuRequestActivity::class.java to a.m::class.java
|
||||
)
|
||||
|
||||
internal var data: DynAPK.Data? = null
|
||||
|
||||
operator fun get(c: Class<*>) = map.getOrElse(c) { throw IllegalArgumentException() }
|
||||
}
|
||||
|
@ -9,12 +9,15 @@ import com.topjohnwu.magisk.utils.KObservableField
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.ShellUtils
|
||||
|
||||
val isRunningAsStub get() = Info.stub != null
|
||||
|
||||
object Info {
|
||||
|
||||
val envRef = CachedValue { loadState() }
|
||||
|
||||
val env by envRef // Local
|
||||
var remote = UpdateInfo() // Remote
|
||||
val env by envRef // Local
|
||||
var remote = UpdateInfo() // Remote
|
||||
var stub: DynAPK.Data? = null // Stub
|
||||
|
||||
var keepVerity = false
|
||||
var keepEnc = false
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.topjohnwu.magisk.base.viewmodel
|
||||
|
||||
import android.app.Activity
|
||||
import com.topjohnwu.magisk.Info.isConnected as gIsConnected
|
||||
import com.topjohnwu.magisk.extensions.doOnSubscribeUi
|
||||
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||
@ -9,6 +8,7 @@ import com.topjohnwu.magisk.model.events.ViewActionEvent
|
||||
import com.topjohnwu.magisk.utils.KObservableField
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import com.topjohnwu.magisk.Info.isConnected as gIsConnected
|
||||
|
||||
|
||||
abstract class BaseViewModel(
|
||||
|
@ -21,8 +21,8 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.FileProvider
|
||||
import com.topjohnwu.magisk.utils.DynamicClassLoader
|
||||
import com.topjohnwu.magisk.utils.FileProvider
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.utils.currentLocale
|
||||
import com.topjohnwu.superuser.Shell
|
||||
|
@ -5,7 +5,6 @@ import com.topjohnwu.magisk.extensions.writeTo
|
||||
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.utils.DynAPK
|
||||
import com.topjohnwu.magisk.utils.PatchAPK
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import java.io.File
|
||||
@ -31,7 +30,7 @@ private fun RemoteFileService.upgrade(apk: File, id: Int) {
|
||||
// Move to upgrade location
|
||||
apk.copyTo(DynAPK.update(this), overwrite = true)
|
||||
apk.delete()
|
||||
if (ClassMap.data!!.version < Info.remote.stub.versionCode) {
|
||||
if (Info.stub!!.version < Info.remote.stub.versionCode) {
|
||||
// We also want to upgrade stub
|
||||
service.fetchFile(Info.remote.stub.link).blockingGet().byteStream().use {
|
||||
it.writeTo(apk)
|
||||
|
@ -208,7 +208,7 @@ class HomeViewModel(
|
||||
}
|
||||
|
||||
managerCurrentVersion.value = if (isRunningAsStub) MGR_VER_FMT
|
||||
.format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, ClassMap.data!!.version)
|
||||
.format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, Info.stub!!.version)
|
||||
else
|
||||
VERSION_FMT.format(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
|
||||
}
|
||||
@ -227,7 +227,7 @@ class HomeViewModel(
|
||||
in Int.MIN_VALUE until 0 -> MagiskState.NOT_INSTALLED //wrong update channel
|
||||
in (BuildConfig.VERSION_CODE + 1) until Int.MAX_VALUE -> MagiskState.OBSOLETE
|
||||
else -> {
|
||||
if (isRunningAsStub && ClassMap.data!!.version < Info.remote.stub.versionCode)
|
||||
if (isRunningAsStub && Info.stub!!.version < Info.remote.stub.versionCode)
|
||||
MagiskState.OBSOLETE
|
||||
else
|
||||
MagiskState.UP_TO_DATE
|
||||
|
@ -8,7 +8,6 @@ import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.topjohnwu.magisk.ClassMap
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.base.BaseFragment
|
||||
|
@ -12,7 +12,6 @@ import com.topjohnwu.magisk.*
|
||||
import com.topjohnwu.magisk.extensions.get
|
||||
import com.topjohnwu.magisk.model.receiver.GeneralReceiver
|
||||
import com.topjohnwu.magisk.ui.SplashActivity
|
||||
import com.topjohnwu.magisk.utils.DynAPK
|
||||
|
||||
object Notifications {
|
||||
|
||||
|
@ -9,7 +9,6 @@ import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.topjohnwu.magisk.*
|
||||
import com.topjohnwu.magisk.ui.SplashActivity
|
||||
import com.topjohnwu.magisk.utils.DynAPK
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.superuser.Shell
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package a;
|
||||
|
||||
import com.topjohnwu.magisk.utils.FileProvider;
|
||||
import com.topjohnwu.magisk.FileProvider;
|
||||
|
||||
public class p extends FileProvider {
|
||||
/* Stub */
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
@ -5,6 +5,8 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import com.topjohnwu.magisk.FileProvider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class APKInstall {
|
||||
|
@ -9,7 +9,6 @@ import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.utils.DynAPK;
|
||||
import com.topjohnwu.magisk.utils.DynamicClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -3,7 +3,7 @@ package com.topjohnwu.magisk;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.topjohnwu.magisk.utils.DynAPK.*;
|
||||
import static com.topjohnwu.magisk.DynAPK.*;
|
||||
|
||||
class Mapping {
|
||||
private static Map<String, String> map = new HashMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user