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
c0be5383
Commit
c0be5383
authored
Sep 15, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support enable/disable Zygisk
parent
3b8ce850
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
65 additions
and
22 deletions
+65
-22
Config.kt
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
+2
-0
BaseSettingsItem.kt
...java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt
+1
-1
SettingsItems.kt
...in/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
+24
-3
SettingsViewModel.kt
...ava/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
+1
-1
TextHolder.kt
app/src/main/java/com/topjohnwu/magisk/utils/TextHolder.kt
+15
-8
resources.xml
app/src/main/res/values/resources.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-0
bootstages.cpp
native/jni/core/bootstages.cpp
+7
-3
core.hpp
native/jni/core/core.hpp
+1
-0
db.cpp
native/jni/core/db.cpp
+1
-0
module.cpp
native/jni/core/module.cpp
+6
-4
db.hpp
native/jni/include/db.hpp
+4
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Config.kt
View file @
c0be5383
...
...
@@ -37,6 +37,7 @@ object Config : PreferenceModel, DBConfig {
const
val
SU_MULTIUSER_MODE
=
"multiuser_mode"
const
val
SU_MNT_NS
=
"mnt_ns"
const
val
SU_BIOMETRIC
=
"su_biometric"
const
val
ZYGISK
=
"zygisk"
const
val
SU_MANAGER
=
"requester"
const
val
KEYSTORE
=
"keystore"
...
...
@@ -143,6 +144,7 @@ object Config : PreferenceModel, DBConfig {
var
suMntNamespaceMode
by
dbSettings
(
Key
.
SU_MNT_NS
,
Value
.
NAMESPACE_MODE_REQUESTER
)
var
suMultiuserMode
by
dbSettings
(
Key
.
SU_MULTIUSER_MODE
,
Value
.
MULTIUSER_MODE_OWNER_ONLY
)
var
suBiometric
by
dbSettings
(
Key
.
SU_BIOMETRIC
,
false
)
var
zygisk
by
dbSettings
(
Key
.
ZYGISK
,
false
)
var
suManager
by
dbStrings
(
Key
.
SU_MANAGER
,
""
,
true
)
var
keyStoreRaw
by
dbStrings
(
Key
.
KEYSTORE
,
""
,
true
)
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt
View file @
c0be5383
...
...
@@ -34,7 +34,7 @@ sealed class BaseSettingsItem : ObservableRvItem() {
@get
:
Bindable
var
isEnabled
=
true
set
(
value
)
=
set
(
value
,
field
,
{
field
=
it
},
BR
.
enabled
)
set
(
value
)
=
set
(
value
,
field
,
{
field
=
it
},
BR
.
enabled
,
BR
.
description
)
open
fun
onPressed
(
view
:
View
,
callback
:
Callback
)
{
callback
.
onItemPressed
(
view
,
this
)
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
View file @
c0be5383
...
...
@@ -234,23 +234,44 @@ object Magisk : BaseSettingsItem.Section() {
override
val
title
=
R
.
string
.
magisk
.
asText
()
}
object
Zygisk
:
BaseSettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
zygisk
.
asText
()
override
val
description
=
R
.
string
.
settings_zygisk_summary
.
asText
()
override
var
value
=
Config
.
zygisk
set
(
value
)
=
setV
(
value
,
field
,
{
field
=
it
})
{
Config
.
zygisk
=
it
DenyList
.
isEnabled
=
it
DenyListConfig
.
isEnabled
=
it
}
}
object
DenyList
:
BaseSettingsItem
.
Toggle
()
{
override
val
title
=
R
.
string
.
settings_denylist_title
.
asText
()
override
val
description
=
R
.
string
.
settings_denylist_summary
.
asText
()
override
val
description
get
()
=
if
(
isEnabled
)
R
.
string
.
settings_denylist_summary
.
asText
()
else
R
.
string
.
settings_denylist_error
.
asText
(
R
.
string
.
zygisk
.
asText
())
override
var
value
=
Info
.
env
.
denyListEnforced
set
(
value
)
=
setV
(
value
,
field
,
{
field
=
it
})
{
val
cmd
=
if
(
it
)
"enable"
else
"disable"
Shell
.
su
(
"magisk --denylist $cmd"
).
submit
{
cb
->
if
(
cb
.
isSuccess
)
Info
.
env
.
denyListEnforced
=
it
Shell
.
su
(
"magisk --denylist $cmd"
).
submit
{
result
->
if
(
result
.
isSuccess
)
Info
.
env
.
denyListEnforced
=
it
else
field
=
!
it
}
DenyListConfig
.
isEnabled
=
it
}
override
fun
refresh
()
{
isEnabled
=
Zygisk
.
value
}
}
object
DenyListConfig
:
BaseSettingsItem
.
Blank
()
{
override
val
title
=
R
.
string
.
settings_denylist_config_title
.
asText
()
override
val
description
=
R
.
string
.
settings_denylist_config_summary
.
asText
()
override
fun
refresh
()
{
isEnabled
=
Zygisk
.
value
}
}
// --- Superuser
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
View file @
c0be5383
...
...
@@ -69,7 +69,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Callback {
SystemlessHosts
))
if
(
Const
.
Version
.
isCanary
())
{
list
.
addAll
(
listOf
(
DenyList
,
DenyListConfig
))
list
.
addAll
(
listOf
(
Zygisk
,
DenyList
,
DenyListConfig
))
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/TextHolder.kt
View file @
c0be5383
...
...
@@ -14,20 +14,26 @@ abstract class TextHolder {
class
String
(
private
val
value
:
CharSequence
)
:
TextHolder
()
{
override
val
isEmpty
get
()
=
value
.
isEmpty
()
override
fun
getText
(
resources
:
Resources
)
=
value
}
class
Resource
(
private
val
value
:
Int
,
private
vararg
val
params
:
Any
open
class
Resource
(
protected
val
value
:
Int
)
:
TextHolder
()
{
override
val
isEmpty
get
()
=
value
==
0
override
fun
getText
(
resources
:
Resources
)
=
resources
.
getString
(
value
,
*
params
)
override
fun
getText
(
resources
:
Resources
)
=
resources
.
getString
(
value
)
}
class
ResourceArgs
(
value
:
Int
,
private
vararg
val
params
:
Any
)
:
Resource
(
value
)
{
override
fun
getText
(
resources
:
Resources
):
kotlin
.
String
{
// Replace TextHolder with strings
val
args
=
params
.
map
{
if
(
it
is
TextHolder
)
it
.
getText
(
resources
)
else
it
}
return
resources
.
getString
(
value
,
*
args
.
toTypedArray
())
}
}
// ---
...
...
@@ -37,7 +43,8 @@ abstract class TextHolder {
}
}
fun
Int
.
asText
(
vararg
params
:
Any
):
TextHolder
=
TextHolder
.
Resource
(
this
,
*
params
)
fun
Int
.
asText
():
TextHolder
=
TextHolder
.
Resource
(
this
)
fun
Int
.
asText
(
vararg
params
:
Any
):
TextHolder
=
TextHolder
.
ResourceArgs
(
this
,
*
params
)
fun
CharSequence
.
asText
():
TextHolder
=
TextHolder
.
String
(
this
)
...
...
app/src/main/res/values/resources.xml
View file @
c0be5383
...
...
@@ -3,6 +3,7 @@
<!-- Static strings -->
<string
name=
"magisk"
translatable=
"false"
>
Magisk
</string>
<string
name=
"zygisk"
translatable=
"false"
>
Zygisk
</string>
<string
name=
"empty"
translatable=
"false"
/>
<string
name=
"topjohnwu"
translatable=
"false"
>
\@topjohnwu
</string>
...
...
app/src/main/res/values/strings.xml
View file @
c0be5383
...
...
@@ -145,8 +145,10 @@
<string
name=
"settings_update_beta"
>
Beta
</string>
<string
name=
"settings_update_custom"
>
Custom Channel
</string>
<string
name=
"settings_update_custom_msg"
>
Insert a custom URL
</string>
<string
name=
"settings_zygisk_summary"
>
Run parts of Magisk in the zygote daemon
</string>
<string
name=
"settings_denylist_title"
>
Enforce DenyList
</string>
<string
name=
"settings_denylist_summary"
>
Processes on the denylist will have all Magisk modifications reverted
</string>
<string
name=
"settings_denylist_error"
>
This feature requires %1$s to be enabled
</string>
<string
name=
"settings_denylist_config_title"
>
Configure DenyList
</string>
<string
name=
"settings_denylist_config_summary"
>
Select the processes to be included on the denylist
</string>
<string
name=
"settings_hosts_title"
>
Systemless hosts
</string>
...
...
native/jni/core/bootstages.cpp
View file @
c0be5383
...
...
@@ -18,6 +18,7 @@
using
namespace
std
;
static
bool
safe_mode
=
false
;
bool
zygisk_enabled
=
false
;
/*********
* Setup *
...
...
@@ -301,7 +302,12 @@ void post_fs_data(int client) {
disable_deny
();
}
else
{
exec_common_scripts
(
"post-fs-data"
);
check_enforce_denylist
();
db_settings
dbs
;
get_db_settings
(
dbs
,
ZYGISK_CONFIG
);
if
(
dbs
[
ZYGISK_CONFIG
])
{
zygisk_enabled
=
true
;
check_enforce_denylist
();
}
handle_modules
();
}
...
...
@@ -350,8 +356,6 @@ void boot_complete(int client) {
if
(
access
(
SECURE_DIR
,
F_OK
)
!=
0
)
xmkdir
(
SECURE_DIR
,
0700
);
check_enforce_denylist
();
if
(
!
check_manager
())
{
if
(
access
(
MANAGERAPK
,
F_OK
)
==
0
)
{
// Only try to install APK when no manager is installed
...
...
native/jni/core/core.hpp
View file @
c0be5383
...
...
@@ -6,6 +6,7 @@
extern
bool
RECOVERY_MODE
;
extern
int
DAEMON_STATE
;
extern
bool
zygisk_enabled
;
void
unlock_blocks
();
void
reboot
();
...
...
native/jni/core/db.cpp
View file @
c0be5383
...
...
@@ -113,6 +113,7 @@ db_settings::db_settings() {
data
[
SU_MULTIUSER_MODE
]
=
MULTIUSER_MODE_OWNER_ONLY
;
data
[
SU_MNT_NS
]
=
NAMESPACE_MODE_REQUESTER
;
data
[
DENYLIST_CONFIG
]
=
false
;
data
[
ZYGISK_CONFIG
]
=
false
;
}
int
db_settings
::
get_idx
(
string_view
key
)
const
{
...
...
native/jni/core/module.cpp
View file @
c0be5383
...
...
@@ -616,10 +616,12 @@ void magic_mount() {
root
->
mount
();
// Mount on top of modules to enable zygisk
string
zygisk_bin
=
MAGISKTMP
+
"/"
ZYGISKBIN
;
mkdir
(
zygisk_bin
.
data
(),
0
);
mount_zygisk
(
32
)
mount_zygisk
(
64
)
if
(
zygisk_enabled
)
{
string
zygisk_bin
=
MAGISKTMP
+
"/"
ZYGISKBIN
;
mkdir
(
zygisk_bin
.
data
(),
0
);
mount_zygisk
(
32
)
mount_zygisk
(
64
)
}
}
static
void
prepare_modules
()
{
...
...
native/jni/include/db.hpp
View file @
c0be5383
...
...
@@ -38,7 +38,8 @@ constexpr const char *DB_SETTING_KEYS[] = {
"root_access"
,
"multiuser_mode"
,
"mnt_ns"
,
"denylist"
"denylist"
,
"zygisk"
};
// Settings key indices
...
...
@@ -46,7 +47,8 @@ enum {
ROOT_ACCESS
=
0
,
SU_MULTIUSER_MODE
,
SU_MNT_NS
,
DENYLIST_CONFIG
DENYLIST_CONFIG
,
ZYGISK_CONFIG
};
// Values for root_access
...
...
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