Skip to content

Commit 20ff3a9

Browse files
authored
Change method of knowing the PID of Zygote. Also minor changes.
thanks HuskyDG
1 parent bf96a65 commit 20ff3a9

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ It's Magisk module, flash it in **Magisk** app
1818

1919
### Auto detect
2020
Usually, bootloop occurs because zygote doesn't start properly or is stuck restarting.
21-
The script run in `late_start` mode. It will check Zygote's Process ID 3 times every 15 seconds.
21+
The script runs in `late_start` mode. It will check Zygote's Process ID 3 times every 15 seconds.
2222
And if Zygote's Process ID doesn't match for 3 times, check the Process ID for next 15 seconds to make sure, and if it's different again, the script will disable all modules and reboot the your device.
2323

2424

25-
## Known issues
26-
It may be too eager to Disable all modules and Reboot.
27-
28-
2925
## Attribution
30-
Module originally made by HuskyDG, but I didn't like how large it was for something that looked like it could be done in less code, so I forked it and made it into just one script.
26+
Module originally made by [HuskyDG](https://github.com/HuskyDG), but I didn't like how large it was for something that looked like it could be done in less code, so I forked it and made it into just one script.
3127
This involved removing the custom recovery parts, but for me the AutoDetect has worked.

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=simple_bootloopsaver
22
name=Simple Bootloop Saver
3-
version=v1.1
4-
versionCode=2
3+
version=v2
4+
versionCode=3
55
author=ez-me
66
description=Protect your system from bootloop caused by Magisk modules by turning off all your modules and restart your system if bootloop is detected.
77
changeBoot=false

service.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
#!/system/bin/sh
1+
#!/data/adb/magisk/busybox sh
22
#Bootloop saver by HuskyDG, modified by ez-me
33

44
# Get variables
55
MODPATH=${0%/*}
66
MESSAGE="$(cat "$MODPATH"/msg.txt | head -c100)"
77

8-
if [ -n "$(getprop ro.product.cpu.abi | grep 64)" ]
9-
then
10-
ZYGOTE_NAME=zygote64
11-
else
12-
ZYGOTE_NAME=zygote
13-
fi
14-
158
# Log
169
log(){
1710
TEXT=$@; echo "[`date -Is`]: $TEXT" >> $MODPATH/log.txt
@@ -44,15 +37,15 @@ disable_modules(){
4437

4538
# Gather PIDs
4639
sleep 5
47-
ZYGOTE_PID1=$(pidof "$ZYGOTE_NAME")
40+
ZYGOTE_PID1=$(getprop init.svc_debug_pid.zygote)
4841
log "PID1: $ZYGOTE_PID1"
4942

5043
sleep 15
51-
ZYGOTE_PID2=$(pidof "$ZYGOTE_NAME")
44+
ZYGOTE_PID2=$(getprop init.svc_debug_pid.zygote)
5245
log "PID2: $ZYGOTE_PID2"
5346

5447
sleep 15
55-
ZYGOTE_PID3=$(pidof "$ZYGOTE_NAME")
48+
ZYGOTE_PID3=$(getprop init.svc_debug_pid.zygote)
5649
log "PID3: $ZYGOTE_PID3"
5750

5851
# Check for BootLoop
@@ -68,10 +61,10 @@ if [ "$ZYGOTE_PID1" != "$ZYGOTE_PID2" -o "$ZYGOTE_PID2" != "$ZYGOTE_PID3" ]
6861
then
6962
log "PID mismatch, checking again"
7063
sleep 15
71-
ZYGOTE_PID4=$(pidof "$ZYGOTE_NAME")
64+
ZYGOTE_PID4=$(getprop init.svc_debug_pid.zygote)
7265
log "PID4: $ZYGOTE_PID4"
7366

74-
if [ "$ZYGOTE_PID1" != "$ZYGOTE_PID4" ]
67+
if [ "$ZYGOTE_PID3" != "$ZYGOTE_PID4" ]
7568
then
7669
log "They don't match..."
7770
disable_modules
@@ -80,5 +73,5 @@ fi
8073

8174
# If we reached this section we should be fine
8275
log "looks good to me!"
83-
log """
76+
log ""
8477
exit

0 commit comments

Comments
 (0)