You've already forked Tricky-Addon-Update-Target-List
mirror of
https://github.com/KOWX712/Tricky-Addon-Update-Target-List.git
synced 2025-09-06 06:37:09 +00:00
Function to handle security patch operation
This commit is contained in:
@@ -146,6 +146,7 @@ set_security_patch() {
|
|||||||
resetprop ro.build.version.security_patch "$security_patch"
|
resetprop ro.build.version.security_patch "$security_patch"
|
||||||
fi
|
fi
|
||||||
echo "all=$formatted_security_patch" > "/data/adb/tricky_store/security_patch.txt"
|
echo "all=$formatted_security_patch" > "/data/adb/tricky_store/security_patch.txt"
|
||||||
|
chmod 644 "/data/adb/tricky_store/security_patch.txt"
|
||||||
else
|
else
|
||||||
echo "not set"
|
echo "not set"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -35,6 +35,36 @@ function hideSecurityPatchDialog() {
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to handle security patch operation
|
||||||
|
async function handleSecurityPatch(mode, value = null) {
|
||||||
|
if (mode === 'disable') {
|
||||||
|
try {
|
||||||
|
await execCommand(`
|
||||||
|
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
||||||
|
rm -f /data/adb/tricky_store/security_patch.txt
|
||||||
|
`);
|
||||||
|
showPrompt('security_patch.value_empty');
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
showPrompt('security_patch.save_failed', false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (mode === 'manual') {
|
||||||
|
try {
|
||||||
|
await execCommand(`
|
||||||
|
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
||||||
|
echo "${value}" > /data/adb/tricky_store/security_patch.txt
|
||||||
|
chmod 644 /data/adb/tricky_store/security_patch.txt
|
||||||
|
`);
|
||||||
|
showPrompt('security_patch.save_success');
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
showPrompt('security_patch.save_failed', false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load current configuration
|
// Load current configuration
|
||||||
async function loadCurrentConfig() {
|
async function loadCurrentConfig() {
|
||||||
try {
|
try {
|
||||||
@@ -165,16 +195,8 @@ export function securityPatch() {
|
|||||||
// Normal mode validation
|
// Normal mode validation
|
||||||
const allValue = allPatchInput.value.trim();
|
const allValue = allPatchInput.value.trim();
|
||||||
if (!allValue) {
|
if (!allValue) {
|
||||||
// Allow saving empty value
|
// Save empty value to disable auto config
|
||||||
try {
|
await handleSecurityPatch('disable');
|
||||||
await execCommand(`
|
|
||||||
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
|
||||||
> /data/adb/tricky_store/security_patch.txt
|
|
||||||
`);
|
|
||||||
showPrompt('security_patch.value_empty');
|
|
||||||
} catch (error) {
|
|
||||||
showPrompt('security_patch.save_failed', false);
|
|
||||||
}
|
|
||||||
hideSecurityPatchDialog();
|
hideSecurityPatchDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -182,17 +204,12 @@ export function securityPatch() {
|
|||||||
showPrompt('security_patch.invalid_all', false);
|
showPrompt('security_patch.invalid_all', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
const value = `all=${allValue}`;
|
||||||
await execCommand(`
|
const result = await handleSecurityPatch('manual', value);
|
||||||
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
if (result) {
|
||||||
echo all=${allValue} > /data/adb/tricky_store/security_patch.txt
|
|
||||||
`);
|
|
||||||
systemPatchInput.value = '';
|
systemPatchInput.value = '';
|
||||||
bootPatchInput.value = '';
|
bootPatchInput.value = '';
|
||||||
vendorPatchInput.value = '';
|
vendorPatchInput.value = '';
|
||||||
showPrompt('security_patch.save_success');
|
|
||||||
} catch (error) {
|
|
||||||
showPrompt('security_patch.save_failed', false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Advanced mode validation
|
// Advanced mode validation
|
||||||
@@ -201,16 +218,8 @@ export function securityPatch() {
|
|||||||
const vendorValue = vendorPatchInput.value.trim();
|
const vendorValue = vendorPatchInput.value.trim();
|
||||||
|
|
||||||
if (!bootValue && !systemValue && !vendorValue) {
|
if (!bootValue && !systemValue && !vendorValue) {
|
||||||
// Allow saving empty values for advanced mode as well
|
// Save empty values to disable auto config
|
||||||
try {
|
await handleSecurityPatch('disable');
|
||||||
await execCommand(`
|
|
||||||
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
|
||||||
> /data/adb/tricky_store/security_patch.txt
|
|
||||||
`);
|
|
||||||
showPrompt('security_patch.value_empty');
|
|
||||||
} catch (error) {
|
|
||||||
showPrompt('security_patch.save_failed', false);
|
|
||||||
}
|
|
||||||
hideSecurityPatchDialog();
|
hideSecurityPatchDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -230,21 +239,15 @@ export function securityPatch() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const config = [
|
||||||
const config = [
|
systemValue ? `system=${systemValue}` : '',
|
||||||
systemValue ? `system=${systemValue}` : '',
|
bootValue ? `boot=${bootValue}` : '',
|
||||||
bootValue ? `boot=${bootValue}` : '',
|
vendorValue ? `vendor=${vendorValue}` : ''
|
||||||
vendorValue ? `vendor=${vendorValue}` : ''
|
].filter(Boolean);
|
||||||
].filter(Boolean);
|
const value = config.filter(Boolean).join('\n');
|
||||||
await execCommand(`
|
const result = await handleSecurityPatch('manual', value);
|
||||||
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
|
if (result) {
|
||||||
echo "${config.filter(Boolean).join('\n')}" > /data/adb/tricky_store/security_patch.txt
|
|
||||||
`);
|
|
||||||
allPatchInput.value = '';
|
allPatchInput.value = '';
|
||||||
showPrompt('security_patch.save_success');
|
|
||||||
hideSecurityPatchDialog();
|
|
||||||
} catch (error) {
|
|
||||||
showPrompt('security_patch.save_failed', false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideSecurityPatchDialog();
|
hideSecurityPatchDialog();
|
||||||
|
|||||||
Reference in New Issue
Block a user