mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
test: rust 编译测试
This commit is contained in:
1 parent
03ea3a7ac5
commit
c6a27159f4
10 files changed
+409
-37
No files matched your search
+5
-5
@@ -74,20 +74,20 @@ while true; do
|
||||
echo "$current_config" >"$config_cache_file"
|
||||
fi
|
||||
|
||||
_log "正在启动 inotifyd 监听" "INFO"
|
||||
_log "正在启动 lumipro 监听" "INFO"
|
||||
now_bri_file="${current_config%|*}"
|
||||
inotify_events="${current_config#*|}"
|
||||
|
||||
# 缓存当前监听路径(供 up.sh 参考)
|
||||
# 缓存当前监听路径(供参考)
|
||||
echo -n "$now_bri_file" >"$MODDIR/config/.cached_path"
|
||||
|
||||
inotifyd "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
||||
"$MODDIR/bin/lumipro" "$MODDIR/script/up.sh" "$now_bri_file:$inotify_events" >>"$log_file" 2>&1 &
|
||||
inotify_pid=$!
|
||||
echo "$inotify_pid" >"$pid_file"
|
||||
_log "inotifyd 已启动 (PID: $inotify_pid), 监听: $now_bri_file, 事件: $inotify_events" "SUCCESS"
|
||||
_log "lumipro 已启动 (PID: $inotify_pid), 监听: $now_bri_file, 事件: $inotify_events" "SUCCESS"
|
||||
|
||||
wait "$inotify_pid"
|
||||
_log "监听进程 (PID: $inotify_pid) 已退出,即将重启" "WARN"
|
||||
_log "lumipro 进程 (PID: $inotify_pid) 已退出,即将重启" "WARN"
|
||||
|
||||
sleep 0.5
|
||||
done
|
||||
+3
-6
@@ -15,13 +15,10 @@ _log "收到手动重启请求"
|
||||
|
||||
pause_file="$PID_DIR/daemon.pause"
|
||||
|
||||
# 1. 强制通知守护进程并执行清理
|
||||
_log "通知守护进程挂起,清理残余进程"
|
||||
# 1. 通知守护进程挂起,终止 lumipro 实例
|
||||
_log "通知守护进程挂起,清理 lumipro 实例"
|
||||
touch "$pause_file"
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
for p in $(pgrep -f "up.sh"); do
|
||||
[ "$p" != "$$" ] && kill -9 "$p" 2>/dev/null
|
||||
done
|
||||
[ -f "$pid_file" ] && kill -9 "$(cat "$pid_file")" 2>/dev/null
|
||||
|
||||
# 2. 清理遗留标记
|
||||
rm -f "$pid_file"
|
||||
|
||||
+7
-26
@@ -1,4 +1,4 @@
|
||||
#!/system/bin/sh
|
||||
#!/system/bin/sh
|
||||
#shellcheck shell=ash
|
||||
# 亮度提升脚本
|
||||
|
||||
@@ -45,23 +45,13 @@ _log() {
|
||||
printf '[%s] [%s] [%s] %s\n' "$(date '+%m-%d %H:%M:%S')" "up" "$level" "$1" >>"$log_file"
|
||||
}
|
||||
|
||||
_log "收到 inotifyd 事件通知 (PID: $$)" "INFO"
|
||||
_log "正在接管控制权,清理残余进程..." "INFO"
|
||||
touch "$pause_file"
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
for p in $(pgrep -f "up.sh"); do
|
||||
[ "$p" != "$$" ] && kill -9 "$p" 2>/dev/null
|
||||
done
|
||||
_log "收到亮度变更通知 (PID: $$)" "INFO"
|
||||
|
||||
if [ -f "$stop_file" ]; then
|
||||
_log "服务已暂停,跳过本次处理" "WARN"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f "$flag_file" ]; then
|
||||
_log "检测到并发执行,当前进程退出" "WARN"
|
||||
exit 1
|
||||
fi
|
||||
touch "$flag_file"
|
||||
|
||||
# 读取配置
|
||||
@@ -133,7 +123,7 @@ CHECK_BRI() {
|
||||
MAIN() {
|
||||
if IS_SLEEP_TIME; then
|
||||
_log "处于休眠时段 ($sleep_start-$sleep_end),跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -142,7 +132,7 @@ MAIN() {
|
||||
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
|
||||
if [ "$mode" = "1" ]; then
|
||||
_log "自动亮度已启用,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -159,7 +149,7 @@ MAIN() {
|
||||
'.blacklist_apps | map(. == $f or . == $a) | any' \
|
||||
"$CONFIG_FILE" >/dev/null 2>&1; then
|
||||
_log "当前前台 ($current_focus) 在黑名单中,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -173,7 +163,7 @@ MAIN() {
|
||||
now="$(date +%s)"
|
||||
if awk "BEGIN{exit !(($now - $flag_time) < 2)}" 2>/dev/null; then
|
||||
_log "HDR 冷却期内,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
else
|
||||
rm -f "$hdr_flag_file"
|
||||
@@ -194,7 +184,7 @@ MAIN() {
|
||||
if awk "BEGIN{exit !($hdr_ratio_rounded > 1.00)}" 2>/dev/null; then
|
||||
_log "检测到 HDR 内容 (比率: $hdr_ratio_rounded),跳过提升" "INFO"
|
||||
date +%s >"$hdr_flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
rm -f "$flag_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -203,16 +193,7 @@ MAIN() {
|
||||
_log "正在检测亮度变化..." "INFO"
|
||||
CHECK_BRI
|
||||
rm -f "$flag_file"
|
||||
rm -f "$pause_file"
|
||||
|
||||
# 如果监听路径变更,重启 inotifyd
|
||||
local current_now_bri cached_now_bri
|
||||
current_now_bri="$(get_cfg now_bri_file "$DEFAULT_NOW_BRI_FILE")"
|
||||
cached_now_bri="$(cat "$MODDIR/config/.cached_path" 2>/dev/null || echo "$DEFAULT_NOW_BRI_FILE")"
|
||||
if [ "$current_now_bri" != "$cached_now_bri" ]; then
|
||||
_log "检测到监听路径变更,重启 inotifyd" "INFO"
|
||||
killall -9 inotifyd 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
MAIN
|
||||
|
||||
Reference in new issue
Block a user