diff --git a/module/common/get_extra.sh b/module/common/get_extra.sh index 699458c..5e2bcb0 100644 --- a/module/common/get_extra.sh +++ b/module/common/get_extra.sh @@ -127,6 +127,30 @@ awk ' ' "$MODPATH/tmp/changelog.md" } +set_security_patch() { + # Find pif.json + [ -f "/data/adb/modules/playintegrityfix/pif.json" ] && PIF="/data/adb/modules/playintegrityfix/pif.json" + [ -f "/data/adb/pif.json" ] && PIF="/data/adb/pif.json" + [ -f "/data/adb/modules/playintegrityfix/custom.pif.json" ] && PIF="/data/adb/modules/playintegrityfix/custom.pif.json" + + security_patch=$(grep '"SECURITY_PATCH"' "$PIF" | sed 's/.*: "//; s/".*//') + [ -z "$security_patch" ] && security_patch=$(getprop ro.build.version.security_patch) # Fallback + + formatted_security_patch=$(echo "$security_patch" | sed 's/-//g') + security_patch_after_1y=$(echo "$formatted_security_patch + 10000" | bc) + TODAY=$(date +%Y%m%d) + if [ -n "$formatted_security_patch" ] && [ "$TODAY" -lt "$security_patch_after_1y" ]; then + TS_version=$(grep "versionCode=" "$TS/module.prop" | cut -d'=' -f2) + if [ "$TS_version" -lt 158 ]; then + resetprop ro.vendor.build.security_patch "$security_patch" + resetprop ro.build.version.security_patch "$security_patch" + fi + echo "all=$formatted_security_patch" > "/data/adb/tricky_store/security_patch.txt" + else + echo "not set" + fi +} + case "$1" in --kb) get_kb @@ -160,4 +184,8 @@ case "$1" in release_note exit ;; +--security-patch) + set_security_patch + exit + ;; esac diff --git a/module/service.sh b/module/service.sh index aca090c..cf5c11d 100644 --- a/module/service.sh +++ b/module/service.sh @@ -1,7 +1,6 @@ MODPATH=${0%/*} HIDE_DIR="/data/adb/modules/.TA_utl" TS="/data/adb/modules/tricky_store" -TARGET_DIR="/data/adb/tricky_store" TSPA="/data/adb/modules/tsupport-advance" aapt() { "$MODPATH/common/aapt" "$@"; } @@ -23,34 +22,9 @@ add_denylist_to_target() { done } -set_security_patch() { - vendor_patch=$(getprop ro.vendor.build.security_patch | sed 's/-//g') - vendor_patch_after_1y=$(echo "$vendor_patch + 10000" | bc) - TODAY=$(date +%Y%m%d) - if [ "$TODAY" -ge "$vendor_patch_after_1y" ]; then - [ -f "/data/adb/modules/playintegrityfix/pif.json" ] && PIF="/data/adb/modules/playintegrityfix/pif.json" - [ -f "/data/adb/pif.json" ] && PIF="/data/adb/pif.json" - [ -f "/data/adb/modules/playintegrityfix/custom.pif.json" ] && PIF="/data/adb/modules/playintegrityfix/custom.pif.json" - security_patch=$(grep '"SECURITY_PATCH"' "$PIF" | sed 's/.*: "//; s/".*//') - [ -z "$security_patch" ] && security_patch=$(getprop ro.build.version.security_patch) - - formatted_security_patch=$(echo "$security_patch" | sed 's/-//g') - security_patch_after_1y=$(echo "$formatted_security_patch + 10000" | bc) - if [ -n "$formatted_security_patch" ] && [ "$TODAY" -lt "$security_patch_after_1y" ]; then - TS_version=$(grep "versionCode=" "$TS/module.prop" | cut -d'=' -f2) - if [ "$TS_version" -lt 158 ]; then - resetprop ro.vendor.build.security_patch "$security_patch" - resetprop ro.build.version.security_patch "$security_patch" - else - echo "all=$formatted_security_patch" > "$TARGET_DIR/security_patch.txt" - fi - fi - fi -} - # Spoof security patch if grep -q "^auto_config=1" "/data/adb/security_patch"; then - set_security_patch + sh "$MODPATH/common/get_extra.sh" --security-patch fi # Reset verified Boot Hash diff --git a/module/webui/locales/A-template.json b/module/webui/locales/A-template.json index e6e2711..e778795 100644 --- a/module/webui/locales/A-template.json +++ b/module/webui/locales/A-template.json @@ -97,14 +97,14 @@ "advanced_mode": "Advanced", "auto": "Auto", "save": "Save", - "auto_success": "Auto config enabled successfully, reboot to apply.", + "auto_success": "Auto config enabled successfully", "auto_failed": "Failed to enable auto config", "save_success": "Security patch saved successfully", "save_failed": "Failed to save security patch", - "value_empty": "Security patch configuration is disabled.", - "invalid_all": "Invalid format.", - "invalid_boot": "Invalid boot format.", - "invalid_system": "Invalid system format.", - "invalid_vendor": "Invalid vendor format." + "value_empty": "Security patch configuration is disabled", + "invalid_all": "Invalid format", + "invalid_boot": "Invalid boot format", + "invalid_system": "Invalid system format", + "invalid_vendor": "Invalid vendor format" } } \ No newline at end of file diff --git a/module/webui/locales/en-US.json b/module/webui/locales/en-US.json index e6e2711..e778795 100644 --- a/module/webui/locales/en-US.json +++ b/module/webui/locales/en-US.json @@ -97,14 +97,14 @@ "advanced_mode": "Advanced", "auto": "Auto", "save": "Save", - "auto_success": "Auto config enabled successfully, reboot to apply.", + "auto_success": "Auto config enabled successfully", "auto_failed": "Failed to enable auto config", "save_success": "Security patch saved successfully", "save_failed": "Failed to save security patch", - "value_empty": "Security patch configuration is disabled.", - "invalid_all": "Invalid format.", - "invalid_boot": "Invalid boot format.", - "invalid_system": "Invalid system format.", - "invalid_vendor": "Invalid vendor format." + "value_empty": "Security patch configuration is disabled", + "invalid_all": "Invalid format", + "invalid_boot": "Invalid boot format", + "invalid_system": "Invalid system format", + "invalid_vendor": "Invalid vendor format" } } \ No newline at end of file diff --git a/module/webui/locales/es-ES.json b/module/webui/locales/es-ES.json index f9cca49..e13f1fc 100644 --- a/module/webui/locales/es-ES.json +++ b/module/webui/locales/es-ES.json @@ -97,14 +97,14 @@ "advanced_mode": "Avanzado", "auto": "Automático", "save": "Guardar", - "auto_success": "Configuración automática habilitada con éxito, reinicia para aplicar.", + "auto_success": "Configuración automática habilitada con éxito", "auto_failed": "Error al habilitar la configuración automática", "save_success": "Parche de seguridad guardado con éxito", "save_failed": "Error al guardar el parche de seguridad", - "value_empty": "La configuración del parche de seguridad está deshabilitada.", - "invalid_all": "Formato inválido.", - "invalid_boot": "Formato de arranque inválido.", - "invalid_system": "Formato de sistema inválido.", - "invalid_vendor": "Formato de proveedor inválido." + "value_empty": "La configuración del parche de seguridad está deshabilitada", + "invalid_all": "Formato inválido", + "invalid_boot": "Formato de arranque inválido", + "invalid_system": "Formato de sistema inválido", + "invalid_vendor": "Formato de proveedor inválido" } } \ No newline at end of file diff --git a/module/webui/locales/ja-JP.json b/module/webui/locales/ja-JP.json index e1e016e..7283750 100644 --- a/module/webui/locales/ja-JP.json +++ b/module/webui/locales/ja-JP.json @@ -97,14 +97,14 @@ "advanced_mode": "高度", "auto": "自動", "save": "保存", - "auto_success": "自動設定が正常に有効になりました。適用するには再起動してください。", + "auto_success": "自動配置已成功啟用", "auto_failed": "自動設定を有効にできませんでした", "save_success": "セキュリティパッチが正常に保存されました", "save_failed": "セキュリティパッチの保存に失敗しました", - "value_empty": "セキュリティパッチの設定は無効です。", - "invalid_all": "無効な形式です。", - "invalid_boot": "無効なブート形式です。", - "invalid_system": "無効なシステム形式です。", - "invalid_vendor": "無効なベンダー形式です。" + "value_empty": "セキュリティパッチの設定は無効です", + "invalid_all": "無効な形式です", + "invalid_boot": "無効なブート形式です", + "invalid_system": "無効なシステム形式です", + "invalid_vendor": "無効なベンダー形式です" } } \ No newline at end of file diff --git a/module/webui/locales/ru-RU.json b/module/webui/locales/ru-RU.json index 03d193c..7bbb89f 100644 --- a/module/webui/locales/ru-RU.json +++ b/module/webui/locales/ru-RU.json @@ -97,14 +97,14 @@ "advanced_mode": "Расширенный", "auto": "Авто", "save": "Сохранить", - "auto_success": "Автоматическая конфигурация успешно включена, перезагрузите для применения.", + "auto_success": "Автоматическая конфигурация успешно включена", "auto_failed": "Не удалось включить автоматическую конфигурацию", "save_success": "Патч безопасности успешно сохранен", "save_failed": "Не удалось сохранить патч безопасности", - "value_empty": "Конфигурация патча безопасности отключена.", - "invalid_all": "Неверный формат.", - "invalid_boot": "Неверный формат загрузки.", - "invalid_system": "Неверный формат системы.", + "value_empty": "Конфигурация патча безопасности отключена", + "invalid_all": "Неверный формат", + "invalid_boot": "Неверный формат загрузки", + "invalid_system": "Неверный формат системы", "invalid_vendor": "Неверный формат поставщика." } } \ No newline at end of file diff --git a/module/webui/locales/tl-PH.json b/module/webui/locales/tl-PH.json index bff5f08..c13e75a 100644 --- a/module/webui/locales/tl-PH.json +++ b/module/webui/locales/tl-PH.json @@ -97,14 +97,14 @@ "advanced_mode": "Advanced", "auto": "Auto", "save": "I-save", - "auto_success": "Matagumpay na na-enable ang auto config, mag-reboot upang i-apply.", + "auto_success": "Matagumpay na na-enable ang auto config", "auto_failed": "Nabigong i-enable ang auto config", "save_success": "Matagumpay na na-save ang security patch", "save_failed": "Nabigong i-save ang security patch", - "value_empty": "Naka-disable ang configuration ng security patch.", - "invalid_all": "Invalid format.", - "invalid_boot": "Invalid boot format.", - "invalid_system": "Invalid system format.", - "invalid_vendor": "Invalid vendor format." + "value_empty": "Naka-disable ang configuration ng security patch", + "invalid_all": "Invalid format", + "invalid_boot": "Invalid boot format", + "invalid_system": "Invalid system format", + "invalid_vendor": "Invalid vendor format" } } \ No newline at end of file diff --git a/module/webui/locales/tr-TR.json b/module/webui/locales/tr-TR.json index deda915..4caed68 100644 --- a/module/webui/locales/tr-TR.json +++ b/module/webui/locales/tr-TR.json @@ -97,11 +97,11 @@ "advanced_mode": "Gelişmiş", "auto": "Otomatik", "save": "Kaydet", - "auto_success": "Otomatik yapılandırma başarıyla etkinleştirildi, yeniden başlatın.", + "auto_success": "Otomatik yapılandırma başarıyla etkinleştirildi", "auto_failed": "Otomatik yapılandırma etkinleştirilemedi", "save_success": "Güvenlik parçası başarıyla kaydedildi", "save_failed": "Güvenlik parçası kaydedilemedi", - "value_empty": "Güvenlik parçası yapılandırması devre dışı bırakıldı.", + "value_empty": "Güvenlik parçası yapılandırması devre dışı bırakıldı", "invalid_all": "Geçersiz format", "invalid_boot": "Geçersiz başlatma formatı", "invalid_system": "Geçersiz sistem formatı", diff --git a/module/webui/locales/zh-CN.json b/module/webui/locales/zh-CN.json index 524d535..df0a9e9 100644 --- a/module/webui/locales/zh-CN.json +++ b/module/webui/locales/zh-CN.json @@ -97,14 +97,14 @@ "advanced_mode": "高级", "auto": "自动", "save": "保存", - "auto_success": "自动配置成功启用,重启生效。", + "auto_success": "自动配置成功启用", "auto_failed": "无法启用自动配置", "save_success": "安全补丁成功保存", "save_failed": "保存安全补丁失败", - "value_empty": "安全补丁配置已禁用。", - "invalid_all": "无效格式。", - "invalid_boot": "无效启动格式。", - "invalid_system": "无效系统格式。", - "invalid_vendor": "无效供应商格式。" + "value_empty": "安全补丁配置已禁用", + "invalid_all": "无效格式", + "invalid_boot": "无效启动格式", + "invalid_system": "无效系统格式", + "invalid_vendor": "无效供应商格式" } } \ No newline at end of file diff --git a/module/webui/locales/zh-TW.json b/module/webui/locales/zh-TW.json index c1e7d47..886e46f 100644 --- a/module/webui/locales/zh-TW.json +++ b/module/webui/locales/zh-TW.json @@ -97,14 +97,14 @@ "advanced_mode": "進階", "auto": "自動", "save": "保存", - "auto_success": "自動配置成功啟用,重啟生效。", + "auto_success": "自動配置成功啟用", "auto_failed": "無法啟用自動配置", "save_success": "安全補丁成功保存", "save_failed": "保存安全補丁失敗", - "value_empty": "安全補丁配置已禁用。", - "invalid_all": "無效格式。", - "invalid_boot": "無效啟動格式。", - "invalid_system": "無效系統格式。", - "invalid_vendor": "無效供應商格式。" + "value_empty": "安全補丁配置已禁用", + "invalid_all": "無效格式", + "invalid_boot": "無效啟動格式", + "invalid_system": "無效系統格式", + "invalid_vendor": "無效供應商格式" } } \ No newline at end of file diff --git a/module/webui/scripts/security_patch.js b/module/webui/scripts/security_patch.js index d8f4164..9882172 100644 --- a/module/webui/scripts/security_patch.js +++ b/module/webui/scripts/security_patch.js @@ -1,4 +1,4 @@ -import { execCommand, showPrompt } from './main.js'; +import { basePath, execCommand, showPrompt } from './main.js'; const overlay = document.getElementById('security-patch-overlay'); const card = document.getElementById('security-patch-card'); @@ -133,12 +133,17 @@ export function securityPatch() { // Auto config button autoButton.addEventListener('click', async () => { try { - await execCommand(`sed -i "s/^auto_config=.*/auto_config=1/" /data/adb/security_patch`); - allPatchInput.value = ''; - bootPatchInput.value = ''; - systemPatchInput.value = ''; - vendorPatchInput.value = ''; - showPrompt('security_patch.auto_success'); + const output = await execCommand(`sh ${basePath}common/get_extra.sh --security-patch`); + if (output.trim() === "not set") { + showPrompt('security_patch.auto_failed', false); + } else { + await execCommand(`sed -i "s/^auto_config=.*/auto_config=1/" /data/adb/security_patch`); + allPatchInput.value = ''; + bootPatchInput.value = ''; + systemPatchInput.value = ''; + vendorPatchInput.value = ''; + showPrompt('security_patch.auto_success'); + } } catch (error) { showPrompt('security_patch.auto_failed', false); }