Fixed setting custom channels and switching between official ones being broken

This commit is contained in:
Viktor De Pasquale
2019-05-23 18:11:23 +02:00
parent dabe6267b9
commit df78fd2d41
7 changed files with 90 additions and 55 deletions

View File

@@ -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"
}

View File

@@ -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)
}