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
2f02f9a5
Commit
2f02f9a5
authored
Jul 21, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update libsu
parent
07f712a1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
5 deletions
+62
-5
build.gradle.kts
app/build.gradle.kts
+1
-1
App.kt
app/src/main/java/com/topjohnwu/magisk/core/App.kt
+3
-1
RemoteFileService.kt
...a/com/topjohnwu/magisk/core/download/RemoteFileService.kt
+2
-2
IODispatcherExecutor.kt
...a/com/topjohnwu/magisk/core/utils/IODispatcherExecutor.kt
+36
-0
XJava.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
+20
-1
No files found.
app/build.gradle.kts
View file @
2f02f9a5
...
...
@@ -98,7 +98,7 @@ dependencies {
implementation
(
"io.noties.markwon:image:${vMarkwon}"
)
implementation
(
"com.caverock:androidsvg:1.4"
)
val
vLibsu
=
"2.5.
1
"
val
vLibsu
=
"2.5.
2
"
implementation
(
"com.github.topjohnwu.libsu:core:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:io:${vLibsu}"
)
...
...
app/src/main/java/com/topjohnwu/magisk/core/App.kt
View file @
2f02f9a5
...
...
@@ -12,6 +12,7 @@ import com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.DynAPK
import
com.topjohnwu.magisk.FileProvider
import
com.topjohnwu.magisk.core.su.SuCallbackHandler
import
com.topjohnwu.magisk.core.utils.IODispatcherExecutor
import
com.topjohnwu.magisk.core.utils.RootInit
import
com.topjohnwu.magisk.core.utils.updateConfig
import
com.topjohnwu.magisk.di.koinModules
...
...
@@ -31,8 +32,9 @@ open class App() : Application() {
init
{
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
)
Shell
.
Config
.
setFlags
(
Shell
.
FLAG_MOUNT_MASTER
)
Shell
.
Config
.
add
Initializers
(
RootInit
::
class
.
java
)
Shell
.
Config
.
set
Initializers
(
RootInit
::
class
.
java
)
Shell
.
Config
.
setTimeout
(
2
)
Shell
.
EXECUTOR
=
IODispatcherExecutor
()
FileProvider
.
callHandler
=
SuCallbackHandler
// Always log full stack trace with Timber
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/RemoteFileService.kt
View file @
2f02f9a5
...
...
@@ -9,11 +9,11 @@ import com.topjohnwu.magisk.core.ForegroundTracker
import
com.topjohnwu.magisk.core.utils.ProgressInputStream
import
com.topjohnwu.magisk.core.view.Notifications
import
com.topjohnwu.magisk.data.network.GithubRawServices
import
com.topjohnwu.magisk.ktx.checkSum
import
com.topjohnwu.magisk.ktx.writeTo
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Module
import
com.topjohnwu.superuser.ShellUtils
import
kotlinx.coroutines.launch
import
okhttp3.ResponseBody
import
org.koin.android.ext.android.inject
...
...
@@ -48,7 +48,7 @@ abstract class RemoteFileService : NotificationService() {
private
suspend
fun
start
(
subject
:
DownloadSubject
)
{
if
(
subject
!
is
Magisk
||
!
subject
.
file
.
exists
()
||
!
ShellUtils
.
checkSum
(
"MD5"
,
subject
.
file
,
subject
.
magisk
.
md5
))
{
!
subject
.
file
.
checkSum
(
"MD5"
,
subject
.
magisk
.
md5
))
{
val
stream
=
service
.
fetchFile
(
subject
.
url
).
toProgressStream
(
subject
)
when
(
subject
)
{
is
Module
->
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/IODispatcherExecutor.kt
0 → 100644
View file @
2f02f9a5
package
com.topjohnwu.magisk.core.utils
import
kotlinx.coroutines.*
import
java.util.concurrent.*
class
IODispatcherExecutor
:
AbstractExecutorService
()
{
private
val
job
=
SupervisorJob
().
apply
{
invokeOnCompletion
{
future
.
run
()
}
}
private
val
scope
=
CoroutineScope
(
job
+
Dispatchers
.
IO
)
private
val
future
=
FutureTask
(
Callable
{
true
})
override
fun
execute
(
command
:
Runnable
)
{
scope
.
launch
{
command
.
run
()
}
}
override
fun
shutdown
()
=
job
.
cancel
()
override
fun
shutdownNow
():
List
<
Runnable
>
{
job
.
cancel
()
return
emptyList
()
}
override
fun
isShutdown
()
=
job
.
isCancelled
override
fun
isTerminated
()
=
job
.
isCancelled
&&
job
.
isCompleted
override
fun
awaitTermination
(
timeout
:
Long
,
unit
:
TimeUnit
):
Boolean
{
return
try
{
future
.
get
(
timeout
,
unit
)
}
catch
(
e
:
TimeoutException
)
{
false
}
}
}
app/src/main/java/com/topjohnwu/magisk/ktx/XJava.kt
View file @
2f02f9a5
...
...
@@ -8,10 +8,12 @@ import java.io.InputStream
import
java.io.OutputStream
import
java.lang.reflect.Field
import
java.lang.reflect.Method
import
java.security.MessageDigest
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.zip.ZipEntry
import
java.util.zip.ZipInputStream
import
kotlin.experimental.and
fun
ZipInputStream
.
forEach
(
callback
:
(
ZipEntry
)
->
Unit
)
{
var
entry
:
ZipEntry
?
=
nextEntry
...
...
@@ -24,6 +26,23 @@ fun ZipInputStream.forEach(callback: (ZipEntry) -> Unit) {
fun
InputStream
.
writeTo
(
file
:
File
)
=
withStreams
(
this
,
file
.
outputStream
())
{
reader
,
writer
->
reader
.
copyTo
(
writer
)
}
fun
File
.
checkSum
(
alg
:
String
,
reference
:
String
)
=
runCatching
{
inputStream
().
use
{
val
digest
=
MessageDigest
.
getInstance
(
alg
)
it
.
copyTo
(
object
:
OutputStream
()
{
override
fun
write
(
b
:
Int
)
{
digest
.
update
(
b
.
toByte
())
}
override
fun
write
(
b
:
ByteArray
,
off
:
Int
,
len
:
Int
)
{
digest
.
update
(
b
,
off
,
len
)
}
})
val
sb
=
StringBuilder
()
digest
.
digest
().
forEach
{
b
->
sb
.
append
(
"%02x"
.
format
(
b
and
0
xff
.
toByte
()))
}
sb
.
toString
()
==
reference
}
}.
getOrElse
{
false
}
inline
fun
<
In
:
InputStream
,
Out
:
OutputStream
>
withStreams
(
inStream
:
In
,
outStream
:
Out
,
...
...
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