Magisk/app/src/main/java/com/topjohnwu/magisk/data/network/GithubServices.kt

82 lines
2.4 KiB
Kotlin
Raw Normal View History

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.tasks.GithubRepoInfo
import com.topjohnwu.magisk.core.model.UpdateInfo
import io.reactivex.Flowable
import io.reactivex.Single
import okhttp3.ResponseBody
import retrofit2.adapter.rxjava2.Result
import retrofit2.http.*
interface GithubRawServices {
//region topjohnwu/magisk_files
@GET("$MAGISK_FILES/master/stable.json")
2019-06-17 01:47:30 +02:00
fun fetchStableUpdate(): Single<UpdateInfo>
@GET("$MAGISK_FILES/master/beta.json")
2019-06-17 01:47:30 +02:00
fun fetchBetaUpdate(): Single<UpdateInfo>
2019-09-24 09:08:48 +02:00
@GET("$MAGISK_FILES/canary/release.json")
2019-06-17 01:47:30 +02:00
fun fetchCanaryUpdate(): Single<UpdateInfo>
2019-09-24 09:08:48 +02:00
@GET("$MAGISK_FILES/canary/debug.json")
2019-06-17 01:47:30 +02:00
fun fetchCanaryDebugUpdate(): Single<UpdateInfo>
@GET
2019-06-17 01:47:30 +02:00
fun fetchCustomUpdate(@Url url: String): Single<UpdateInfo>
2019-08-08 13:18:32 +02:00
@GET("$MAGISK_FILES/{$REVISION}/snet.jar")
@Streaming
2019-06-08 09:41:03 +02:00
fun fetchSafetynet(@Path(REVISION) revision: String = Const.SNET_REVISION): Single<ResponseBody>
@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-07-26 11:26:02 +02:00
@GET("$MAGISK_MASTER/scripts/module_installer.sh")
@Streaming
fun fetchInstaller(): Single<ResponseBody>
@GET("$MAGISK_MODULES/{$MODULE}/master/{$FILE}")
fun fetchModuleInfo(@Path(MODULE) id: String, @Path(FILE) file: String): Single<String>
//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>
@GET
fun fetchString(@Url url: String): Single<String>
companion object {
private const val REVISION = "revision"
private const val MODULE = "module"
private const val FILE = "file"
private const val MAGISK_FILES = "topjohnwu/magisk_files"
private const val MAGISK_MASTER = "topjohnwu/Magisk/master"
private const val MAGISK_MODULES = "Magisk-Modules-Repo"
}
}
interface GithubApiServices {
@GET("repos")
fun fetchRepos(@Query("page") page: Int,
@Header(Const.Key.IF_NONE_MATCH) etag: String,
@Query("sort") sort: String = "pushed",
@Query("per_page") count: Int = 100): Flowable<Result<List<GithubRepoInfo>>>
2020-01-13 15:01:46 +01:00
}