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
519bd2f3
Commit
519bd2f3
authored
Jan 20, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable AVD hacks by default
parent
20ef724f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
7 deletions
+27
-7
init.hpp
native/jni/init/init.hpp
+10
-0
mount.cpp
native/jni/init/mount.cpp
+10
-6
avd_magisk.sh
scripts/avd_magisk.sh
+1
-1
avd_patch.sh
scripts/avd_patch.sh
+6
-0
No files found.
native/jni/init/init.hpp
View file @
519bd2f3
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
using
kv_pairs
=
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
;
using
kv_pairs
=
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
;
// For API 28 AVD, it uses legacy SAR setup that requires
// special hacks in magiskinit to work properly. We do not
// necessarily want this enabled in production builds.
#define ENABLE_AVD_HACK 0
struct
BootConfig
{
struct
BootConfig
{
bool
skip_initramfs
;
bool
skip_initramfs
;
bool
force_normal_boot
;
bool
force_normal_boot
;
...
@@ -67,9 +72,14 @@ protected:
...
@@ -67,9 +72,14 @@ protected:
mmap_data
magisk_config
;
mmap_data
magisk_config
;
std
::
string
custom_rules_dir
;
std
::
string
custom_rules_dir
;
#if ENABLE_AVD_HACK
// When this boolean is set, this means we are currently
// When this boolean is set, this means we are currently
// running magiskinit on legacy SAR AVD emulator
// running magiskinit on legacy SAR AVD emulator
bool
avd_hack
=
false
;
bool
avd_hack
=
false
;
#else
// Make it const so compiler can optimize hacks out of the code
static
const
bool
avd_hack
=
false
;
#endif
void
mount_with_dt
();
void
mount_with_dt
();
bool
patch_sepolicy
(
const
char
*
file
);
bool
patch_sepolicy
(
const
char
*
file
);
...
...
native/jni/init/mount.cpp
View file @
519bd2f3
...
@@ -158,19 +158,21 @@ void MagiskInit::mount_with_dt() {
...
@@ -158,19 +158,21 @@ void MagiskInit::mount_with_dt() {
for
(
const
auto
&
entry
:
fstab
)
{
for
(
const
auto
&
entry
:
fstab
)
{
if
(
is_lnk
(
entry
.
mnt_point
.
data
()))
if
(
is_lnk
(
entry
.
mnt_point
.
data
()))
continue
;
continue
;
// When we force AVD to disable SystemAsRoot, it will always add system
if
(
avd_hack
&&
entry
.
mnt_point
==
"/system"
)
{
// to dt fstab, which we actually have already mounted as root
// When we force AVD to disable SystemAsRoot, it will always add system
if
(
avd_hack
&&
entry
.
mnt_point
==
"/system"
)
// to dt fstab. We actually already mounted it as root, so skip this one.
continue
;
continue
;
}
// Derive partname from dev
// Derive partname from dev
sprintf
(
blk_info
.
partname
,
"%s%s"
,
basename
(
entry
.
dev
.
data
()),
config
->
slot
);
sprintf
(
blk_info
.
partname
,
"%s%s"
,
basename
(
entry
.
dev
.
data
()),
config
->
slot
);
setup_block
(
true
);
setup_block
(
true
);
xmkdir
(
entry
.
mnt_point
.
data
(),
0755
);
xmkdir
(
entry
.
mnt_point
.
data
(),
0755
);
xmount
(
blk_info
.
block_dev
,
entry
.
mnt_point
.
data
(),
entry
.
type
.
data
(),
MS_RDONLY
,
nullptr
);
xmount
(
blk_info
.
block_dev
,
entry
.
mnt_point
.
data
(),
entry
.
type
.
data
(),
MS_RDONLY
,
nullptr
);
// When avd_hack is true, do not add any early mount partitions to mount_list
if
(
!
avd_hack
)
{
// as we will actually forcefully disable original init's early moun
t
// When avd_hack is true, do not add any early mount partitions to mount_lis
t
if
(
!
avd_hack
)
// as we will actually forcefully disable original init's early mount
mount_list
.
push_back
(
entry
.
mnt_point
);
mount_list
.
push_back
(
entry
.
mnt_point
);
}
}
}
}
}
...
@@ -379,7 +381,9 @@ void SARInit::early_mount() {
...
@@ -379,7 +381,9 @@ void SARInit::early_mount() {
xmkdir
(
"/dev"
,
0755
);
xmkdir
(
"/dev"
,
0755
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
xmount
(
"tmpfs"
,
"/dev"
,
"tmpfs"
,
0
,
"mode=755"
);
mount_list
.
emplace_back
(
"/dev"
);
mount_list
.
emplace_back
(
"/dev"
);
#if ENABLE_AVD_HACK
avd_hack
=
config
->
emulator
;
avd_hack
=
config
->
emulator
;
#endif
mount_with_dt
();
mount_with_dt
();
}
}
}
}
...
...
scripts/avd_magisk.sh
View file @
519bd2f3
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
# the official Android emulator (AVD) instead of a real device.
# the official Android emulator (AVD) instead of a real device.
#
#
# This only covers the "core" features of Magisk. For testing
# This only covers the "core" features of Magisk. For testing
# magiskinit, please checkout avd_
init
.sh.
# magiskinit, please checkout avd_
patch
.sh.
#
#
#####################################################################
#####################################################################
...
...
scripts/avd_patch.sh
View file @
519bd2f3
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
# After patching ramdisk.img, close the emulator, then select
# After patching ramdisk.img, close the emulator, then select
# "Cold Boot Now" in AVD Manager to force a full reboot.
# "Cold Boot Now" in AVD Manager to force a full reboot.
#
#
# P.S. If running against the API 28 image, modify init.hpp and set
# ENABLE_AVD_HACK to 1 to enable special hacks designed specifically
# for this use case.
#
#####################################################################
#####################################################################
# AVD Init Configurations:
# AVD Init Configurations:
#
#
...
@@ -39,6 +43,8 @@ if [ -z "$FIRST_STAGE" ]; then
...
@@ -39,6 +43,8 @@ if [ -z "$FIRST_STAGE" ]; then
exec
./busybox sh
$0
exec
./busybox sh
$0
fi
fi
pm
install
-r
$(
pwd
)
/app-debug.apk
# Extract files from APK
# Extract files from APK
unzip
-oj
app-debug.apk
'assets/util_functions.sh'
unzip
-oj
app-debug.apk
'assets/util_functions.sh'
.
./util_functions.sh
.
./util_functions.sh
...
...
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