diff --git a/boost.sh b/boost.sh new file mode 100644 index 0000000..738c0a6 --- /dev/null +++ b/boost.sh @@ -0,0 +1,49 @@ +#!/system/bin/sh +#shellcheck shell=ash + +# LuminPro 手动提升/恢复亮度触发脚本 + +# 解析模块工作目录 +MODDIR="$(dirname "$(readlink -f "$0")")" +CONFIG_DIR="$MODDIR/config" +PATH_CONFIG_DIR="$CONFIG_DIR/path" +PID_DIR="$MODDIR/pid" +BOOST_FLAG="$PID_DIR/boost.flag" + +# 默认设备路径 +DEFAULT_NOW_BRI_FILE="/sys/class/backlight/panel0-backlight/brightness" + +# 读取配置的路径,如果不存在则回退至默认值 +if [ -f "$PATH_CONFIG_DIR/now_bri_file.txt" ]; then + now_bri_file="$(cat "$PATH_CONFIG_DIR/now_bri_file.txt" 2>/dev/null | tr -d ' \n')" +fi +[ -z "$now_bri_file" ] && now_bri_file="$DEFAULT_NOW_BRI_FILE" + +# 确保节点存在 +if [ ! -f "$now_bri_file" ]; then + exit 1 +fi + +if [ -f "$BOOST_FLAG" ]; then + restore_bri="$(cat "$BOOST_FLAG" 2>/dev/null | tr -d ' \n')" + if [ -n "$restore_bri" ]; then + echo -n "$restore_bri" >"$now_bri_file" 2>/dev/null + fi + rm -f "$BOOST_FLAG" +else + max_bri="$(cat "$CONFIG_DIR/max_bri.txt" 2>/dev/null | tr -d ' \n')" + if [ -z "$max_bri" ]; then + exit 1 + fi + + # 读取当前亮度并存档 + now_bri="$(cat "$now_bri_file" 2>/dev/null | tr -d ' \n')" + + mkdir -p "$PID_DIR" + echo -n "$now_bri" >"$BOOST_FLAG" + + # 执行写入将亮度设定为峰值极限 + echo -n "$max_bri" >"$now_bri_file" 2>/dev/null +fi + +exit 0 diff --git a/build-module.js b/build-module.js index 186fa96..7c76b05 100644 --- a/build-module.js +++ b/build-module.js @@ -1,6 +1,5 @@ import fs from 'fs'; import archiver from 'archiver'; -import { spawn } from 'child_process'; // 读取版本信息用以命名 const propContent = fs.readFileSync('module.prop', 'utf-8'); diff --git a/customize.sh b/customize.sh index 6df1dd1..dd10830 100755 --- a/customize.sh +++ b/customize.sh @@ -349,6 +349,26 @@ ENSURE_DEFAULTS() { [ ! -s "$mod_config/log_max_size.txt" ] && echo "500" >"$mod_config/log_max_size.txt" } +# 机型兼容性校验 +CHECK_DEVICE_COMPATIBILITY() { + local model prefix + model="$(getprop ro.product.model)" + prefix="$(echo "$model" | cut -c 1-9)" + + if [ "$prefix" = "25128PNA1" ] || [ "$prefix" = "2512BPNDA" ]; then + echo "" + echo "[!] 您可能是 Xiaomi 17 Ultra 用户,建议您使用 '0' 事件作为监测对象,否则模块可能不生效" + echo "[?] 是否将 inotifyd 监测事件修改为 '0'? (按音量 + 确认,按音量 - 跳过)" + if [ "$(button_listener)" = "0" ]; then + echo -n "0" >"$mod_config/inotify_events.txt" + echo "[OK] 已设置为 0 事件监测" + else + echo "[*] 已跳过配置更改" + fi + sleep 1 + fi +} + # 创建备份 (用于 WebUI 恢复默认) CREATE_BACKUP() { mkdir -p "$mod_config/.backup" @@ -370,6 +390,7 @@ MAIN() { TEST_UI_MAX_BRI fi ENSURE_DEFAULTS + CHECK_DEVICE_COMPATIBILITY CREATE_BACKUP END } diff --git a/module.prop b/module.prop index 8828fda..c017290 100755 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=LuminPro name=LuminPro丨日用屏幕亮度强化 version=V2.2 -versionCode=2203 +versionCode=2204 author=酷安@Yule description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果 updateJson=https://share.yule.ink/magisk/mod/luminpro/update.json \ No newline at end of file diff --git a/update.json b/update.json index 766bc71..c1f8139 100644 --- a/update.json +++ b/update.json @@ -1,6 +1,6 @@ { - "versionCode": 2203, + "versionCode": 2204, "version": "V2.2", - "zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2203.zip", + "zipUrl": "https://share.yule.ink/magisk/mod/luminpro/module/LuminPro_V2.2-2204.zip", "changelog": "https://share.yule.ink/magisk/mod/luminpro/changelog.md" } \ No newline at end of file diff --git a/webroot/index.html b/webroot/index.html index 3af0fbe..e754816 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -6,7 +6,7 @@ LuminPro - + @@ -32,6 +32,7 @@

实时状态

