mirror of
https://github.com/YuleBest/LuminPro.git
synced 2026-12-04 00:54:42 +08:00
update: 更新到 2208 版本;实现 HDR 避让;实现活动级黑名单
This commit is contained in:
1 parent
a61c845323
commit
b4169ceb1f
12 files changed
+566
-124
No files matched your search
+49
-8
@@ -77,6 +77,7 @@ ui_max_bri="$(cat "$CONFIG_DIR/ui_max_bri.txt")"
|
||||
max_bri="$(cat "$CONFIG_DIR/max_bri.txt")"
|
||||
sleep_time="$(cat "$CONFIG_DIR/sleep_time.txt" 2>/dev/null)"
|
||||
auto_bri_sleep="$(cat "$CONFIG_DIR/auto_bri_sleep.txt" 2>/dev/null)"
|
||||
display_hdr_sleep="$(cat "$CONFIG_DIR/display_hdr_sleep.txt" 2>/dev/null)"
|
||||
|
||||
# 解析休眠时间 (格式: HHMM-HHMM, 例如 1900-0600)
|
||||
sleep_start="${sleep_time%-*}" # 1900
|
||||
@@ -161,7 +162,7 @@ MAIN() {
|
||||
# 解析并判断休眠
|
||||
if IS_SLEEP_TIME; then
|
||||
_log "处于休眠时段 ($sleep_start-$sleep_end),跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -169,23 +170,63 @@ MAIN() {
|
||||
mode="$(settings get system screen_brightness_mode 2>/dev/null)"
|
||||
if [ "$mode" = "1" ]; then
|
||||
_log "自动亮度已启用,跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 黑名单应用检测
|
||||
# 黑名单应用检测(支持包名和完整 package/activity 两种格式)
|
||||
local blacklist_file="$CONFIG_DIR/blacklist_apps.txt"
|
||||
if [ -f "$blacklist_file" ] && [ -s "$blacklist_file" ]; then
|
||||
local current_app
|
||||
current_app="$(dumpsys window | grep mCurrentFocus | sed 's/.*u0 \(.*\)\/.*/\1/')"
|
||||
if [ -n "$current_app" ] && grep -qxF "$current_app" "$blacklist_file"; then
|
||||
_log "当前前台应用 ($current_app) 在黑名单中,跳过提升" "INFO"
|
||||
rm -f "$flag_file"
|
||||
local current_focus current_app
|
||||
current_focus="$(dumpsys window | grep mCurrentFocus | sed 's/.*u0 \(.*\)}/\1/')"
|
||||
current_app="${current_focus%%/*}"
|
||||
if [ -n "$current_focus" ] && { grep -qxF "$current_focus" "$blacklist_file" || grep -qxF "$current_app" "$blacklist_file"; }; then
|
||||
_log "当前前台 ($current_focus) 在黑名单中,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# 显示 HDR 内容时休眠
|
||||
if [ "$display_hdr_sleep" = "1" ]; then
|
||||
local hdr_flag_file="$PID_DIR/hdr.flag"
|
||||
# 冷却期检查:读取写入时间戳,判断是否在 2 秒内
|
||||
if [ -f "$hdr_flag_file" ]; then
|
||||
local flag_time now
|
||||
flag_time="$(cat "$hdr_flag_file")"
|
||||
now="$(date +%s)"
|
||||
if awk "BEGIN{exit !(($now - $flag_time) < 2)}" 2>/dev/null; then
|
||||
_log "HDR 冷却期内,跳过提升" "INFO"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
else
|
||||
rm -f "$hdr_flag_file" # 冷却期已过,清理
|
||||
fi
|
||||
fi
|
||||
local hdr_ratio hdr_ratio_rounded
|
||||
local hdr_cache_file="$PID_DIR/.hdr_ratio_cache"
|
||||
hdr_ratio="$(dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \([0-9.]*\).*/\1/p' | head -n 1)"
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
# 读取成功,更新缓存
|
||||
echo -n "$hdr_ratio" >"$hdr_cache_file"
|
||||
elif [ -f "$hdr_cache_file" ]; then
|
||||
# 读取为空,使用上次缓存
|
||||
hdr_ratio="$(cat "$hdr_cache_file")"
|
||||
_log "HDR 比率读取为空,使用缓存值: $hdr_ratio" "INFO"
|
||||
fi
|
||||
if echo "$hdr_ratio" | grep -qE '^[0-9]+\.[0-9]+$'; then
|
||||
hdr_ratio_rounded="$(awk "BEGIN{printf \"%.2f\", $hdr_ratio}")"
|
||||
if awk "BEGIN{exit !($hdr_ratio_rounded > 1.00)}" 2>/dev/null; then
|
||||
_log "检测到 HDR 内容 (比率: $hdr_ratio_rounded),跳过提升" "INFO"
|
||||
# 写入当前时间戳作为冷却期起点(2 秒内再次触发直接跳过)
|
||||
date +%s >"$hdr_flag_file"
|
||||
rm -f "$flag_file" "$pause_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
_log "正在检测亮度变化..." "INFO"
|
||||
# sleep 0.5
|
||||
CHECK_BRI
|
||||
|
||||
Reference in new issue
Block a user