-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jsdelivr CDN for several files
- Loading branch information
Showing
17 changed files
with
130 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
app/src/main/java/com/topjohnwu/magisk/data/repository/MagiskRepository.kt
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.topjohnwu.magisk.data.repository | ||
|
||
import com.topjohnwu.magisk.core.Config | ||
import com.topjohnwu.magisk.core.Config.Value.BETA_CHANNEL | ||
import com.topjohnwu.magisk.core.Config.Value.CANARY_CHANNEL | ||
import com.topjohnwu.magisk.core.Config.Value.CUSTOM_CHANNEL | ||
import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL | ||
import com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL | ||
import com.topjohnwu.magisk.core.Info | ||
import com.topjohnwu.magisk.core.model.module.Repo | ||
import com.topjohnwu.magisk.data.network.GithubApiServices | ||
import com.topjohnwu.magisk.data.network.GithubPageServices | ||
import com.topjohnwu.magisk.data.network.GithubRawServices | ||
import com.topjohnwu.magisk.data.network.JSDelivrServices | ||
import retrofit2.HttpException | ||
import timber.log.Timber | ||
import java.io.IOException | ||
|
||
class NetworkService( | ||
private val pages: GithubPageServices, | ||
private val raw: GithubRawServices, | ||
private val jsd: JSDelivrServices, | ||
private val api: GithubApiServices | ||
) { | ||
suspend fun fetchUpdate() = try { | ||
var info = when (Config.updateChannel) { | ||
DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate() | ||
BETA_CHANNEL -> fetchBetaUpdate() | ||
CANARY_CHANNEL -> fetchCanaryUpdate() | ||
CUSTOM_CHANNEL -> fetchCustomUpdate(Config.customChannelUrl) | ||
else -> throw IllegalArgumentException() | ||
} | ||
if (info.magisk.versionCode < Info.env.magiskVersionCode && | ||
Config.updateChannel == DEFAULT_CHANNEL | ||
) { | ||
Config.updateChannel = BETA_CHANNEL | ||
info = fetchBetaUpdate() | ||
} | ||
Info.remote = info | ||
info | ||
} catch (e: IOException) { | ||
Timber.e(e) | ||
null | ||
} catch (e: HttpException) { | ||
Timber.e(e) | ||
null | ||
} | ||
|
||
// UpdateInfo | ||
suspend fun fetchStableUpdate() = pages.fetchStableUpdate() | ||
suspend fun fetchBetaUpdate() = pages.fetchBetaUpdate() | ||
suspend fun fetchCanaryUpdate() = raw.fetchCanaryUpdate() | ||
suspend fun fetchCustomUpdate(url: String) = raw.fetchCustomUpdate(url) | ||
|
||
// Byte streams | ||
suspend fun fetchSafetynet() = jsd.fetchSafetynet() | ||
suspend fun fetchBootctl() = jsd.fetchBootctl() | ||
suspend fun fetchInstaller() = raw.fetchInstaller() | ||
suspend fun fetchFile(url: String) = raw.fetchFile(url) | ||
|
||
// Strings | ||
suspend fun fetchMetadata(repo: Repo) = raw.fetchModuleFile(repo.id, "module.prop") | ||
suspend fun fetchReadme(repo: Repo) = raw.fetchModuleFile(repo.id, "README.md") | ||
suspend fun fetchString(url: String) = raw.fetchString(url) | ||
|
||
// API calls | ||
suspend fun fetchRepos(page: Int, etag: String) = api.fetchRepos(page, etag) | ||
} |
16 changes: 0 additions & 16 deletions
16
app/src/main/java/com/topjohnwu/magisk/data/repository/StringRepository.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.