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
3e915676
Commit
3e915676
authored
Dec 20, 2020
by
vvb2060
Committed by
topjohnwu
Dec 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a suffix to magisk_patched.img
prevent it from being used as input file
parent
0b4dd63d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
MagiskInstaller.kt
...n/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
+25
-6
No files found.
app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
View file @
3e915676
...
@@ -8,6 +8,7 @@ import android.widget.Toast
...
@@ -8,6 +8,7 @@ import android.widget.Toast
import
androidx.annotation.WorkerThread
import
androidx.annotation.WorkerThread
import
androidx.core.os.postDelayed
import
androidx.core.os.postDelayed
import
androidx.localbroadcastmanager.content.LocalBroadcastManager
import
androidx.localbroadcastmanager.content.LocalBroadcastManager
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
...
@@ -41,6 +42,8 @@ import org.koin.core.inject
...
@@ -41,6 +42,8 @@ import org.koin.core.inject
import
timber.log.Timber
import
timber.log.Timber
import
java.io.*
import
java.io.*
import
java.nio.ByteBuffer
import
java.nio.ByteBuffer
import
java.security.SecureRandom
import
java.util.*
import
java.util.zip.ZipEntry
import
java.util.zip.ZipEntry
import
java.util.zip.ZipInputStream
import
java.util.zip.ZipInputStream
...
@@ -108,6 +111,8 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -108,6 +111,8 @@ abstract class MagiskInstallImpl : KoinComponent {
}
}
console
.
add
(
"- Device platform: "
+
Build
.
CPU_ABI
)
console
.
add
(
"- Device platform: "
+
Build
.
CPU_ABI
)
console
.
add
(
"- Magisk Manager: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
)
console
.
add
(
"- Install target: ${Info.remote.magisk.version} (${Info.remote.magisk.versionCode})"
)
try
{
try
{
ZipInputStream
(
zipUri
.
inputStream
().
buffered
()).
use
{
zi
->
ZipInputStream
(
zipUri
.
inputStream
().
buffered
()).
use
{
zi
->
...
@@ -226,7 +231,7 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -226,7 +231,7 @@ abstract class MagiskInstallImpl : KoinComponent {
private
fun
handleFile
(
uri
:
Uri
):
Boolean
{
private
fun
handleFile
(
uri
:
Uri
):
Boolean
{
val
outStream
:
OutputStream
val
outStream
:
OutputStream
va
l
outFile
:
MediaStoreUtils
.
UriFile
va
r
outFile
:
MediaStoreUtils
.
UriFile
?
=
null
// Process input file
// Process input file
try
{
try
{
...
@@ -238,27 +243,40 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -238,27 +243,40 @@ abstract class MagiskInstallImpl : KoinComponent {
return
false
return
false
}
}
src
.
reset
()
src
.
reset
()
val
alpha
=
"abcdefghijklmnopqrstuvwxyz"
val
alphaNum
=
"$alpha${alpha.toUpperCase(Locale.ROOT)}0123456789"
val
random
=
SecureRandom
()
val
suffix
=
StringBuilder
()
for
(
i
in
1
..
5
)
{
suffix
.
append
(
alphaNum
[
random
.
nextInt
(
alphaNum
.
length
)])
}
val
filename
=
"magisk_patched_$suffix"
outStream
=
if
(
magic
.
contentEquals
(
"ustar"
.
toByteArray
()))
{
outStream
=
if
(
magic
.
contentEquals
(
"ustar"
.
toByteArray
()))
{
outFile
=
MediaStoreUtils
.
getFile
(
"
magisk_patched
.tar"
)
outFile
=
MediaStoreUtils
.
getFile
(
"
$filename
.tar"
)
handleTar
(
src
,
outFile
.
uri
.
outputStream
())
handleTar
(
src
,
outFile
!!
.
uri
.
outputStream
())
}
else
{
}
else
{
// Raw image
// Raw image
srcBoot
=
File
(
installDir
,
"boot.img"
).
path
srcBoot
=
File
(
installDir
,
"boot.img"
).
path
console
.
add
(
"- Copying image to cache"
)
console
.
add
(
"- Copying image to cache"
)
FileOutputStream
(
srcBoot
).
use
{
src
.
copyTo
(
it
)
}
FileOutputStream
(
srcBoot
).
use
{
src
.
copyTo
(
it
)
}
outFile
=
MediaStoreUtils
.
getFile
(
"
magisk_patched
.img"
)
outFile
=
MediaStoreUtils
.
getFile
(
"
$filename
.img"
)
outFile
.
uri
.
outputStream
()
outFile
!!
.
uri
.
outputStream
()
}
}
}
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
console
.
add
(
"! Process error"
)
console
.
add
(
"! Process error"
)
outFile
?.
delete
()
Timber
.
e
(
e
)
Timber
.
e
(
e
)
return
false
return
false
}
}
// Patch file
// Patch file
if
(!
patchBoot
())
if
(!
patchBoot
())
{
outFile
!!
.
delete
()
return
false
return
false
}
// Output file
// Output file
try
{
try
{
...
@@ -277,6 +295,7 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -277,6 +295,7 @@ abstract class MagiskInstallImpl : KoinComponent {
console
.
add
(
"****************************"
)
console
.
add
(
"****************************"
)
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
console
.
add
(
"! Failed to output to $outFile"
)
console
.
add
(
"! Failed to output to $outFile"
)
outFile
!!
.
delete
()
Timber
.
e
(
e
)
Timber
.
e
(
e
)
return
false
return
false
}
}
...
...
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