2019-05-06 19:03:28 +02:00
|
|
|
package com.topjohnwu.magisk.data.network
|
|
|
|
|
2020-01-13 15:01:46 +01:00
|
|
|
import com.topjohnwu.magisk.core.Const
|
|
|
|
import com.topjohnwu.magisk.core.model.UpdateInfo
|
2020-01-28 18:49:59 +01:00
|
|
|
import com.topjohnwu.magisk.core.tasks.GithubRepoInfo
|
2019-05-06 19:03:28 +02:00
|
|
|
import io.reactivex.Single
|
|
|
|
import okhttp3.ResponseBody
|
2020-07-07 10:57:56 +02:00
|
|
|
import retrofit2.Response
|
2019-07-28 10:54:34 +02:00
|
|
|
import retrofit2.http.*
|
2019-05-06 19:03:28 +02:00
|
|
|
|
2019-07-28 10:54:34 +02:00
|
|
|
interface GithubRawServices {
|
2019-05-06 19:03:28 +02:00
|
|
|
|
|
|
|
//region topjohnwu/magisk_files
|
|
|
|
|
|
|
|
@GET("$MAGISK_FILES/master/stable.json")
|
2020-07-09 13:49:14 +02:00
|
|
|
suspend fun fetchStableUpdate(): UpdateInfo
|
2019-05-06 19:03:28 +02:00
|
|
|
|
|
|
|
@GET("$MAGISK_FILES/master/beta.json")
|
2020-07-09 13:49:14 +02:00
|
|
|
suspend fun fetchBetaUpdate(): UpdateInfo
|
2019-05-06 19:03:28 +02:00
|
|
|
|
2019-09-24 09:08:48 +02:00
|
|
|
@GET("$MAGISK_FILES/canary/debug.json")
|
2020-07-09 13:49:14 +02:00
|
|
|
suspend fun fetchCanaryUpdate(): UpdateInfo
|
2019-05-06 19:03:28 +02:00
|
|
|
|
2019-05-23 18:11:23 +02:00
|
|
|
@GET
|
2020-07-09 13:49:14 +02:00
|
|
|
suspend fun fetchCustomUpdate(@Url url: String): UpdateInfo
|
2019-05-23 18:11:23 +02:00
|
|
|
|
2019-08-08 13:18:32 +02:00
|
|
|
@GET("$MAGISK_FILES/{$REVISION}/snet.jar")
|
2019-05-06 19:03:28 +02:00
|
|
|
@Streaming
|
2019-06-08 09:41:03 +02:00
|
|
|
fun fetchSafetynet(@Path(REVISION) revision: String = Const.SNET_REVISION): Single<ResponseBody>
|
2019-05-06 19:03:28 +02:00
|
|
|
|
|
|
|
@GET("$MAGISK_FILES/{$REVISION}/bootctl")
|
|
|
|
@Streaming
|
2019-06-08 09:41:03 +02:00
|
|
|
fun fetchBootctl(@Path(REVISION) revision: String = Const.BOOTCTL_REVISION): Single<ResponseBody>
|
2019-05-06 19:03:28 +02:00
|
|
|
|
2019-07-26 11:26:02 +02:00
|
|
|
@GET("$MAGISK_MASTER/scripts/module_installer.sh")
|
|
|
|
@Streaming
|
|
|
|
fun fetchInstaller(): Single<ResponseBody>
|
|
|
|
|
2019-07-28 10:54:34 +02:00
|
|
|
@GET("$MAGISK_MODULES/{$MODULE}/master/{$FILE}")
|
|
|
|
fun fetchModuleInfo(@Path(MODULE) id: String, @Path(FILE) file: String): Single<String>
|
|
|
|
|
2020-07-07 10:57:56 +02:00
|
|
|
@GET("$MAGISK_MODULES/{$MODULE}/master/{$FILE}")
|
|
|
|
suspend fun fetchModuleFile(@Path(MODULE) id: String, @Path(FILE) file: String): String
|
|
|
|
|
2019-05-06 19:03:28 +02:00
|
|
|
//endregion
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method shall be used exclusively for fetching files from urls from previous requests.
|
|
|
|
* Him, who uses it in a wrong way, shall die in an eternal flame.
|
|
|
|
* */
|
|
|
|
@GET
|
|
|
|
@Streaming
|
|
|
|
fun fetchFile(@Url url: String): Single<ResponseBody>
|
|
|
|
|
2019-07-28 10:54:34 +02:00
|
|
|
@GET
|
|
|
|
fun fetchString(@Url url: String): Single<String>
|
|
|
|
|
2019-05-06 19:03:28 +02:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
private const val REVISION = "revision"
|
|
|
|
private const val MODULE = "module"
|
|
|
|
private const val FILE = "file"
|
|
|
|
|
|
|
|
|
2019-06-10 13:37:56 +02:00
|
|
|
private const val MAGISK_FILES = "topjohnwu/magisk_files"
|
2019-05-06 19:03:28 +02:00
|
|
|
private const val MAGISK_MASTER = "topjohnwu/Magisk/master"
|
|
|
|
private const val MAGISK_MODULES = "Magisk-Modules-Repo"
|
|
|
|
}
|
|
|
|
|
2019-07-28 10:54:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
interface GithubApiServices {
|
|
|
|
|
|
|
|
@GET("repos")
|
2020-07-07 10:57:56 +02:00
|
|
|
suspend fun fetchRepos(
|
2020-06-20 11:44:29 +02:00
|
|
|
@Query("page") page: Int,
|
|
|
|
@Header(Const.Key.IF_NONE_MATCH) etag: String,
|
|
|
|
@Query("sort") sort: String = "pushed",
|
|
|
|
@Query("per_page") count: Int = 100
|
2020-07-07 10:57:56 +02:00
|
|
|
): Response<List<GithubRepoInfo>>
|
2019-07-28 10:54:34 +02:00
|
|
|
|
2020-01-13 15:01:46 +01:00
|
|
|
}
|