From 791884862a6c9bf54cdeed1da432981ee901bdb0 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Mon, 6 Sep 2021 04:02:27 -0700 Subject: [PATCH] magisk: Add service script for MagiskHide device indicators This functionality has been removed from Magisk: https://github.com/topjohnwu/Magisk/commit/003fea52b1857015bfc3988de56eb1a6d3049a7f Simple properties are set in system.prop, but more advanced overrides need to be handled by a script. --- riru/template/magisk_module/customize.sh | 2 ++ riru/template/magisk_module/service.sh | 28 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 riru/template/magisk_module/service.sh diff --git a/riru/template/magisk_module/customize.sh b/riru/template/magisk_module/customize.sh index d89666e..42ab0a9 100644 --- a/riru/template/magisk_module/customize.sh +++ b/riru/template/magisk_module/customize.sh @@ -38,6 +38,8 @@ ui_print "- Extracting module files" extract "$ZIPFILE" 'module.prop' "$MODPATH" extract "$ZIPFILE" 'classes.dex' "$MODPATH" +extract "$ZIPFILE" 'service.sh' "$MODPATH" +chmod 755 "$MODPATH/service.sh" # Riru v24+ load files from the "riru" folder in the Magisk module folder # This "riru" folder is also used to determine if a Magisk module is a Riru module diff --git a/riru/template/magisk_module/service.sh b/riru/template/magisk_module/service.sh new file mode 100644 index 0000000..a8a8fb0 --- /dev/null +++ b/riru/template/magisk_module/service.sh @@ -0,0 +1,28 @@ +#!/system/bin/sh + +maybe_set_prop() { + local prop="$1" + local contains="$2" + local value="$3" + + if [[ "$(getprop "$prop")" == *"$contains"* ]]; then + resetprop "$prop" "$value" + fi +} + +# Magisk recovery mode +maybe_set_prop ro.bootmode recovery unknown +maybe_set_prop ro.boot.mode recovery unknown +maybe_set_prop vendor.boot.mode recovery unknown + +# MIUI region +maybe_set_prop ro.boot.hwc CN GLOBAL +maybe_set_prop ro.boot.hwcountry China GLOBAL + +resetprop --delete ro.build.selinux + +# SELinux permissive +if [[ "$(cat /sys/fs/selinux/enforce)" == "0" ]]; then + chmod 640 /sys/fs/selinux/enforce + chmod 440 /sys/fs/selinux/policy +fi