diff --git a/module/service.sh b/module/service.sh index 3f360d4..077a486 100644 --- a/module/service.sh +++ b/module/service.sh @@ -16,7 +16,13 @@ for kpm in $KPNDIR/kpm/*.kpm; do kpatch kpm load "$kpm" || rm -f "$kpm" done -[ -n "$REHOOK" ] && [ "$REHOOK" -ge 0 ] && [ "$REHOOK" -le 2 ] && kpatch rehook $REHOOK +if [ -n "$REHOOK" ]; then + if [ "$REHOOK" = "enable" ] || [ "$REHOOK" = "disable" ]; then + kpatch rehook $REHOOK + else + rm -f "$KPNDIR/rehook" + fi +fi until [ "$(getprop sys.boot_completed)" = "1" ]; do sleep 1 diff --git a/module/status.sh b/module/status.sh index 4e07a74..ac671bd 100644 --- a/module/status.sh +++ b/module/status.sh @@ -46,7 +46,7 @@ if kpatch hello >/dev/null 2>&1; then [ -z "$KPM_COUNT" ] && KPM_COUNT=0 REHOOK_MODE="$(kpatch rehook_status 2>/dev/null | awk '{print $NF}')" - [ -z "$REHOOK_MODE" ] && REHOOK_MODE="0" + [ -z "$REHOOK_MODE" ] && REHOOK_MODE="enabled" string="$active | kpmodule: $KPM_COUNT 💉 | rehook: $REHOOK_MODE 🪝" fi diff --git a/webui/index.html b/webui/index.html index 0d13a8c..9803baf 100644 --- a/webui/index.html +++ b/webui/index.html @@ -151,21 +151,16 @@
-
+
diff --git a/webui/index.js b/webui/index.js index d79fd0a..ddb2d74 100644 --- a/webui/index.js +++ b/webui/index.js @@ -9,12 +9,6 @@ import * as excludeModule from './page/exclude.js'; export const modDir = '/data/adb/modules/KPatch-Next'; export const persistDir = '/data/adb/kp-next'; -const rehookMode = [ - "disable", // 0 - "target", // 1 - "minimal" // 2 -] - export let MAX_CHUNK_SIZE = 96 * 1024; async function updateStatus() { @@ -62,38 +56,41 @@ async function reboot(reason = "") { async function initRehook() { const rehook = document.getElementById('rehook'); - const rehookMenu = rehook.querySelector('md-menu'); - const mode = await updateRehookStatus(); - if (mode) rehook.onclick = () => rehookMenu.open = !rehookMenu.open; - rehookMenu.querySelectorAll('md-menu-item').forEach((item, index) => { - item.onclick = () => { - setRehookMode(index); - rehook.click(); - } + const rehookRipple = rehook.querySelector('md-ripple'); + const rehookSwitch = rehook.querySelector('md-switch'); + const isEnabled = await updateRehookStatus(); + if (isEnabled === null) { + rehookRipple.disabled = true; + rehookSwitch.disabled = true; + return; + } + rehookSwitch.addEventListener('change', () => { + setRehookMode(rehookSwitch.selected); }); } async function updateRehookStatus() { const rehook = document.getElementById('rehook'); - const rehookText = rehook.querySelector('.menu-text'); - const rehookRipple = rehook.querySelector('md-ripple'); + const rehookSwitch = rehook.querySelector('md-switch'); - let modeName = 'target', modeId = null; + let isEnabled = null; const result = await exec(`kpatch rehook_status`, { env: { PATH: `${modDir}/bin` } }); - const mode = result.stdout.split('\n').find(line => line.includes('mode: ')); - if (mode) { - modeId = parseInt(mode.split(':')[1].trim()); - modeName = rehookMode[modeId]; + if (result.errno === 0) { + const mode = result.stdout.split(':')[1].trim(); + if (mode === 'enabled') { + isEnabled = true; + } else if (mode === 'disabled') { + isEnabled = false; + } + rehookSwitch.selected = isEnabled; } - rehookText.textContent = getString('label_rehook_mode_' + modeName); - rehookText.classList.toggle('disabled', !mode); - rehookRipple.disabled = !mode; - return modeId !== null; + return isEnabled; } -function setRehookMode(mode) { +function setRehookMode(isEnable) { + const mode = isEnable ? "enable" : "disable"; exec(` kpatch rehook ${mode} && echo ${mode} > ${persistDir}/rehook && sh "${modDir}/status.sh"`, { env: { PATH: `${modDir}/bin:$PATH` } } diff --git a/webui/public/locales/strings/bn.xml b/webui/public/locales/strings/bn.xml index 1d14ffa..1714fb0 100644 --- a/webui/public/locales/strings/bn.xml +++ b/webui/public/locales/strings/bn.xml @@ -16,7 +16,7 @@ ডাউনলোডে রিবুট EDL-এ রিবুট কার্নেল - রিহুক মোড + রিহুক Syscall ইনস্টল করতে ক্লিক করুন আনইনস্টল @@ -35,9 +35,6 @@ সিস্টেম অ্যাপ দেখান সিস্টেম ডিফল্ট ট্রিগার ইভেন্ট - নিষ্ক্রিয় - টার্গেট - ন্যূনতম ইনস্টল করা নেই কাজ করছে 😋 diff --git a/webui/public/locales/strings/en.xml b/webui/public/locales/strings/en.xml index 8b75ec2..2ce24df 100644 --- a/webui/public/locales/strings/en.xml +++ b/webui/public/locales/strings/en.xml @@ -16,7 +16,7 @@ Reboot to Download Reboot to EDL Kernel - Rehook Mode + Rehook Syscall Click to install Uninstall @@ -35,9 +35,6 @@ Show system app System Default Trigger Event - Disable - Target - Minimal Not installed Working 😋 diff --git a/webui/public/locales/strings/fr.xml b/webui/public/locales/strings/fr.xml index f7f449d..5257cd0 100644 --- a/webui/public/locales/strings/fr.xml +++ b/webui/public/locales/strings/fr.xml @@ -15,7 +15,7 @@ Redémarrer vers le Bootloader Redémarrer en mode Téléchargement Redémarrer en mode EDL - Mode Rehook + Rehook Syscall Appuyez pour installer Désinstaller @@ -33,9 +33,6 @@ Afficher les applications système Paramètre système par défaut Déclencher un événement - Désactiver - Cible - Minimal Non installé En fonctionnement 😋 diff --git a/webui/public/locales/strings/ja.xml b/webui/public/locales/strings/ja.xml index 01d0c1b..839f017 100644 --- a/webui/public/locales/strings/ja.xml +++ b/webui/public/locales/strings/ja.xml @@ -16,7 +16,7 @@ ダウンロードモードへ再起動 EDL へ再起動 カーネル - 再フックモード + 再フック Syscall クリックしてインストール アンインストール @@ -35,9 +35,6 @@ システムアプリを表示 システムのデフォルト トリガーイベント - 無効化 - ターゲット - 最小限 未インストール 動作中 😋 diff --git a/webui/public/locales/strings/tr.xml b/webui/public/locales/strings/tr.xml index 92b4db6..011600b 100644 --- a/webui/public/locales/strings/tr.xml +++ b/webui/public/locales/strings/tr.xml @@ -16,7 +16,7 @@ İndirme Modunda Yeniden Başlat EDL Modunda Yeniden Başlat Çekirdek - Yeniden Kancala Modu + Yeniden Kancala Syscall Yüklemek için tıkla Kaldır @@ -35,9 +35,6 @@ Sistem uygulamasını göster Sistem Varsayılanı Olay Tetikle - Devre Dışı Bırak - Hedef - Minimal Kurulu Değil Çalışıyor 😋 @@ -84,4 +81,4 @@ Uygulamalar yüklenirken hata oluştu: Uygulamalar oluşturulurken hata oluştu: Bilinmiyor - + \ No newline at end of file diff --git a/webui/public/locales/strings/zh-CN.xml b/webui/public/locales/strings/zh-CN.xml index 2158921..66b37da 100644 --- a/webui/public/locales/strings/zh-CN.xml +++ b/webui/public/locales/strings/zh-CN.xml @@ -16,7 +16,7 @@ 重启到 Download 重启到 EDL 内核 - 重挂钩模式 + 重挂钩 Syscall 点击安装 卸载 @@ -35,9 +35,6 @@ 显示系统应用 系统默认 触发事件 - 禁用 - 目标 - 最小化 未安装 工作中 😋