diff --git a/zip_static/META-INF/com/google/android/update-binary b/zip_static/META-INF/com/google/android/update-binary index f4e48218a..30434ba0c 100644 --- a/zip_static/META-INF/com/google/android/update-binary +++ b/zip_static/META-INF/com/google/android/update-binary @@ -309,6 +309,10 @@ if (! is_mounted /magisk); then fi MAGISKLOOP=$LOOPDEVICE +mkdir -p /magisk/.core/magiskhide 2>/dev/null +cp -af $INSTALLER/common/magiskhide/. /magisk/.core/magiskhide +chmod 755 /magisk/.core/magiskhide /magisk/.core/magiskhide/* + ########################################################################################## # Boot image patch ########################################################################################## @@ -346,7 +350,7 @@ if (! $NORESTORE); then # Save it for helper module mkdir -p /magisk/zzsupersu touch /magisk/zzsupersu/stub - cp -af sbin/launch_daemonsu.sh $INSTALLER/roothelper/launch_daemonsu.sh + cp -af sbin/launch_daemonsu.sh $INSTALLER/common/roothelper/launch_daemonsu.sh fi # Non-standard boot image restores if ($SUPERSU); then @@ -427,7 +431,7 @@ if (! $NORESTORE); then fi ui_print "- Installing root helper module" -cp -af $INSTALLER/roothelper /magisk/00roothelper +cp -af $INSTALLER/common/roothelper /magisk/00roothelper chmod 755 /magisk/00roothelper /magisk/00roothelper/* # Patch ramdisk @@ -460,7 +464,7 @@ mkdir -p magisk 2>/dev/null cp -af $INSTALLER/common/init.magisk.rc init.magisk.rc cp -af $INSTALLER/common/magic_mask.sh sbin/magic_mask.sh -chmod 0755 magisk +# chmod 0755 magisk chmod 0750 init.magisk.rc sbin/magic_mask.sh ui_print "- Repacking boot image" diff --git a/zip_static/arm/magiskhide b/zip_static/arm/magiskhide index a51f9b27a..887ba5627 100644 Binary files a/zip_static/arm/magiskhide and b/zip_static/arm/magiskhide differ diff --git a/zip_static/common/init.magisk.rc b/zip_static/common/init.magisk.rc index 89a135c23..f04ab6133 100644 --- a/zip_static/common/init.magisk.rc +++ b/zip_static/common/init.magisk.rc @@ -9,13 +9,12 @@ on post-fs rm /dev/.magisk.unblock on post-fs-data - start magisk_pfsd wait /dev/.magisk.unblock 40 rm /dev/.magisk.unblock -on property:magisk.root=* - start magisk_root +on property:magisk.hide=1 + restart magisk_hide # Services @@ -37,3 +36,9 @@ service magisk_service /sbin/magic_mask.sh service user root seclabel u:r:su:s0 oneshot + +# launch magisk hide script +service magisk_hide /sbin/magic_mask.sh hide + user root + seclabel u:r:su:s0 + oneshot diff --git a/zip_static/common/magic_mask.sh b/zip_static/common/magic_mask.sh index cd00ff19b..36a75383a 100644 --- a/zip_static/common/magic_mask.sh +++ b/zip_static/common/magic_mask.sh @@ -2,9 +2,8 @@ LOGFILE=/cache/magisk.log IMG=/data/magisk.img -MOUNTLIST=/dev/mountlist -MOUNTPOINT=/magisk +export MOUNTPOINT=/magisk COREDIR=$MOUNTPOINT/.core @@ -142,7 +141,6 @@ bind_mount() { mount -o bind $1 $2 if [ "$?" -eq "0" ]; then log_print "Mount: $1" - echo $2 >> $MOUNTLIST else log_print "Mount Fail: $1" fi @@ -301,6 +299,8 @@ case $1 in unblock fi + echo $MOUNTPOINT >> $MOUNTLIST + log_print "Preparing modules" # First do cleanups rm -rf $DUMMDIR @@ -407,7 +407,10 @@ case $1 in setprop magisk.version 7 log_print "Magisk late_start service mode running..." run_scripts service + [ -f "$COREDIR/magiskhide/enable" ] && setprop magisk.hide 1 + ;; + hide ) # Enable magiskhide [ ! -f "$COREDIR/magiskhide/hidelist" ] && mktouch $COREDIR/magiskhide/hidelist # Add preset for Safety Net @@ -415,10 +418,10 @@ case $1 in mv $COREDIR/magiskhide/hidelist $COREDIR/magiskhide/hidelist.tmp echo "com.google.android.gms.unstable" > $COREDIR/magiskhide/hidelist cat $COREDIR/magiskhide/hidelist.tmp >> $COREDIR/magiskhide/hidelist + rm -f $COREDIR/magiskhide/hidelist.tmp fi log_print "Starting Magisk Hide" - (/data/magisk/magiskhide &) - + exec /data/magisk/magiskhide $COREDIR/magiskhide/hidelist ;; esac diff --git a/zip_static/common/magiskhide/add b/zip_static/common/magiskhide/add new file mode 100644 index 000000000..1b87dde52 --- /dev/null +++ b/zip_static/common/magiskhide/add @@ -0,0 +1,12 @@ +#!/system/bin/sh + +HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist + +if [ ! -z "$1" ]; then + if [ $(grep -c "^$1$" $HIDELIST) -eq "0" ]; then + echo "$1" >> $HIDELIST + fi +fi + +# Reload the list +setprop magisk.hide 1 diff --git a/zip_static/common/magiskhide/list b/zip_static/common/magiskhide/list new file mode 100644 index 000000000..10a8f5cf2 --- /dev/null +++ b/zip_static/common/magiskhide/list @@ -0,0 +1,4 @@ +#!/system/bin/sh + +HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist +cat $HIDELIST diff --git a/zip_static/common/magiskhide/rm b/zip_static/common/magiskhide/rm new file mode 100644 index 000000000..2eb8b3b4b --- /dev/null +++ b/zip_static/common/magiskhide/rm @@ -0,0 +1,12 @@ +#!/system/bin/sh + +HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist + +if [ ! -z "$1" ]; then + mv $HIDELIST $HIDELIST.tmp + cat $HIDELIST.tmp | grep -v "^$1$" > $HIDELIST + rm -f $HIDELIST.tmp +fi + +# Reload the list +setprop magisk.hide 1 diff --git a/zip_static/x86/magiskhide b/zip_static/x86/magiskhide index c2d149cda..e72fa8907 100644 Binary files a/zip_static/x86/magiskhide and b/zip_static/x86/magiskhide differ