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
594c2acc
Commit
594c2acc
authored
Feb 05, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dependencies
parent
7acfac6a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
46 deletions
+40
-46
build.gradle.kts
app/build.gradle.kts
+7
-7
SplashActivity.kt
...src/main/java/com/topjohnwu/magisk/core/SplashActivity.kt
+2
-9
SuPolicy.kt
.../main/java/com/topjohnwu/magisk/core/model/su/SuPolicy.kt
+5
-3
MagiskInstaller.kt
...n/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
+5
-21
ZipUtils.kt
...src/main/java/com/topjohnwu/magisk/core/utils/ZipUtils.kt
+1
-1
SignBoot.java
app/src/main/java/com/topjohnwu/signing/SignBoot.java
+18
-3
build.gradle.kts
build.gradle.kts
+2
-2
No files found.
app/build.gradle.kts
View file @
594c2acc
...
@@ -201,13 +201,13 @@ dependencies {
...
@@ -201,13 +201,13 @@ dependencies {
implementation
(
"${bindingAdapter}:${vBAdapt}"
)
implementation
(
"${bindingAdapter}:${vBAdapt}"
)
implementation
(
"${bindingAdapter}-recyclerview:${vBAdapt}"
)
implementation
(
"${bindingAdapter}-recyclerview:${vBAdapt}"
)
val
vMarkwon
=
"4.6.
0
"
val
vMarkwon
=
"4.6.
1
"
implementation
(
"io.noties.markwon:core:${vMarkwon}"
)
implementation
(
"io.noties.markwon:core:${vMarkwon}"
)
implementation
(
"io.noties.markwon:html:${vMarkwon}"
)
implementation
(
"io.noties.markwon:html:${vMarkwon}"
)
implementation
(
"io.noties.markwon:image:${vMarkwon}"
)
implementation
(
"io.noties.markwon:image:${vMarkwon}"
)
implementation
(
"com.caverock:androidsvg:1.4"
)
implementation
(
"com.caverock:androidsvg:1.4"
)
val
vLibsu
=
"3.
0.2
"
val
vLibsu
=
"3.
1.0
"
implementation
(
"com.github.topjohnwu.libsu:core:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:core:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:io:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:io:${vLibsu}"
)
...
@@ -234,7 +234,7 @@ dependencies {
...
@@ -234,7 +234,7 @@ dependencies {
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}"
)
val
vRoom
=
"2.3.0-
alpha04
"
val
vRoom
=
"2.3.0-
beta01
"
implementation
(
"androidx.room:room-runtime:${vRoom}"
)
implementation
(
"androidx.room:room-runtime:${vRoom}"
)
implementation
(
"androidx.room:room-ktx:${vRoom}"
)
implementation
(
"androidx.room:room-ktx:${vRoom}"
)
kapt
(
"androidx.room:room-compiler:${vRoom}"
)
kapt
(
"androidx.room:room-compiler:${vRoom}"
)
...
@@ -243,16 +243,16 @@ dependencies {
...
@@ -243,16 +243,16 @@ dependencies {
implementation
(
"androidx.navigation:navigation-fragment-ktx:${vNav}"
)
implementation
(
"androidx.navigation:navigation-fragment-ktx:${vNav}"
)
implementation
(
"androidx.navigation:navigation-ui-ktx:${vNav}"
)
implementation
(
"androidx.navigation:navigation-ui-ktx:${vNav}"
)
implementation
(
"androidx.biometric:biometric:1.
0.1
"
)
implementation
(
"androidx.biometric:biometric:1.
1.0
"
)
implementation
(
"androidx.constraintlayout:constraintlayout:2.0.4"
)
implementation
(
"androidx.constraintlayout:constraintlayout:2.0.4"
)
implementation
(
"androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
)
implementation
(
"androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
)
implementation
(
"androidx.browser:browser:1.3.0"
)
implementation
(
"androidx.browser:browser:1.3.0"
)
implementation
(
"androidx.preference:preference:1.1.1"
)
implementation
(
"androidx.preference:preference:1.1.1"
)
implementation
(
"androidx.recyclerview:recyclerview:1.1.0"
)
implementation
(
"androidx.recyclerview:recyclerview:1.1.0"
)
implementation
(
"androidx.fragment:fragment-ktx:1.2.5"
)
implementation
(
"androidx.fragment:fragment-ktx:1.2.5"
)
implementation
(
"androidx.work:work-runtime-ktx:2.
4
.0"
)
implementation
(
"androidx.work:work-runtime-ktx:2.
5
.0"
)
implementation
(
"androidx.transition:transition:1.
3.1
"
)
implementation
(
"androidx.transition:transition:1.
4.0
"
)
implementation
(
"androidx.multidex:multidex:2.0.1"
)
implementation
(
"androidx.multidex:multidex:2.0.1"
)
implementation
(
"androidx.core:core-ktx:1.3.2"
)
implementation
(
"androidx.core:core-ktx:1.3.2"
)
implementation
(
"com.google.android.material:material:1.
2.1
"
)
implementation
(
"com.google.android.material:material:1.
3.0
"
)
}
}
app/src/main/java/com/topjohnwu/magisk/core/SplashActivity.kt
View file @
594c2acc
...
@@ -11,9 +11,6 @@ import com.topjohnwu.magisk.ui.MainActivity
...
@@ -11,9 +11,6 @@ import com.topjohnwu.magisk.ui.MainActivity
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
open
class
SplashActivity
:
Activity
()
{
open
class
SplashActivity
:
Activity
()
{
...
@@ -24,9 +21,8 @@ open class SplashActivity : Activity() {
...
@@ -24,9 +21,8 @@ open class SplashActivity : Activity() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
setTheme
(
R
.
style
.
SplashTheme
)
setTheme
(
R
.
style
.
SplashTheme
)
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
// Pre-initialize root shell
initAndStart
()
Shell
.
getShell
(
null
)
{
initAndStart
()
}
}
}
}
private
fun
handleRepackage
(
pkg
:
String
?)
{
private
fun
handleRepackage
(
pkg
:
String
?)
{
...
@@ -45,9 +41,6 @@ open class SplashActivity : Activity() {
...
@@ -45,9 +41,6 @@ open class SplashActivity : Activity() {
}
}
private
fun
initAndStart
()
{
private
fun
initAndStart
()
{
// Pre-initialize root shell
Shell
.
getShell
()
val
prevPkg
=
intent
.
getStringExtra
(
Const
.
Key
.
PREV_PKG
)
val
prevPkg
=
intent
.
getStringExtra
(
Const
.
Key
.
PREV_PKG
)
Config
.
load
(
prevPkg
)
Config
.
load
(
prevPkg
)
...
...
app/src/main/java/com/topjohnwu/magisk/core/model/su/SuPolicy.kt
View file @
594c2acc
@file
:
SuppressLint
(
"InlinedApi"
)
package
com.topjohnwu.magisk.core.model.su
package
com.topjohnwu.magisk.core.model.su
import
android.annotation.SuppressLint
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.INTERACTIVE
import
com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.INTERACTIVE
import
com.topjohnwu.magisk.ktx.getLabel
import
com.topjohnwu.magisk.ktx.getLabel
data class
SuPolicy
(
data class
SuPolicy
(
var
uid
:
Int
,
var
uid
:
Int
,
val
packageName
:
String
,
val
packageName
:
String
,
...
@@ -38,7 +40,7 @@ fun SuPolicy.toMap() = mapOf(
...
@@ -38,7 +40,7 @@ fun SuPolicy.toMap() = mapOf(
fun
Map
<
String
,
String
>.
toPolicy
(
pm
:
PackageManager
):
SuPolicy
{
fun
Map
<
String
,
String
>.
toPolicy
(
pm
:
PackageManager
):
SuPolicy
{
val
uid
=
get
(
"uid"
)
?.
toIntOrNull
()
?:
-
1
val
uid
=
get
(
"uid"
)
?.
toIntOrNull
()
?:
-
1
val
packageName
=
get
(
"package_name"
).
orEmpty
()
val
packageName
=
get
(
"package_name"
).
orEmpty
()
val
info
=
pm
.
getApplicationInfo
(
packageName
,
PackageManager
.
GET
_UNINSTALLED_PACKAGES
)
val
info
=
pm
.
getApplicationInfo
(
packageName
,
PackageManager
.
MATCH
_UNINSTALLED_PACKAGES
)
if
(
info
.
uid
!=
uid
)
if
(
info
.
uid
!=
uid
)
throw
PackageManager
.
NameNotFoundException
()
throw
PackageManager
.
NameNotFoundException
()
...
@@ -59,7 +61,7 @@ fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
...
@@ -59,7 +61,7 @@ fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
fun
Int
.
toPolicy
(
pm
:
PackageManager
,
policy
:
Int
=
INTERACTIVE
):
SuPolicy
{
fun
Int
.
toPolicy
(
pm
:
PackageManager
,
policy
:
Int
=
INTERACTIVE
):
SuPolicy
{
val
pkg
=
pm
.
getPackagesForUid
(
this
)
?.
firstOrNull
()
val
pkg
=
pm
.
getPackagesForUid
(
this
)
?.
firstOrNull
()
?:
throw
PackageManager
.
NameNotFoundException
()
?:
throw
PackageManager
.
NameNotFoundException
()
val
info
=
pm
.
getApplicationInfo
(
pkg
,
PackageManager
.
GET
_UNINSTALLED_PACKAGES
)
val
info
=
pm
.
getApplicationInfo
(
pkg
,
PackageManager
.
MATCH
_UNINSTALLED_PACKAGES
)
return
SuPolicy
(
return
SuPolicy
(
uid
=
info
.
uid
,
uid
=
info
.
uid
,
packageName
=
pkg
,
packageName
=
pkg
,
...
...
app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
View file @
594c2acc
...
@@ -27,6 +27,7 @@ import com.topjohnwu.superuser.ShellUtils
...
@@ -27,6 +27,7 @@ import com.topjohnwu.superuser.ShellUtils
import
com.topjohnwu.superuser.internal.NOPList
import
com.topjohnwu.superuser.internal.NOPList
import
com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.io.SuFile
import
com.topjohnwu.superuser.io.SuFile
import
com.topjohnwu.superuser.io.SuFileInputStream
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
net.jpountz.lz4.LZ4FrameInputStream
import
net.jpountz.lz4.LZ4FrameInputStream
...
@@ -292,24 +293,6 @@ abstract class MagiskInstallImpl protected constructor(
...
@@ -292,24 +293,6 @@ abstract class MagiskInstallImpl protected constructor(
return
true
return
true
}
}
private
fun
rootInputStream
(
file
:
File
):
InputStream
{
return
if
(
file
is
SuFile
)
object
:
BufferedInputStream
(
null
)
{
private
val
tmp
=
File
.
createTempFile
(
file
.
name
,
null
,
context
.
cacheDir
).
also
{
// Copy to tmp file and read from there
"cat $file > $it"
.
sh
()
`in`
=
it
.
inputStream
()
}
override
fun
close
()
{
super
.
close
()
tmp
.
delete
()
}
}
else
file
.
inputStream
().
buffered
()
}
private
fun
patchBoot
():
Boolean
{
private
fun
patchBoot
():
Boolean
{
val
inRootDir
=
shell
.
isRoot
&&
Info
.
noDataExec
val
inRootDir
=
shell
.
isRoot
&&
Info
.
noDataExec
...
@@ -335,7 +318,7 @@ abstract class MagiskInstallImpl protected constructor(
...
@@ -335,7 +318,7 @@ abstract class MagiskInstallImpl protected constructor(
var
isSigned
=
false
var
isSigned
=
false
if
(
srcBoot
.
let
{
it
!
is
SuFile
||
!
it
.
isCharacter
})
{
if
(
srcBoot
.
let
{
it
!
is
SuFile
||
!
it
.
isCharacter
})
{
try
{
try
{
rootInputStream
(
srcBoot
).
use
{
SuFileInputStream
.
open
(
srcBoot
).
use
{
if
(
SignBoot
.
verifySignature
(
it
,
null
))
{
if
(
SignBoot
.
verifySignature
(
it
,
null
))
{
isSigned
=
true
isSigned
=
true
console
.
add
(
"- Boot image is signed with AVB 1.0"
)
console
.
add
(
"- Boot image is signed with AVB 1.0"
)
...
@@ -361,8 +344,9 @@ abstract class MagiskInstallImpl protected constructor(
...
@@ -361,8 +344,9 @@ abstract class MagiskInstallImpl protected constructor(
console
.
add
(
"- Signing boot image with verity keys"
)
console
.
add
(
"- Signing boot image with verity keys"
)
val
signed
=
File
.
createTempFile
(
"signed"
,
".img"
,
context
.
cacheDir
)
val
signed
=
File
.
createTempFile
(
"signed"
,
".img"
,
context
.
cacheDir
)
try
{
try
{
withStreams
(
rootInputStream
(
newBootImg
),
signed
.
outputStream
().
buffered
())
{
withStreams
(
SuFileInputStream
.
open
(
newBootImg
).
buffered
(),
src
,
out
->
SignBoot
.
doSignature
(
null
,
null
,
src
,
out
,
"/boot"
)
signed
.
outputStream
().
buffered
())
{
src
,
out
->
SignBoot
.
doSignature
(
null
,
null
,
src
,
out
,
"/boot"
)
}
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
console
.
add
(
"! Unable to sign image"
)
console
.
add
(
"! Unable to sign image"
)
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/ZipUtils.kt
View file @
594c2acc
...
@@ -36,7 +36,7 @@ fun InputStream.unzip(folder: File, path: String, junkPath: Boolean) {
...
@@ -36,7 +36,7 @@ fun InputStream.unzip(folder: File, path: String, junkPath: Boolean) {
dest
=
SuFile
(
folder
,
name
)
dest
=
SuFile
(
folder
,
name
)
dest
.
parentFile
!!
.
mkdirs
()
dest
.
parentFile
!!
.
mkdirs
()
}
}
SuFileOutputStream
(
dest
).
use
{
out
->
zin
.
copyTo
(
out
)
}
SuFileOutputStream
.
open
(
dest
).
use
{
out
->
zin
.
copyTo
(
out
)
}
}
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
app/src/main/java/com/topjohnwu/signing/SignBoot.java
View file @
594c2acc
...
@@ -90,6 +90,21 @@ public class SignBoot {
...
@@ -90,6 +90,21 @@ public class SignBoot {
}
}
}
}
private
static
int
fullRead
(
InputStream
in
,
byte
[]
b
)
throws
IOException
{
return
fullRead
(
in
,
b
,
0
,
b
.
length
);
}
private
static
int
fullRead
(
InputStream
in
,
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
int
n
=
0
;
while
(
n
<
len
)
{
int
count
=
in
.
read
(
b
,
off
+
n
,
len
-
n
);
if
(
count
<=
0
)
break
;
n
+=
count
;
}
return
n
;
}
public
static
boolean
doSignature
(
public
static
boolean
doSignature
(
@Nullable
X509Certificate
cert
,
@Nullable
PrivateKey
key
,
@Nullable
X509Certificate
cert
,
@Nullable
PrivateKey
key
,
@NonNull
InputStream
imgIn
,
@NonNull
OutputStream
imgOut
,
@NonNull
String
target
@NonNull
InputStream
imgIn
,
@NonNull
OutputStream
imgOut
,
@NonNull
String
target
...
@@ -98,7 +113,7 @@ public class SignBoot {
...
@@ -98,7 +113,7 @@ public class SignBoot {
PushBackRWStream
in
=
new
PushBackRWStream
(
imgIn
,
imgOut
);
PushBackRWStream
in
=
new
PushBackRWStream
(
imgIn
,
imgOut
);
byte
[]
hdr
=
new
byte
[
BOOT_IMAGE_HEADER_SIZE_MAXIMUM
];
byte
[]
hdr
=
new
byte
[
BOOT_IMAGE_HEADER_SIZE_MAXIMUM
];
// First read the header
// First read the header
in
.
read
(
hdr
);
fullRead
(
in
,
hdr
);
int
signableSize
=
getSignableImageSize
(
hdr
);
int
signableSize
=
getSignableImageSize
(
hdr
);
// Unread header
// Unread header
in
.
unread
(
hdr
);
in
.
unread
(
hdr
);
...
@@ -128,7 +143,7 @@ public class SignBoot {
...
@@ -128,7 +143,7 @@ public class SignBoot {
try
{
try
{
// Read the header for size
// Read the header for size
byte
[]
hdr
=
new
byte
[
BOOT_IMAGE_HEADER_SIZE_MAXIMUM
];
byte
[]
hdr
=
new
byte
[
BOOT_IMAGE_HEADER_SIZE_MAXIMUM
];
if
(
imgIn
.
read
(
hdr
)
!=
hdr
.
length
)
{
if
(
fullRead
(
imgIn
,
hdr
)
!=
hdr
.
length
)
{
System
.
err
.
println
(
"Unable to read image header"
);
System
.
err
.
println
(
"Unable to read image header"
);
return
false
;
return
false
;
}
}
...
@@ -137,7 +152,7 @@ public class SignBoot {
...
@@ -137,7 +152,7 @@ public class SignBoot {
// Read the rest of the image
// Read the rest of the image
byte
[]
rawImg
=
Arrays
.
copyOf
(
hdr
,
signableSize
);
byte
[]
rawImg
=
Arrays
.
copyOf
(
hdr
,
signableSize
);
int
remain
=
signableSize
-
hdr
.
length
;
int
remain
=
signableSize
-
hdr
.
length
;
if
(
imgIn
.
read
(
rawImg
,
hdr
.
length
,
remain
)
!=
remain
)
{
if
(
fullRead
(
imgIn
,
rawImg
,
hdr
.
length
,
remain
)
!=
remain
)
{
System
.
err
.
println
(
"Unable to read image"
);
System
.
err
.
println
(
"Unable to read image"
);
return
false
;
return
false
;
}
}
...
...
build.gradle.kts
View file @
594c2acc
...
@@ -14,12 +14,12 @@ buildscript {
...
@@ -14,12 +14,12 @@ buildscript {
maven
{
url
=
uri
(
"https://kotlin.bintray.com/kotlinx"
)
}
maven
{
url
=
uri
(
"https://kotlin.bintray.com/kotlinx"
)
}
}
}
val
vNav
=
"2.3.
2
"
val
vNav
=
"2.3.
3
"
extra
[
"vNav"
]
=
vNav
extra
[
"vNav"
]
=
vNav
dependencies
{
dependencies
{
classpath
(
"com.android.tools.build:gradle:4.1.2"
)
classpath
(
"com.android.tools.build:gradle:4.1.2"
)
classpath
(
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.
21
"
)
classpath
(
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.
30
"
)
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