mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Cache update check results
This commit is contained in:
parent
21466426da
commit
dc61dfbde6
@ -4,6 +4,7 @@ import androidx.databinding.ObservableBoolean
|
||||
import com.topjohnwu.magisk.DynAPK
|
||||
import com.topjohnwu.magisk.core.model.UpdateInfo
|
||||
import com.topjohnwu.magisk.core.utils.net.NetworkObserver
|
||||
import com.topjohnwu.magisk.data.repository.NetworkService
|
||||
import com.topjohnwu.magisk.ktx.get
|
||||
import com.topjohnwu.magisk.ktx.getProperty
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@ -18,7 +19,13 @@ object Info {
|
||||
|
||||
var stub: DynAPK.Data? = null
|
||||
|
||||
var remote = UpdateInfo()
|
||||
val EMPTY_REMOTE = UpdateInfo()
|
||||
var remote = EMPTY_REMOTE
|
||||
suspend fun getRemote(svc: NetworkService): UpdateInfo? {
|
||||
return if (remote === EMPTY_REMOTE) {
|
||||
svc.fetchUpdate()?.apply { remote = this }
|
||||
} else remote
|
||||
}
|
||||
|
||||
// Device state
|
||||
@JvmStatic val env by lazy { loadState() }
|
||||
|
@ -36,7 +36,6 @@ class NetworkService(
|
||||
Config.updateChannel = BETA_CHANNEL
|
||||
info = fetchBetaUpdate()
|
||||
}
|
||||
Info.remote = info
|
||||
info
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class HomeViewModel(
|
||||
override fun refresh() = viewModelScope.launch {
|
||||
state = State.LOADING
|
||||
notifyPropertyChanged(BR.showSafetyNet)
|
||||
svc.fetchUpdate()?.apply {
|
||||
Info.getRemote(svc)?.apply {
|
||||
state = State.LOADED
|
||||
|
||||
stateManager = when {
|
||||
|
@ -141,7 +141,10 @@ object DownloadPath : BaseSettingsItem.Input() {
|
||||
|
||||
object UpdateChannel : BaseSettingsItem.Selector() {
|
||||
override var value = Config.updateChannel
|
||||
set(value) = setV(value, field, { field = it }) { Config.updateChannel = it }
|
||||
set(value) = setV(value, field, { field = it }) {
|
||||
Config.updateChannel = it
|
||||
Info.remote = Info.EMPTY_REMOTE
|
||||
}
|
||||
|
||||
override val title = R.string.settings_update_channel_title.asTransitive()
|
||||
override val entries: Array<String> = resources.getStringArray(R.array.update_channel).let {
|
||||
@ -155,7 +158,10 @@ object UpdateChannel : BaseSettingsItem.Selector() {
|
||||
object UpdateChannelUrl : BaseSettingsItem.Input() {
|
||||
override val title = R.string.settings_update_custom.asTransitive()
|
||||
override var value = Config.customChannelUrl
|
||||
set(value) = setV(value, field, { field = it }) { Config.customChannelUrl = it }
|
||||
set(value) = setV(value, field, { field = it }) {
|
||||
Config.customChannelUrl = it
|
||||
Info.remote = Info.EMPTY_REMOTE
|
||||
}
|
||||
override val description get() = value.asTransitive()
|
||||
|
||||
override val inputResult get() = result
|
||||
|
Loading…
Reference in New Issue
Block a user