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
67f8dc49
Commit
67f8dc49
authored
Oct 06, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly patch vbmeta.img
Close #3241
parent
3e4caabe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
build.gradle.kts
app/build.gradle.kts
+3
-2
MagiskInstaller.kt
...n/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
+25
-9
build.gradle.kts
build.gradle.kts
+1
-1
No files found.
app/build.gradle.kts
View file @
67f8dc49
...
@@ -82,6 +82,7 @@ dependencies {
...
@@ -82,6 +82,7 @@ dependencies {
implementation
(
"com.github.topjohnwu:jtar:1.0.0"
)
implementation
(
"com.github.topjohnwu:jtar:1.0.0"
)
implementation
(
"com.github.topjohnwu:indeterminate-checkbox:1.0.7"
)
implementation
(
"com.github.topjohnwu:indeterminate-checkbox:1.0.7"
)
implementation
(
"com.github.topjohnwu:lz4-java:1.7.1"
)
implementation
(
"com.jakewharton.timber:timber:4.7.1"
)
implementation
(
"com.jakewharton.timber:timber:4.7.1"
)
val
vBAdapt
=
"4.0.0"
val
vBAdapt
=
"4.0.0"
...
@@ -118,7 +119,7 @@ dependencies {
...
@@ -118,7 +119,7 @@ dependencies {
implementation
(
"com.squareup.okhttp3:logging-interceptor:${vOkHttp}"
)
implementation
(
"com.squareup.okhttp3:logging-interceptor:${vOkHttp}"
)
implementation
(
"com.squareup.okhttp3:okhttp-dnsoverhttps:${vOkHttp}"
)
implementation
(
"com.squareup.okhttp3:okhttp-dnsoverhttps:${vOkHttp}"
)
val
vMoshi
=
"1.1
0
.0"
val
vMoshi
=
"1.1
1
.0"
implementation
(
"com.squareup.moshi:moshi:${vMoshi}"
)
implementation
(
"com.squareup.moshi:moshi:${vMoshi}"
)
kapt
(
"com.squareup.moshi:moshi-kotlin-codegen:${vMoshi}"
)
kapt
(
"com.squareup.moshi:moshi-kotlin-codegen:${vMoshi}"
)
...
@@ -141,7 +142,7 @@ dependencies {
...
@@ -141,7 +142,7 @@ dependencies {
implementation
(
"androidx.work:work-runtime-ktx:2.4.0"
)
implementation
(
"androidx.work:work-runtime-ktx:2.4.0"
)
implementation
(
"androidx.transition:transition:1.3.1"
)
implementation
(
"androidx.transition:transition:1.3.1"
)
implementation
(
"androidx.multidex:multidex:2.0.1"
)
implementation
(
"androidx.multidex:multidex:2.0.1"
)
implementation
(
"androidx.core:core-ktx:1.3.
1
"
)
implementation
(
"androidx.core:core-ktx:1.3.
2
"
)
implementation
(
"androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"
)
implementation
(
"androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"
)
implementation
(
"com.google.android.material:material:1.2.1"
)
implementation
(
"com.google.android.material:material:1.2.1"
)
}
}
app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
View file @
67f8dc49
...
@@ -29,6 +29,7 @@ import com.topjohnwu.superuser.io.SuFileInputStream
...
@@ -29,6 +29,7 @@ import com.topjohnwu.superuser.io.SuFileInputStream
import
com.topjohnwu.superuser.io.SuFileOutputStream
import
com.topjohnwu.superuser.io.SuFileOutputStream
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
net.jpountz.lz4.LZ4FrameInputStream
import
org.kamranzafar.jtar.TarEntry
import
org.kamranzafar.jtar.TarEntry
import
org.kamranzafar.jtar.TarHeader
import
org.kamranzafar.jtar.TarHeader
import
org.kamranzafar.jtar.TarInputStream
import
org.kamranzafar.jtar.TarInputStream
...
@@ -38,6 +39,7 @@ import org.koin.core.get
...
@@ -38,6 +39,7 @@ import org.koin.core.get
import
org.koin.core.inject
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.util.zip.ZipEntry
import
java.util.zip.ZipEntry
import
java.util.zip.ZipInputStream
import
java.util.zip.ZipInputStream
...
@@ -97,8 +99,7 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -97,8 +99,7 @@ abstract class MagiskInstallImpl : KoinComponent {
@Suppress
(
"DEPRECATION"
)
@Suppress
(
"DEPRECATION"
)
private
fun
extractZip
():
Boolean
{
private
fun
extractZip
():
Boolean
{
val
arch
:
String
val
arch
=
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
{
arch
=
if
(
Build
.
VERSION
.
SDK_INT
>=
21
)
{
val
abis
=
listOf
(*
Build
.
SUPPORTED_ABIS
)
val
abis
=
listOf
(*
Build
.
SUPPORTED_ABIS
)
if
(
abis
.
contains
(
"x86"
))
"x86"
else
"arm"
if
(
abis
.
contains
(
"x86"
))
"x86"
else
"arm"
}
else
{
}
else
{
...
@@ -163,21 +164,36 @@ abstract class MagiskInstallImpl : KoinComponent {
...
@@ -163,21 +164,36 @@ abstract class MagiskInstallImpl : KoinComponent {
val
tarOut
=
TarOutputStream
(
output
)
val
tarOut
=
TarOutputStream
(
output
)
TarInputStream
(
input
).
use
{
tarIn
->
TarInputStream
(
input
).
use
{
tarIn
->
lateinit
var
entry
:
TarEntry
lateinit
var
entry
:
TarEntry
fun
decompressedStream
()
=
if
(
entry
.
name
.
contains
(
".lz4"
))
LZ4FrameInputStream
(
tarIn
)
else
tarIn
while
(
tarIn
.
nextEntry
?.
let
{
entry
=
it
}
!=
null
)
{
while
(
tarIn
.
nextEntry
?.
let
{
entry
=
it
}
!=
null
)
{
if
(
entry
.
name
.
contains
(
"boot.img"
)
||
if
(
entry
.
name
.
contains
(
"boot.img"
)
||
(
Config
.
recovery
&&
entry
.
name
.
contains
(
"recovery.img"
)))
{
(
Config
.
recovery
&&
entry
.
name
.
contains
(
"recovery.img"
)))
{
val
name
=
entry
.
name
val
name
=
entry
.
name
.
replace
(
".lz4"
,
""
)
console
.
add
(
"-- Extracting: $name"
)
console
.
add
(
"-- Extracting: $name"
)
val
extract
=
File
(
installDir
,
name
)
val
extract
=
File
(
installDir
,
name
)
FileOutputStream
(
extract
).
use
{
tarIn
.
copyTo
(
it
)
}
FileOutputStream
(
extract
).
use
{
decompressedStream
().
copyTo
(
it
)
}
if
(
name
.
contains
(
".lz4"
))
{
}
else
if
(
entry
.
name
.
contains
(
"vbmeta.img"
))
{
console
.
add
(
"-- Decompressing: $name"
)
val
rawData
=
ByteArrayOutputStream
().
let
{
"./magiskboot decompress $extract"
.
sh
()
decompressedStream
().
copyTo
(
it
)
it
.
toByteArray
()
}
}
// Valid vbmeta.img should be at least 256 bytes
if
(
rawData
.
size
<
256
)
continue
// Patch flags to AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
console
.
add
(
"-- Patching: vbmeta.img"
)
ByteBuffer
.
wrap
(
rawData
).
putInt
(
120
,
2
)
tarOut
.
putNextEntry
(
newEntry
(
"vbmeta.img"
,
rawData
.
size
.
toLong
()))
tarOut
.
write
(
rawData
)
}
else
{
}
else
{
console
.
add
(
"-- Copying:
"
+
entry
.
name
)
console
.
add
(
"-- Copying:
${entry.name}"
)
tarOut
.
putNextEntry
(
entry
)
tarOut
.
putNextEntry
(
entry
)
tarIn
.
copyTo
(
tarOut
)
tarIn
.
copyTo
(
tarOut
,
bufferSize
=
1024
*
1024
)
}
}
}
}
val
boot
=
SuFile
.
open
(
installDir
,
"boot.img"
)
val
boot
=
SuFile
.
open
(
installDir
,
"boot.img"
)
...
...
build.gradle.kts
View file @
67f8dc49
...
@@ -19,7 +19,7 @@ buildscript {
...
@@ -19,7 +19,7 @@ buildscript {
dependencies
{
dependencies
{
classpath
(
"com.android.tools.build:gradle:4.0.1"
)
classpath
(
"com.android.tools.build:gradle:4.0.1"
)
classpath
(
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0"
)
classpath
(
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.
1
0"
)
classpath
(
"androidx.navigation:navigation-safe-args-gradle-plugin:${vNav}"
)
classpath
(
"androidx.navigation:navigation-safe-args-gradle-plugin:${vNav}"
)
// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place your application dependencies here; they belong
...
...
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