fix: unable to fetch security patch x2

#42
This commit is contained in:
KOWX712
2025-05-18 21:14:30 +08:00
parent 357289b558
commit 56afd639a4
5 changed files with 22 additions and 3 deletions

View File

@@ -136,8 +136,17 @@ set_security_patch() {
}
get_latest_security_patch() {
security_patch=$(download "https://source.android.com/docs/security/bulletin/pixel" | grep -o "<td>[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}</td>" | head -n 1 | sed 's/<td>\(.*\)<\/td>/\1/')
[ -n "$security_patch" ] && echo "$security_patch" || exit 1
security_patch=$(download "https://source.android.com/docs/security/bulletin/pixel" |
sed -n 's/.*<td>\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\)<\/td>.*/\1/p' |
head -n 1)
if [ -n "$security_patch" ]; then
echo "$security_patch"
exit 0
elif ! ping -c 1 -W 5 "source.android.com" >/dev/null 2>&1; then
echo "Connection failed" >&2
fi
exit 1
}
unknown_kb() {

View File

@@ -113,6 +113,7 @@
<string name="security_patch_fetching">Fetching...</string>
<string name="security_patch_fetched">Done</string>
<string name="security_patch_get_failed">Failed to fetch security patch date</string>
<string name="security_patch_unable_to_connect">Unable to connect to source.android.com</string>
<string name="security_patch_auto_success">Auto config enabled successfully</string>
<string name="security_patch_auto_failed">Failed to enable auto config</string>
<string name="security_patch_save_success">Security patch saved successfully</string>

View File

@@ -113,6 +113,7 @@
<string name="security_patch_fetching">获取中...</string>
<string name="security_patch_fetched">完成</string>
<string name="security_patch_get_failed">获取安全补丁日期失败</string>
<string name="security_patch_unable_to_connect">无法连接至 source.android.com</string>
<string name="security_patch_auto_success">自动配置成功启用</string>
<string name="security_patch_auto_failed">无法启用自动配置</string>
<string name="security_patch_save_success">安全补丁成功保存</string>

View File

@@ -113,6 +113,7 @@
<string name="security_patch_fetching">獲取中...</string>
<string name="security_patch_fetched">完成</string>
<string name="security_patch_get_failed">獲取安全補丁日期失敗</string>
<string name="security_patch_unable_to_connect">無法連線至 source.android.com</string>
<string name="security_patch_auto_success">自動配置成功啟用</string>
<string name="security_patch_auto_failed">無法啟用自動配置</string>
<string name="security_patch_save_success">安全補丁成功保存</string>

View File

@@ -314,7 +314,7 @@ export function securityPatch() {
getButton.addEventListener('click', async () => {
showPrompt('security_patch_fetching');
const output = spawn('sh', [`${basePath}/common/get_extra.sh`, '--get-security-patch'],
{ env: { PATH: "/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk:/data/data/com.termux/files/usr/bin:$PATH" }});
{ cwd: "/data/local/tmp", env: { PATH: "/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk:/data/data/com.termux/files/usr/bin:$PATH" }});
output.stdout.on('data', (data) => {
showPrompt('security_patch_fetched', true, 1000);
checkAdvanced(true);
@@ -324,6 +324,13 @@ export function securityPatch() {
bootPatchInput.value = data;
vendorPatchInput.value = data;
});
output.stderr.on('data', (data) => {
if (data.includes("failed")) {
showPrompt('security_patch_unable_to_connect', false);
} else {
console.error(data);
}
});
output.on('exit', (code) => {
if (code !== 0) showPrompt('security_patch_get_failed', false);
});