Add scripts / support for Magisk Hide to Magisk

This commit is contained in:
topjohnwu 2016-10-15 05:38:12 +08:00
parent f785dcac3d
commit 70e8ad7104
8 changed files with 51 additions and 11 deletions

View File

@ -309,6 +309,10 @@ if (! is_mounted /magisk); then
fi fi
MAGISKLOOP=$LOOPDEVICE 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 # Boot image patch
########################################################################################## ##########################################################################################
@ -346,7 +350,7 @@ if (! $NORESTORE); then
# Save it for helper module # Save it for helper module
mkdir -p /magisk/zzsupersu mkdir -p /magisk/zzsupersu
touch /magisk/zzsupersu/stub 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 fi
# Non-standard boot image restores # Non-standard boot image restores
if ($SUPERSU); then if ($SUPERSU); then
@ -427,7 +431,7 @@ if (! $NORESTORE); then
fi fi
ui_print "- Installing root helper module" 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/* chmod 755 /magisk/00roothelper /magisk/00roothelper/*
# Patch ramdisk # 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/init.magisk.rc init.magisk.rc
cp -af $INSTALLER/common/magic_mask.sh sbin/magic_mask.sh 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 chmod 0750 init.magisk.rc sbin/magic_mask.sh
ui_print "- Repacking boot image" ui_print "- Repacking boot image"

Binary file not shown.

View File

@ -9,13 +9,12 @@ on post-fs
rm /dev/.magisk.unblock rm /dev/.magisk.unblock
on post-fs-data on post-fs-data
start magisk_pfsd start magisk_pfsd
wait /dev/.magisk.unblock 40 wait /dev/.magisk.unblock 40
rm /dev/.magisk.unblock rm /dev/.magisk.unblock
on property:magisk.root=* on property:magisk.hide=1
start magisk_root restart magisk_hide
# Services # Services
@ -37,3 +36,9 @@ service magisk_service /sbin/magic_mask.sh service
user root user root
seclabel u:r:su:s0 seclabel u:r:su:s0
oneshot oneshot
# launch magisk hide script
service magisk_hide /sbin/magic_mask.sh hide
user root
seclabel u:r:su:s0
oneshot

View File

@ -2,9 +2,8 @@
LOGFILE=/cache/magisk.log LOGFILE=/cache/magisk.log
IMG=/data/magisk.img IMG=/data/magisk.img
MOUNTLIST=/dev/mountlist
MOUNTPOINT=/magisk export MOUNTPOINT=/magisk
COREDIR=$MOUNTPOINT/.core COREDIR=$MOUNTPOINT/.core
@ -142,7 +141,6 @@ bind_mount() {
mount -o bind $1 $2 mount -o bind $1 $2
if [ "$?" -eq "0" ]; then if [ "$?" -eq "0" ]; then
log_print "Mount: $1" log_print "Mount: $1"
echo $2 >> $MOUNTLIST
else else
log_print "Mount Fail: $1" log_print "Mount Fail: $1"
fi fi
@ -301,6 +299,8 @@ case $1 in
unblock unblock
fi fi
echo $MOUNTPOINT >> $MOUNTLIST
log_print "Preparing modules" log_print "Preparing modules"
# First do cleanups # First do cleanups
rm -rf $DUMMDIR rm -rf $DUMMDIR
@ -407,7 +407,10 @@ case $1 in
setprop magisk.version 7 setprop magisk.version 7
log_print "Magisk late_start service mode running..." log_print "Magisk late_start service mode running..."
run_scripts service run_scripts service
[ -f "$COREDIR/magiskhide/enable" ] && setprop magisk.hide 1
;;
hide )
# Enable magiskhide # Enable magiskhide
[ ! -f "$COREDIR/magiskhide/hidelist" ] && mktouch $COREDIR/magiskhide/hidelist [ ! -f "$COREDIR/magiskhide/hidelist" ] && mktouch $COREDIR/magiskhide/hidelist
# Add preset for Safety Net # Add preset for Safety Net
@ -415,10 +418,10 @@ case $1 in
mv $COREDIR/magiskhide/hidelist $COREDIR/magiskhide/hidelist.tmp mv $COREDIR/magiskhide/hidelist $COREDIR/magiskhide/hidelist.tmp
echo "com.google.android.gms.unstable" > $COREDIR/magiskhide/hidelist echo "com.google.android.gms.unstable" > $COREDIR/magiskhide/hidelist
cat $COREDIR/magiskhide/hidelist.tmp >> $COREDIR/magiskhide/hidelist cat $COREDIR/magiskhide/hidelist.tmp >> $COREDIR/magiskhide/hidelist
rm -f $COREDIR/magiskhide/hidelist.tmp
fi fi
log_print "Starting Magisk Hide" log_print "Starting Magisk Hide"
(/data/magisk/magiskhide &) exec /data/magisk/magiskhide $COREDIR/magiskhide/hidelist
;; ;;
esac esac

View File

@ -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

View File

@ -0,0 +1,4 @@
#!/system/bin/sh
HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist
cat $HIDELIST

View File

@ -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

Binary file not shown.