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
3c783448
Commit
3c783448
authored
Jun 28, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor version handling
parent
594f2688
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
29 deletions
+36
-29
build.gradle
app/build.gradle
+1
-0
Const.kt
app/src/main/java/com/topjohnwu/magisk/core/Const.kt
+5
-3
SuRequestHandler.kt
...ain/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
+1
-2
PatchAPK.kt
...src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt
+1
-2
RootInit.kt
...src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt
+27
-22
manager.sh
app/src/main/res/raw/manager.sh
+1
-0
No files found.
app/build.gradle
View file @
3c783448
...
@@ -22,6 +22,7 @@ android {
...
@@ -22,6 +22,7 @@ android {
multiDexEnabled
true
multiDexEnabled
true
versionName
props
[
'appVersion'
]
versionName
props
[
'appVersion'
]
versionCode
props
[
'appVersionCode'
]
as
Integer
versionCode
props
[
'appVersionCode'
]
as
Integer
buildConfigField
'int'
,
'LATEST_MAGISK'
,
props
[
'versionCode'
]
?:
'Integer.MAX_VALUE'
javaCompileOptions
{
javaCompileOptions
{
annotationProcessorOptions
{
annotationProcessorOptions
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/Const.kt
View file @
3c783448
package
com.topjohnwu.magisk.core
package
com.topjohnwu.magisk.core
import
android.os.Process
import
android.os.Process
import
com.topjohnwu.magisk.BuildConfig
object
Const
{
object
Const
{
...
@@ -24,9 +25,10 @@ object Const {
...
@@ -24,9 +25,10 @@ object Const {
object
Version
{
object
Version
{
const
val
MIN_VERSION
=
"v19.0"
const
val
MIN_VERSION
=
"v19.0"
const
val
MIN_VERCODE
=
19000
const
val
MIN_VERCODE
=
19000
const
val
PROVIDER_CONNECT
=
20200
const
val
DYNAMIC_PATH
=
20400
fun
atLeast_20_2
()
=
Info
.
env
.
magiskVersionCode
>=
20200
const
val
SEPOLICY_REDESIGN
=
20416
fun
atLeast_20_4
()
=
Info
.
env
.
magiskVersionCode
>=
20400
fun
atLeastCanary
()
=
Info
.
env
.
magiskVersionCode
>
BuildConfig
.
LATEST_MAGISK
/
100
*
100
}
}
object
ID
{
object
ID
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
View file @
3c783448
...
@@ -9,7 +9,6 @@ import androidx.collection.ArrayMap
...
@@ -9,7 +9,6 @@ import androidx.collection.ArrayMap
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.magiskdb.PolicyDao
import
com.topjohnwu.magisk.core.magiskdb.PolicyDao
import
com.topjohnwu.magisk.core.model.MagiskPolicy
import
com.topjohnwu.magisk.core.model.MagiskPolicy
import
com.topjohnwu.magisk.core.model.toPolicy
import
com.topjohnwu.magisk.core.model.toPolicy
...
@@ -38,7 +37,7 @@ abstract class SuRequestHandler(
...
@@ -38,7 +37,7 @@ abstract class SuRequestHandler(
val
name
=
intent
.
getStringExtra
(
"socket"
)
?:
return
false
val
name
=
intent
.
getStringExtra
(
"socket"
)
?:
return
false
try
{
try
{
if
(
Info
.
env
.
magiskVersionCode
>=
Const
.
Version
.
SEPOLICY_REDESIGN
)
{
if
(
Const
.
Version
.
atLeastCanary
()
)
{
val
server
=
LocalServerSocket
(
name
)
val
server
=
LocalServerSocket
(
name
)
val
futureSocket
=
Shell
.
EXECUTOR
.
submit
(
Callable
{
server
.
accept
()
})
val
futureSocket
=
Shell
.
EXECUTOR
.
submit
(
Callable
{
server
.
accept
()
})
try
{
try
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt
View file @
3c783448
...
@@ -103,8 +103,7 @@ object PatchAPK {
...
@@ -103,8 +103,7 @@ object PatchAPK {
}
}
private
fun
patchAndHide
(
context
:
Context
,
label
:
String
):
Boolean
{
private
fun
patchAndHide
(
context
:
Context
,
label
:
String
):
Boolean
{
val
dlStub
=
!
isRunningAsStub
&&
SDK_INT
>=
28
&&
val
dlStub
=
!
isRunningAsStub
&&
SDK_INT
>=
28
&&
Const
.
Version
.
atLeast_20_2
()
Info
.
env
.
magiskVersionCode
>=
Const
.
Version
.
PROVIDER_CONNECT
val
src
=
if
(
dlStub
)
{
val
src
=
if
(
dlStub
)
{
val
stub
=
File
(
context
.
cacheDir
,
"stub.apk"
)
val
stub
=
File
(
context
.
cacheDir
,
"stub.apk"
)
val
svc
=
get
<
GithubRawServices
>()
val
svc
=
get
<
GithubRawServices
>()
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt
View file @
3c783448
...
@@ -16,30 +16,35 @@ class RootInit : Shell.Initializer() {
...
@@ -16,30 +16,35 @@ class RootInit : Shell.Initializer() {
}
}
fun
init
(
context
:
Context
,
shell
:
Shell
):
Boolean
{
fun
init
(
context
:
Context
,
shell
:
Shell
):
Boolean
{
val
job
=
shell
.
newJob
()
shell
.
newJob
().
apply
{
if
(
Info
.
env
.
magiskVersionCode
>=
Const
.
Version
.
DYNAMIC_PATH
)
{
if
(
Const
.
Version
.
atLeast_20_4
())
{
job
.
add
(
"export ASH_STANDALONE=1"
)
add
(
"MAGISKTMP=$(magisk --path)/.magisk"
)
.
add
(
"[ -x /data/adb/magisk/busybox ] && exec /data/adb/magisk/busybox sh"
)
}
else
{
.
add
(
"MAGISKTMP=$(magisk --path)/.magisk"
)
add
(
"MAGISKTMP=/sbin/.magisk"
)
}
else
{
}
job
.
add
(
"export PATH=\"/sbin/.magisk/busybox:\$PATH\""
)
if
(
Const
.
Version
.
atLeastCanary
())
{
.
add
(
"MAGISKTMP=/sbin/.magisk"
)
add
(
"export ASH_STANDALONE=1"
)
}
add
(
"[ -x /data/adb/magisk/busybox ] && exec /data/adb/magisk/busybox sh"
)
job
.
add
(
context
.
rawResource
(
R
.
raw
.
manager
))
}
else
{
if
(
shell
.
isRoot
)
{
add
(
"export PATH=\"\$MAGISKTMP/busybox:\$PATH\""
)
job
.
add
(
context
.
rawResource
(
R
.
raw
.
util_functions
))
}
}
add
(
context
.
rawResource
(
R
.
raw
.
manager
))
job
.
add
(
"mm_init"
).
exec
()
if
(
shell
.
isRoot
)
{
add
(
context
.
rawResource
(
R
.
raw
.
util_functions
))
}
add
(
"mm_init"
)
}.
exec
()
fun
getvar
(
name
:
String
)
=
ShellUtils
.
fastCmd
(
shell
,
"echo \$$name"
).
toBoolean
()
fun
getvar
(
name
:
String
)
=
ShellUtils
.
fastCmd
(
shell
,
"echo \$$name"
)
fun
getBool
(
name
:
String
)
=
getvar
(
name
).
toBoolean
()
Const
.
MAGISKTMP
=
ShellUtils
.
fastCmd
(
shell
,
"echo \$
MAGISKTMP"
)
Const
.
MAGISKTMP
=
getvar
(
"
MAGISKTMP"
)
Info
.
keepVerity
=
get
var
(
"KEEPVERITY"
)
Info
.
keepVerity
=
get
Bool
(
"KEEPVERITY"
)
Info
.
keepEnc
=
get
var
(
"KEEPFORCEENCRYPT"
)
Info
.
keepEnc
=
get
Bool
(
"KEEPFORCEENCRYPT"
)
Info
.
isSAR
=
get
var
(
"SYSTEM_ROOT"
)
Info
.
isSAR
=
get
Bool
(
"SYSTEM_ROOT"
)
Info
.
ramdisk
=
shell
.
newJob
().
add
(
"check_boot_ramdisk"
).
exec
().
isSuccess
Info
.
ramdisk
=
getBool
(
"RAMDISKEXIST"
)
Info
.
recovery
=
get
var
(
"RECOVERYMODE"
)
Info
.
recovery
=
get
Bool
(
"RECOVERYMODE"
)
Info
.
isAB
=
get
var
(
"ISAB"
)
Info
.
isAB
=
get
Bool
(
"ISAB"
)
return
true
return
true
}
}
...
...
app/src/main/res/raw/manager.sh
View file @
3c783448
...
@@ -145,4 +145,5 @@ mm_init() {
...
@@ -145,4 +145,5 @@ mm_init() {
get_flags
get_flags
run_migrations
run_migrations
SHA1
=
$(
grep_prop SHA1
$MAGISKTMP
/config
)
SHA1
=
$(
grep_prop SHA1
$MAGISKTMP
/config
)
check_boot_ramdisk
&&
RAMDISKEXIST
=
true
||
RAMDISKEXIST
=
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