Magisk/zip_static/common/magiskhide/enable

44 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/system/bin/sh
MODDIR=/magisk/.core/magiskhide
BINPATH=/data/magisk
LOGFILE=/cache/magisk.log
2017-02-04 17:45:53 +00:00
TOOLPATH=/dev/busybox
log_print() {
echo "MagiskHide: $1"
echo "MagiskHide: $1" >> $LOGFILE
log -p i -t Magisk "MagiskHide: $1"
}
2017-02-05 15:41:24 +00:00
# Only enable when isn't started
ps | grep "magiskhide --daemon" | grep -v grep >/dev/null 2>&1 && exit
log_print "Removing tampered read-only system props"
VERIFYBOOT=`getprop ro.boot.verifiedbootstate`
FLASHLOCKED=`getprop ro.boot.flash.locked`
VERITYMODE=`getprop ro.boot.veritymode`
[ ! -z "$VERIFYBOOT" -a "$VERIFYBOOT" != "green" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.verifiedbootstate green`"
[ ! -z "$FLASHLOCKED" -a "$FLASHLOCKED" != "1" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.flash.locked 1`"
[ ! -z "$VERITYMODE" -a "$VERITYMODE" != "enforcing" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.veritymode enforcing`"
touch $MODDIR/hidelist
chmod -R 755 $MODDIR
# Add Safety Net preset
$MODDIR/add com.google.android.gms.unstable
while read PROCESS; do
log_print "Killing $PROCESS"
set --
2017-02-04 17:45:53 +00:00
set `$TOOLPATH/ps -o pid,args | grep "$PROCESS" | grep -v grep` >/dev/null
[ ! -z "$1" ] && kill "$1"
done < $MODDIR/hidelist
log_print "Starting MagiskHide daemon"
$MODDIR/magiskhide --daemon