Skip to content

Commit b4a1741

Browse files
authored
Update service.sh
1 parent 969bf51 commit b4a1741

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

service.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ systemui_monitor() {
178178

179179

180180
# Monitor SystemUI
181+
181182
monitor_package() {
182183
if [ -f "$MONITOR_DISABLE_FILE" ]; then
183184
log_event "SystemUI monitoring is disabled. Exiting monitor."
@@ -188,16 +189,26 @@ monitor_package() {
188189
local MONITOR_TIMEOUT=25 # Total timeout in seconds
189190
local CHECK_INTERVAL=5 # Check interval in seconds
190191
local FAILURE_TIME=0 # Time elapsed since package stopped running
192+
local PREVIOUS_PID="" # Previous PID of the package
191193

192194
while true; do
193-
if is_package_running; then
195+
CURRENT_PID=$(pidof "$PACKAGE")
196+
197+
if [ -n "$CURRENT_PID" ]; then
198+
if [ "$CURRENT_PID" != "$PREVIOUS_PID" ]; then
199+
log_event "PID of $PACKAGE has changed from $PREVIOUS_PID to $CURRENT_PID."
200+
PREVIOUS_PID="$CURRENT_PID"
201+
if [ ! -f "$lock_file" ]; then
202+
systemui_monitor &
203+
fi
204+
fi
194205
FAILURE_TIME=0
195206
else
196207
log_event "$PACKAGE is not running. Failure timer: $FAILURE_TIME seconds."
197208
FAILURE_TIME=$((FAILURE_TIME + CHECK_INTERVAL))
198209
if [ ! -f "$lock_file" ]; then
199-
systemui_monitor &
200-
fi
210+
systemui_monitor &
211+
fi
201212
if [ $FAILURE_TIME -ge $MONITOR_TIMEOUT ]; then
202213
log_event "$PACKAGE has not been running for $MONITOR_TIMEOUT seconds. Disabling Magisk modules and rebooting..."
203214
disable_magisk_modules

0 commit comments

Comments
 (0)