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 {
...
@@ -37,6 +37,10 @@ interface GithubRawApiServices {
@Streaming
@Streaming
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
Single
<
ResponseBody
>
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
Single
<
ResponseBody
>
@GET
(
"$MAGISK_MASTER/scripts/module_installer.sh"
)
@Streaming
fun
fetchInstaller
():
Single
<
ResponseBody
>
//endregion
//endregion
/**
/**
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/FileRepository.kt
View file @
cdaff5b3
...
@@ -8,4 +8,6 @@ class FileRepository(
...
@@ -8,4 +8,6 @@ class FileRepository(
fun
downloadFile
(
url
:
String
)
=
api
.
fetchFile
(
url
)
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
...
@@ -8,8 +8,6 @@ import com.topjohnwu.magisk.data.network.GithubRawApiServices
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
import
okhttp3.logging.HttpLoggingInterceptor
import
okhttp3.logging.HttpLoggingInterceptor
import
org.koin.dsl.module
import
org.koin.dsl.module
import
retrofit2.CallAdapter
import
retrofit2.Converter
import
retrofit2.Retrofit
import
retrofit2.Retrofit
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import
retrofit2.converter.moshi.MoshiConverterFactory
import
retrofit2.converter.moshi.MoshiConverterFactory
...
@@ -17,9 +15,8 @@ import se.ansman.kotshi.KotshiJsonAdapterFactory
...
@@ -17,9 +15,8 @@ import se.ansman.kotshi.KotshiJsonAdapterFactory
val
networkingModule
=
module
{
val
networkingModule
=
module
{
single
{
createOkHttpClient
()
}
single
{
createOkHttpClient
()
}
single
{
createConverterFactory
()
}
single
{
createMoshiConverterFactory
()
}
single
{
createCallAdapterFactory
()
}
single
{
createRetrofit
(
get
(),
get
())
}
single
{
createRetrofit
(
get
(),
get
(),
get
())
}
single
{
createApiService
<
GithubRawApiServices
>(
get
(),
Const
.
Url
.
GITHUB_RAW_API_URL
)
}
single
{
createApiService
<
GithubRawApiServices
>(
get
(),
Const
.
Url
.
GITHUB_RAW_API_URL
)
}
}
}
...
@@ -36,34 +33,25 @@ fun createOkHttpClient(): OkHttpClient {
...
@@ -36,34 +33,25 @@ fun createOkHttpClient(): OkHttpClient {
return
builder
.
build
()
return
builder
.
build
()
}
}
fun
create
ConverterFactory
():
Converter
.
Factory
{
fun
create
MoshiConverterFactory
():
MoshiConverter
Factory
{
val
moshi
=
Moshi
.
Builder
()
val
moshi
=
Moshi
.
Builder
()
.
add
(
JsonAdapterFactory
.
INSTANCE
)
.
add
(
KotshiJsonAdapterFactory
)
.
build
()
.
build
()
return
MoshiConverterFactory
.
create
(
moshi
)
return
MoshiConverterFactory
.
create
(
moshi
)
}
}
fun
createCallAdapterFactory
():
CallAdapter
.
Factory
{
return
RxJava2CallAdapterFactory
.
create
()
}
fun
createRetrofit
(
fun
createRetrofit
(
okHttpClient
:
OkHttpClient
,
okHttpClient
:
OkHttpClient
,
converterFactory
:
Converter
.
Factory
,
converterFactory
:
MoshiConverterFactory
callAdapterFactory
:
CallAdapter
.
Factory
):
Retrofit
.
Builder
{
):
Retrofit
.
Builder
{
return
Retrofit
.
Builder
()
return
Retrofit
.
Builder
()
.
addConverterFactory
(
converterFactory
)
.
addConverterFactory
(
converterFactory
)
.
addCallAdapterFactory
(
callAdapterFactory
)
.
addCallAdapterFactory
(
RxJava2CallAdapterFactory
.
create
()
)
.
client
(
okHttpClient
)
.
client
(
okHttpClient
)
}
}
@KotshiJsonAdapterFactory
@KotshiJsonAdapterFactory
abstract
class
JsonAdapterFactory
:
JsonAdapter
.
Factory
{
abstract
class
JsonAdapterFactory
:
JsonAdapter
.
Factory
companion
object
{
val
INSTANCE
:
JsonAdapterFactory
=
KotshiJsonAdapterFactory
}
}
inline
fun
<
reified
T
>
createApiService
(
retrofitBuilder
:
Retrofit
.
Builder
,
baseUrl
:
String
):
T
{
inline
fun
<
reified
T
>
createApiService
(
retrofitBuilder
:
Retrofit
.
Builder
,
baseUrl
:
String
):
T
{
return
retrofitBuilder
return
retrofitBuilder
...
...
app/src/main/java/com/topjohnwu/magisk/model/download/RemoteFileService.kt
View file @
cdaff5b3
...
@@ -4,7 +4,6 @@ import android.content.Intent
...
@@ -4,7 +4,6 @@ import android.content.Intent
import
androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationCompat
import
com.skoumal.teanity.extensions.subscribeK
import
com.skoumal.teanity.extensions.subscribeK
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.repository.FileRepository
import
com.topjohnwu.magisk.data.repository.FileRepository
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
...
@@ -71,13 +70,11 @@ abstract class RemoteFileService : NotificationService() {
...
@@ -71,13 +70,11 @@ abstract class RemoteFileService : NotificationService() {
private
fun
download
(
subject
:
DownloadSubject
)
=
repo
.
downloadFile
(
subject
.
url
)
private
fun
download
(
subject
:
DownloadSubject
)
=
repo
.
downloadFile
(
subject
.
url
)
.
map
{
it
.
toStream
(
subject
.
hashCode
())
}
.
map
{
it
.
toStream
(
subject
.
hashCode
())
}
.
map
{
.
flatMap
{
stream
->
subject
.
file
.
apply
{
when
(
subject
)
{
when
(
subject
)
{
is
Module
->
repo
.
downloadInstaller
()
is
Module
->
it
.
toModule
(
this
,
.
map
{
stream
.
toModule
(
subject
.
file
,
it
.
byteStream
());
subject
.
file
}
repo
.
downloadFile
(
Const
.
Url
.
MODULE_INSTALLER
).
blockingGet
().
byteStream
())
else
->
Single
.
fromCallable
{
stream
.
writeTo
(
subject
.
file
);
subject
.
file
}
else
->
it
.
writeTo
(
this
)
}
}
}
}
}
...
...
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