mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-23 18:15:30 +00:00
Better AVD support
This commit is contained in:
parent
762b70ba9d
commit
24ba4ab95b
@ -126,9 +126,11 @@ string find_preinit_device() {
|
||||
} matched = UNKNOWN;
|
||||
bool encrypted = getprop("ro.crypto.state") == "encrypted";
|
||||
bool mount = getuid() == 0 && getenv("MAGISKTMP");
|
||||
bool make_dev = mount && getenv("MAKEDEV");
|
||||
|
||||
string preinit_source;
|
||||
string preinit_dir;
|
||||
dev_t preinit_dev;
|
||||
|
||||
for (const auto &info: parse_mount_info("self")) {
|
||||
if (info.target.ends_with(PREINITMIRR))
|
||||
@ -180,6 +182,7 @@ string find_preinit_device() {
|
||||
|
||||
if (mount) {
|
||||
preinit_dir = resolve_preinit_dir(info.target.data());
|
||||
preinit_dev = info.device;
|
||||
}
|
||||
preinit_source = info.source;
|
||||
}
|
||||
@ -189,6 +192,10 @@ string find_preinit_device() {
|
||||
mkdirs(preinit_dir.data(), 0700);
|
||||
mkdirs(mirror_dir.data(), 0700);
|
||||
xmount(preinit_dir.data(), mirror_dir.data(), nullptr, MS_BIND, nullptr);
|
||||
if (make_dev) {
|
||||
auto dev_path = string(getenv("MAGISKTMP")) + "/" PREINITDEV;
|
||||
xmknod(dev_path.data(), S_IFBLK | 0600, preinit_dev);
|
||||
}
|
||||
}
|
||||
return preinit_source.empty() ? "" : basename(preinit_source.data());
|
||||
}
|
||||
|
@ -67,15 +67,9 @@ if [ -d /dev/avd-magisk ]; then
|
||||
rm -rf /dev/avd-magisk 2>/dev/null
|
||||
fi
|
||||
|
||||
# SELinux stuffs
|
||||
if [ -d /sys/fs/selinux ]; then
|
||||
if [ -f /vendor/etc/selinux/precompiled_sepolicy ]; then
|
||||
./magiskpolicy --load /vendor/etc/selinux/precompiled_sepolicy --live --magisk 2>&1
|
||||
elif [ -f /sepolicy ]; then
|
||||
./magiskpolicy --load /sepolicy --live --magisk 2>&1
|
||||
else
|
||||
./magiskpolicy --live --magisk 2>&1
|
||||
fi
|
||||
# Mount /cache if not already mounted
|
||||
if ! grep -q ' /cache ' /proc/mounts; then
|
||||
mount -t tmpfs -o 'mode=0755' tmpfs /cache
|
||||
fi
|
||||
|
||||
MAGISKTMP=/sbin
|
||||
@ -148,9 +142,27 @@ mkdir $MAGISKTMP/.magisk/block
|
||||
mkdir $MAGISKTMP/.magisk/worker
|
||||
touch $MAGISKTMP/.magisk/config
|
||||
|
||||
# Boot up
|
||||
export MAGISKTMP
|
||||
$MAGISKTMP/magisk --preinit-device
|
||||
MAKEDEV=1 $MAGISKTMP/magisk --preinit-device 2>&1
|
||||
|
||||
RULESCMD=""
|
||||
for r in $MAGISKTMP/.magisk/preinit/*/sepolicy.rule; do
|
||||
[ -f "$r" ] || continue
|
||||
RULESCMD="$RULESCMD --apply $r"
|
||||
done
|
||||
|
||||
# SELinux stuffs
|
||||
if [ -d /sys/fs/selinux ]; then
|
||||
if [ -f /vendor/etc/selinux/precompiled_sepolicy ]; then
|
||||
./magiskpolicy --load /vendor/etc/selinux/precompiled_sepolicy --live --magisk $RULESCMD 2>&1
|
||||
elif [ -f /sepolicy ]; then
|
||||
./magiskpolicy --load /sepolicy --live --magisk $RULESCMD 2>&1
|
||||
else
|
||||
./magiskpolicy --live --magisk $RULESCMD 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Boot up
|
||||
$MAGISKTMP/magisk --post-fs-data
|
||||
start
|
||||
$MAGISKTMP/magisk --service
|
||||
|
Loading…
Reference in New Issue
Block a user