mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-17 07:12:32 -08:00
Fixed setting custom channels and switching between official ones being broken
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.topjohnwu.magisk.data.network
|
||||
|
||||
import com.topjohnwu.magisk.Constants
|
||||
import com.topjohnwu.magisk.KConfig
|
||||
import com.topjohnwu.magisk.model.entity.MagiskConfig
|
||||
import io.reactivex.Single
|
||||
import okhttp3.ResponseBody
|
||||
@@ -26,6 +27,9 @@ interface GithubRawApiServices {
|
||||
@GET("$MAGISK_FILES/master/canary_builds/canary.json")
|
||||
fun fetchCanaryDebugConfig(): Single<MagiskConfig>
|
||||
|
||||
@GET
|
||||
fun fetchCustomConfig(@Url url: String): Single<MagiskConfig>
|
||||
|
||||
@GET("$MAGISK_FILES/{$REVISION}/snet.apk")
|
||||
@Streaming
|
||||
fun fetchSafetynet(@Path(REVISION) revision: String = Constants.SNET_REVISION): Single<ResponseBody>
|
||||
@@ -67,7 +71,7 @@ interface GithubRawApiServices {
|
||||
private const val FILE = "file"
|
||||
|
||||
|
||||
private const val MAGISK_FILES = "topjohnwu/magisk_files"
|
||||
private const val MAGISK_FILES = KConfig.DEFAULT_CHANNEL
|
||||
private const val MAGISK_MASTER = "topjohnwu/Magisk/master"
|
||||
private const val MAGISK_MODULES = "Magisk-Modules-Repo"
|
||||
}
|
||||
|
||||
@@ -24,12 +24,6 @@ class MagiskRepository(
|
||||
private val packageManager: PackageManager
|
||||
) {
|
||||
|
||||
private val config = apiRaw.fetchConfig()
|
||||
private val configBeta = apiRaw.fetchBetaConfig()
|
||||
private val configCanary = apiRaw.fetchCanaryConfig()
|
||||
private val configCanaryDebug = apiRaw.fetchCanaryDebugConfig()
|
||||
|
||||
|
||||
fun fetchMagisk() = fetchConfig()
|
||||
.flatMap { apiRaw.fetchFile(it.magisk.link) }
|
||||
.map { it.writeToFile(context, FILE_MAGISK_ZIP) }
|
||||
@@ -52,10 +46,11 @@ class MagiskRepository(
|
||||
|
||||
|
||||
fun fetchConfig() = when (KConfig.updateChannel) {
|
||||
KConfig.UpdateChannel.STABLE -> config
|
||||
KConfig.UpdateChannel.BETA -> configBeta
|
||||
KConfig.UpdateChannel.CANARY -> configCanary
|
||||
KConfig.UpdateChannel.CANARY_DEBUG -> configCanaryDebug
|
||||
KConfig.UpdateChannel.STABLE -> apiRaw.fetchConfig()
|
||||
KConfig.UpdateChannel.BETA -> apiRaw.fetchBetaConfig()
|
||||
KConfig.UpdateChannel.CANARY -> apiRaw.fetchCanaryConfig()
|
||||
KConfig.UpdateChannel.CANARY_DEBUG -> apiRaw.fetchCanaryDebugConfig()
|
||||
KConfig.UpdateChannel.CUSTOM -> apiRaw.fetchCustomConfig(KConfig.customUpdateChannel)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user