Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
cdaff5b3
Commit
cdaff5b3
authored
Jul 26, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update module download pipeline
parent
2b1b970e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
27 deletions
+18
-27
GithubRawApiServices.kt
...com/topjohnwu/magisk/data/network/GithubRawApiServices.kt
+4
-0
FileRepository.kt
...va/com/topjohnwu/magisk/data/repository/FileRepository.kt
+2
-0
NetworkingModule.kt
...src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
+7
-19
RemoteFileService.kt
.../com/topjohnwu/magisk/model/download/RemoteFileService.kt
+5
-8
No files found.
app/src/main/java/com/topjohnwu/magisk/data/network/GithubRawApiServices.kt
View file @
cdaff5b3
...
...
@@ -37,6 +37,10 @@ interface GithubRawApiServices {
@Streaming
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
Single
<
ResponseBody
>
@GET
(
"$MAGISK_MASTER/scripts/module_installer.sh"
)
@Streaming
fun
fetchInstaller
():
Single
<
ResponseBody
>
//endregion
/**
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/FileRepository.kt
View file @
cdaff5b3
...
...
@@ -8,4 +8,6 @@ class FileRepository(
fun
downloadFile
(
url
:
String
)
=
api
.
fetchFile
(
url
)
fun
downloadInstaller
()
=
api
.
fetchInstaller
()
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/di/NetworkingModule.kt
View file @
cdaff5b3
...
...
@@ -8,8 +8,6 @@ import com.topjohnwu.magisk.data.network.GithubRawApiServices
import
okhttp3.OkHttpClient
import
okhttp3.logging.HttpLoggingInterceptor
import
org.koin.dsl.module
import
retrofit2.CallAdapter
import
retrofit2.Converter
import
retrofit2.Retrofit
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import
retrofit2.converter.moshi.MoshiConverterFactory
...
...
@@ -17,9 +15,8 @@ import se.ansman.kotshi.KotshiJsonAdapterFactory
val
networkingModule
=
module
{
single
{
createOkHttpClient
()
}
single
{
createConverterFactory
()
}
single
{
createCallAdapterFactory
()
}
single
{
createRetrofit
(
get
(),
get
(),
get
())
}
single
{
createMoshiConverterFactory
()
}
single
{
createRetrofit
(
get
(),
get
())
}
single
{
createApiService
<
GithubRawApiServices
>(
get
(),
Const
.
Url
.
GITHUB_RAW_API_URL
)
}
}
...
...
@@ -36,34 +33,25 @@ fun createOkHttpClient(): OkHttpClient {
return
builder
.
build
()
}
fun
create
ConverterFactory
():
Converter
.
Factory
{
fun
create
MoshiConverterFactory
():
MoshiConverter
Factory
{
val
moshi
=
Moshi
.
Builder
()
.
add
(
JsonAdapterFactory
.
INSTANCE
)
.
add
(
KotshiJsonAdapterFactory
)
.
build
()
return
MoshiConverterFactory
.
create
(
moshi
)
}
fun
createCallAdapterFactory
():
CallAdapter
.
Factory
{
return
RxJava2CallAdapterFactory
.
create
()
}
fun
createRetrofit
(
okHttpClient
:
OkHttpClient
,
converterFactory
:
Converter
.
Factory
,
callAdapterFactory
:
CallAdapter
.
Factory
converterFactory
:
MoshiConverterFactory
):
Retrofit
.
Builder
{
return
Retrofit
.
Builder
()
.
addConverterFactory
(
converterFactory
)
.
addCallAdapterFactory
(
callAdapterFactory
)
.
addCallAdapterFactory
(
RxJava2CallAdapterFactory
.
create
()
)
.
client
(
okHttpClient
)
}
@KotshiJsonAdapterFactory
abstract
class
JsonAdapterFactory
:
JsonAdapter
.
Factory
{
companion
object
{
val
INSTANCE
:
JsonAdapterFactory
=
KotshiJsonAdapterFactory
}
}
abstract
class
JsonAdapterFactory
:
JsonAdapter
.
Factory
inline
fun
<
reified
T
>
createApiService
(
retrofitBuilder
:
Retrofit
.
Builder
,
baseUrl
:
String
):
T
{
return
retrofitBuilder
...
...
app/src/main/java/com/topjohnwu/magisk/model/download/RemoteFileService.kt
View file @
cdaff5b3
...
...
@@ -4,7 +4,6 @@ import android.content.Intent
import
androidx.core.app.NotificationCompat
import
com.skoumal.teanity.extensions.subscribeK
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.repository.FileRepository
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
...
...
@@ -71,13 +70,11 @@ abstract class RemoteFileService : NotificationService() {
private
fun
download
(
subject
:
DownloadSubject
)
=
repo
.
downloadFile
(
subject
.
url
)
.
map
{
it
.
toStream
(
subject
.
hashCode
())
}
.
map
{
subject
.
file
.
apply
{
when
(
subject
)
{
is
Module
->
it
.
toModule
(
this
,
repo
.
downloadFile
(
Const
.
Url
.
MODULE_INSTALLER
).
blockingGet
().
byteStream
())
else
->
it
.
writeTo
(
this
)
}
.
flatMap
{
stream
->
when
(
subject
)
{
is
Module
->
repo
.
downloadInstaller
()
.
map
{
stream
.
toModule
(
subject
.
file
,
it
.
byteStream
());
subject
.
file
}
else
->
Single
.
fromCallable
{
stream
.
writeTo
(
subject
.
file
);
subject
.
file
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment