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
04920883
Commit
04920883
authored
Oct 10, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change code for handling tar files
parent
5e44b0b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
MagiskInstaller.kt
...c/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.kt
+14
-13
No files found.
app/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.kt
View file @
04920883
...
...
@@ -24,9 +24,11 @@ import org.kamranzafar.jtar.TarHeader
import
org.kamranzafar.jtar.TarInputStream
import
org.kamranzafar.jtar.TarOutputStream
import
timber.log.Timber
import
java.io.*
import
java.io.File
import
java.io.FileOutputStream
import
java.io.IOException
import
java.io.InputStream
import
java.nio.ByteBuffer
import
java.util.*
import
java.util.zip.ZipEntry
import
java.util.zip.ZipInputStream
...
...
@@ -39,7 +41,7 @@ abstract class MagiskInstaller {
private
val
console
:
MutableList
<
String
>
private
val
logs
:
MutableList
<
String
>
private
var
isTar
=
false
private
var
tarOut
:
TarOutputStream
?
=
null
private
val
service
:
GithubRawServices
by
inject
()
private
val
context
:
Context
by
inject
()
...
...
@@ -150,7 +152,9 @@ abstract class MagiskInstaller {
private
fun
handleTar
(
input
:
InputStream
)
{
console
.
add
(
"- Processing tar file"
)
var
vbmeta
=
false
withStreams
(
TarInputStream
(
input
),
TarOutputStream
(
destFile
))
{
tarIn
,
tarOut
->
val
tarOut
=
TarOutputStream
(
destFile
)
this
.
tarOut
=
tarOut
TarInputStream
(
input
).
use
{
tarIn
->
lateinit
var
entry
:
TarEntry
while
(
tarIn
.
nextEntry
?.
let
{
entry
=
it
}
!=
null
)
{
if
(
entry
.
name
.
contains
(
"boot.img"
)
||
entry
.
name
.
contains
(
"recovery.img"
))
{
...
...
@@ -214,8 +218,7 @@ abstract class MagiskInstaller {
return
false
}
it
.
reset
()
if
(
Arrays
.
equals
(
magic
,
"ustar"
.
toByteArray
()))
{
isTar
=
true
if
(
magic
.
contentEquals
(
"ustar"
.
toByteArray
()))
{
destFile
=
File
(
Config
.
downloadDirectory
,
"magisk_patched.tar"
)
handleTar
(
it
)
}
else
{
...
...
@@ -292,15 +295,13 @@ abstract class MagiskInstaller {
protected
fun
storeBoot
():
Boolean
{
val
patched
=
SuFile
.
open
(
installDir
,
"new-boot.img"
)
try
{
val
os
:
OutputStream
if
(
isTar
)
{
os
=
TarOutputStream
(
destFile
,
true
)
os
.
putNextEntry
(
newEntry
(
val
os
=
tarOut
?.
let
{
it
.
putNextEntry
(
newEntry
(
if
(
srcBoot
.
contains
(
"recovery"
))
"recovery.img"
else
"boot.img"
,
patched
.
length
()))
}
else
{
os
=
destFile
.
outputStream
()
}
tarOut
=
null
it
}
?:
destFile
.
outputStream
()
patched
.
suInputStream
().
use
{
it
.
copyTo
(
os
);
os
.
close
()
}
}
catch
(
e
:
IOException
)
{
console
.
add
(
"! Failed to output to $destFile"
)
...
...
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