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
9471577b
Commit
9471577b
authored
Feb 11, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly detect advanced device info
parent
e85d5e54
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
30 deletions
+37
-30
Info.kt
app/src/main/java/com/topjohnwu/magisk/core/Info.kt
+9
-6
RootInit.kt
...src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt
+5
-2
XAndroid.kt
...src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt
+0
-16
include_home_device.xml
app/src/main/res/layout/include_home_device.xml
+3
-6
manager.sh
app/src/main/res/raw/manager.sh
+20
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Info.kt
View file @
9471577b
...
@@ -24,12 +24,15 @@ object Info {
...
@@ -24,12 +24,15 @@ object Info {
@JvmStatic
@JvmStatic
var
stub
:
DynAPK
.
Data
?
=
null
// Stub
var
stub
:
DynAPK
.
Data
?
=
null
// Stub
@JvmStatic
// Toggle-able options
var
keepVerity
=
false
@JvmStatic
var
keepVerity
=
false
@JvmStatic
@JvmStatic
var
keepEnc
=
false
var
keepEnc
=
false
@JvmStatic
var
recovery
=
false
@JvmStatic
var
recovery
=
false
// Immutable device state
@JvmStatic
var
isSAR
=
false
@JvmStatic
var
isAB
=
false
@JvmStatic
var
ramdisk
=
false
val
isConnected
by
lazy
{
val
isConnected
by
lazy
{
KObservableField
(
false
).
also
{
field
->
KObservableField
(
false
).
also
{
field
->
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt
View file @
9471577b
...
@@ -26,17 +26,20 @@ class RootInit : Shell.Initializer() {
...
@@ -26,17 +26,20 @@ class RootInit : Shell.Initializer() {
}
}
job
.
add
(
job
.
add
(
"export BOOTMODE=true"
,
"mount_partitions"
,
"mount_partitions"
,
"get_flags"
,
"get_flags"
,
"run_migrations"
,
"run_migrations"
"export BOOTMODE=true"
).
exec
()
).
exec
()
fun
getvar
(
name
:
String
)
=
ShellUtils
.
fastCmd
(
shell
,
"echo \$$name"
).
toBoolean
()
fun
getvar
(
name
:
String
)
=
ShellUtils
.
fastCmd
(
shell
,
"echo \$$name"
).
toBoolean
()
Info
.
keepVerity
=
getvar
(
"KEEPVERITY"
)
Info
.
keepVerity
=
getvar
(
"KEEPVERITY"
)
Info
.
keepEnc
=
getvar
(
"KEEPFORCEENCRYPT"
)
Info
.
keepEnc
=
getvar
(
"KEEPFORCEENCRYPT"
)
Info
.
isSAR
=
getvar
(
"SYSTEM_ROOT"
)
Info
.
ramdisk
=
shell
.
newJob
().
add
(
"check_boot_ramdisk"
).
exec
().
isSuccess
Info
.
recovery
=
getvar
(
"RECOVERYMODE"
)
Info
.
recovery
=
getvar
(
"RECOVERYMODE"
)
Info
.
isAB
=
getvar
(
"ISAB"
)
return
true
return
true
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt
View file @
9471577b
...
@@ -38,10 +38,8 @@ import com.topjohnwu.magisk.core.utils.Utils
...
@@ -38,10 +38,8 @@ import com.topjohnwu.magisk.core.utils.Utils
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.core.utils.currentLocale
import
com.topjohnwu.magisk.utils.DynamicClassLoader
import
com.topjohnwu.magisk.utils.DynamicClassLoader
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
import
java.io.File
import
java.io.File
import
java.io.FileNotFoundException
import
java.io.FileNotFoundException
import
java.text.SimpleDateFormat
import
java.lang.reflect.Array
as
JArray
import
java.lang.reflect.Array
as
JArray
val
packageName
:
String
get
()
=
get
<
Context
>().
packageName
val
packageName
:
String
get
()
=
get
<
Context
>().
packageName
...
@@ -320,20 +318,6 @@ fun Context.hasPermissions(vararg permissions: String) = permissions.all {
...
@@ -320,20 +318,6 @@ fun Context.hasPermissions(vararg permissions: String) = permissions.all {
ContextCompat
.
checkSelfPermission
(
this
,
it
)
==
PERMISSION_GRANTED
ContextCompat
.
checkSelfPermission
(
this
,
it
)
==
PERMISSION_GRANTED
}
}
private
val
securityLevelFormatter
get
()
=
SimpleDateFormat
(
"yyyy-MM-dd"
,
currentLocale
)
val
isSAR
get
()
=
ShellUtils
.
fastCmd
(
"grep_prop ro.build.system_root_image"
)
.
let
{
it
.
isNotEmpty
()
&&
it
.
toBoolean
()
}
val
isAB
get
()
=
ShellUtils
.
fastCmd
(
"grep_prop ro.build.ab_update"
)
.
let
{
it
.
isNotEmpty
()
&&
it
.
toBoolean
()
}
fun
Activity
.
hideKeyboard
()
{
fun
Activity
.
hideKeyboard
()
{
val
view
=
currentFocus
?:
return
val
view
=
currentFocus
?:
return
getSystemService
<
InputMethodManager
>()
getSystemService
<
InputMethodManager
>()
...
...
app/src/main/res/layout/include_home_device.xml
View file @
9471577b
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
<import
type=
"android.os.Build"
/>
<import
type=
"android.os.Build"
/>
<import
type=
"com.topjohnwu.magisk.extensions.XAndroidKt"
/>
<import
type=
"com.topjohnwu.magisk.extensions.XSUKt"
/>
<import
type=
"com.topjohnwu.magisk.extensions.XSUKt"
/>
<import
type=
"com.topjohnwu.magisk.R"
/>
<import
type=
"com.topjohnwu.magisk.R"
/>
...
@@ -186,7 +184,6 @@
...
@@ -186,7 +184,6 @@
<com.google.android.material.card.MaterialCardView
<com.google.android.material.card.MaterialCardView
style=
"@style/W.Home.Card"
style=
"@style/W.Home.Card"
goneUnless=
"@{XSUKt.hasRoot}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
android:layout_height=
"wrap_content"
>
...
@@ -220,7 +217,7 @@
...
@@ -220,7 +217,7 @@
<androidx.appcompat.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/W.Home.ItemContent.Right"
style=
"@style/W.Home.ItemContent.Right"
android:text=
"@{
XAndroidKt
.isAB ? @string/yes : @string/no}"
android:text=
"@{
Info
.isAB ? @string/yes : @string/no}"
tools:text=
"Yes"
/>
tools:text=
"Yes"
/>
</LinearLayout>
</LinearLayout>
...
@@ -237,7 +234,7 @@
...
@@ -237,7 +234,7 @@
<androidx.appcompat.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/W.Home.ItemContent.Right"
style=
"@style/W.Home.ItemContent.Right"
android:text=
"@{
XAndroidKt
.isSAR ? @string/yes : @string/no}"
android:text=
"@{
Info
.isSAR ? @string/yes : @string/no}"
tools:text=
"Yes"
/>
tools:text=
"Yes"
/>
</LinearLayout>
</LinearLayout>
...
@@ -254,7 +251,7 @@
...
@@ -254,7 +251,7 @@
<androidx.appcompat.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
style=
"@style/W.Home.ItemContent.Right"
style=
"@style/W.Home.ItemContent.Right"
android:text=
"@{Info.r
ecovery ? @string/no : @string/yes
}"
android:text=
"@{Info.r
amdisk ? @string/yes : @string/no
}"
tools:text=
"Yes"
/>
tools:text=
"Yes"
/>
</LinearLayout>
</LinearLayout>
...
...
app/src/main/res/raw/manager.sh
View file @
9471577b
...
@@ -122,6 +122,26 @@ force_pm_install() {
...
@@ -122,6 +122,26 @@ force_pm_install() {
return
$res
return
$res
}
}
check_boot_ramdisk
()
{
# Create boolean ISAB
[
-z
$SLOT
]
&&
ISAB
=
false
||
ISAB
=
true
# If we are running as recovery mode, then we do not have ramdisk in boot
$RECOVERYMODE
&&
return
1
# If we are A/B, then we must have ramdisk
$ISAB
&&
return
0
# If we are using legacy SAR, but not AB, we do not have ramdisk in boot
if
grep
' / '
/proc/mounts |
grep
-q
'/dev/root'
;
then
# Override recovery mode to true
RECOVERYMODE
=
true
return
1
fi
return
0
}
##########################
##########################
# Non-root util_functions
# Non-root util_functions
##########################
##########################
...
...
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