+
@@ -194,6 +195,7 @@
inotifyd 监听事件 默认 c。修改需重启服务 +
diff --git a/webui/index.html b/webui/index.html index 81e712c..b91d4d7 100644 --- a/webui/index.html +++ b/webui/index.html @@ -31,6 +31,7 @@

实时状态

+
diff --git a/webui/src/main.js b/webui/src/main.js index d0d444b..7e3ad3d 100644 --- a/webui/src/main.js +++ b/webui/src/main.js @@ -15,6 +15,9 @@ let NOW_BRI_FILE = DEFAULT_NOW_BRI_FILE; let SYS_MAX_BRI_FILE = DEFAULT_SYS_MAX_BRI_FILE; let INOTIFY_EVENTS = 'c'; +let cachedCurrentBri = null; +let cachedSysMaxBri = null; + // Web UI 配置 let statusLogRefreshInterval = 1000; // 状态/日志刷新间隔(默认1秒) let configRefreshInterval = 5000; // 配置卡片刷新间隔(默认5秒) @@ -328,10 +331,17 @@ async function handleReset() { } // 3. 刷新实时状态 -async function loadStatus() { - const [curRes, sysRes, pidRes, stopRes, autoBriRes] = await Promise.all([ - runCmd(`cat "${NOW_BRI_FILE}"`), - runCmd(`cat "${SYS_MAX_BRI_FILE}"`), +async function loadStatus(forceFull = false) { + if (forceFull || cachedCurrentBri === null || cachedSysMaxBri === null) { + const [cRes, sRes] = await Promise.all([ + runCmd(`cat "${NOW_BRI_FILE}"`), + runCmd(`cat "${SYS_MAX_BRI_FILE}"`) + ]); + if (cRes.errno === 0) cachedCurrentBri = cRes.stdout.trim(); + if (sRes.errno === 0) cachedSysMaxBri = sRes.stdout.trim(); + } + + const [pidRes, stopRes, autoBriRes] = await Promise.all([ runCmd(`cat "${PID_FILE}"`), runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`), runCmd(`settings get system screen_brightness_mode`) @@ -369,14 +379,14 @@ async function loadStatus() { } // 填入数值 - const currentBri = curRes.errno === 0 ? curRes.stdout.trim() : '0'; + const currentBri = cachedCurrentBri || '0'; document.getElementById('status-current-bri').textContent = currentBri; - document.getElementById('status-sys-max-bri').textContent = sysRes.errno === 0 ? sysRes.stdout.trim() : '—'; + document.getElementById('status-sys-max-bri').textContent = cachedSysMaxBri || '—'; document.getElementById('status-inotifyd-pid').textContent = running ? pidRes.stdout.trim() : '离线'; // 更新亮度滑条 const brightnessSlider = document.getElementById('brightness-slider'); - const sysMaxBri = sysRes.errno === 0 ? parseInt(sysRes.stdout.trim(), 10) : 255; + const sysMaxBri = cachedSysMaxBri ? parseInt(cachedSysMaxBri, 10) : 255; brightnessSlider.max = sysMaxBri; const currentBriValue = parseInt(currentBri, 10) || 0; brightnessSlider.value = currentBriValue; @@ -420,7 +430,7 @@ async function toggleService() { } else { showToast('操作失败: ' + res.stderr); } - await loadStatus(); + await loadStatus(true); } async function restartService() { const btn = document.getElementById('btn-restart-service'); @@ -439,7 +449,7 @@ async function restartService() { // 延迟刷新状态以确保 PID 文件已写入 setTimeout(async () => { - await loadStatus(); + await loadStatus(true); btn.disabled = false; }, 1000); } @@ -453,6 +463,7 @@ async function handleBrightnessChange(e) { // 立即更新 UI(不等待文件 IO) document.getElementById('brightness-display').textContent = percentage + '%'; + cachedCurrentBri = String(newBri); // 直接写入文件,无防抖 const cmd = `echo -n '${newBri}' > '${NOW_BRI_FILE}' 2>/dev/null && echo 'OK'`; @@ -460,11 +471,11 @@ async function handleBrightnessChange(e) { if (!(res.errno === 0 && res.stdout.includes('OK'))) { showToast('亮度设置失败,已恢复'); - await loadStatus(); // 恢复旧值 + await loadStatus(true); // 恢复旧值 } } catch (error) { showToast('设置亮度出错: ' + error.message); - await loadStatus(); + await loadStatus(true); } } @@ -598,7 +609,7 @@ async function startAutoRefreshConfig() { async function startAutoRefresh() { // 立即执行一次状态/日志刷新 - await Promise.all([loadStatus(), loadLogs()]); + await Promise.all([loadStatus(true), loadLogs()]); // 启动定时刷新 autoRefreshStatusLogTimer = setTimeout(startAutoRefreshStatusLog, statusLogRefreshInterval); @@ -690,6 +701,10 @@ async function init() { setupNavbar(); // 绑定事件 + document.getElementById('btn-refresh-status').addEventListener('click', async () => { + showToast('刷新状态...'); + await loadStatus(true); + }); document.getElementById('btn-save').addEventListener('click', saveConfig); document.getElementById('btn-save-advanced').addEventListener('click', saveAdvancedConfig); document.getElementById('btn-save-webui-config').addEventListener('click', saveWebUIConfig);