From 6d3ac2aa55689cda1a68f6def4f6ffbd89a02112 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 5 Feb 2017 23:41:24 +0800 Subject: [PATCH] Check before enable/disable --- zip_static/common/magiskhide/disable | 4 ++++ zip_static/common/magiskhide/enable | 3 +++ 2 files changed, 7 insertions(+) diff --git a/zip_static/common/magiskhide/disable b/zip_static/common/magiskhide/disable index 9e6961957..f7dda86c9 100644 --- a/zip_static/common/magiskhide/disable +++ b/zip_static/common/magiskhide/disable @@ -10,7 +10,11 @@ log_print() { log -p i -t Magisk "MagiskHide: $1" } +# Only disable when MagiskHide is started +ps | grep "magiskhide --daemon" | grep -v grep >/dev/null 2>&1 || exit + log_print "Stopping MagiskHide daemon" + set -- set `$TOOLPATH/ps -o pid,args | grep "magiskhide" | grep -v grep | head -1` >/dev/null [ ! -z "$1" ] && kill "$1" diff --git a/zip_static/common/magiskhide/enable b/zip_static/common/magiskhide/enable index bbce84b54..740ff1489 100644 --- a/zip_static/common/magiskhide/enable +++ b/zip_static/common/magiskhide/enable @@ -11,6 +11,9 @@ log_print() { log -p i -t Magisk "MagiskHide: $1" } +# 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`