feat: add support for qwq233's tricky store fork

GitHub@qwq233/TrickyStore
This commit is contained in:
KOWX712
2025-06-19 00:12:37 +08:00
parent 4da0590440
commit 184d50840c
4 changed files with 105 additions and 21 deletions

View File

@@ -136,6 +136,14 @@ set_security_patch() {
SECURITY_PATCH_FILE="/data/adb/tricky_store/security_patch.txt" SECURITY_PATCH_FILE="/data/adb/tricky_store/security_patch.txt"
printf "system=prop\nboot=%s\nvendor=%s\n" "$security_patch" "$security_patch" > "$SECURITY_PATCH_FILE" printf "system=prop\nboot=%s\nvendor=%s\n" "$security_patch" "$security_patch" > "$SECURITY_PATCH_FILE"
chmod 644 "$SECURITY_PATCH_FILE" chmod 644 "$SECURITY_PATCH_FILE"
# James Clef's TrickyStore fork (GitHub@qwq233/TrickyStore)
elif grep -q "James" "/data/adb/modules/tricky_store/module.prop"; then
SECURITY_PATCH_FILE="/data/adb/tricky_store/devconfig.toml"
if grep -q "^securityPatch" "$SECURITY_PATCH_FILE"; then
sed -i "s/^securityPatch .*/securityPatch = \"$security_patch\"/" "$SECURITY_PATCH_FILE"
else
echo "securityPatch = \"$security_patch\"" >> "$SECURITY_PATCH_FILE"
fi
# Other # Other
else else
resetprop ro.vendor.build.security_patch "$security_patch" resetprop ro.vendor.build.security_patch "$security_patch"

View File

@@ -268,6 +268,7 @@
<div id="security-patch-card" class="security-patch-card overlay-content blur-box"> <div id="security-patch-card" class="security-patch-card overlay-content blur-box">
<div class="security-patch-header" data-i18n="security_patch_title"></div> <div class="security-patch-header" data-i18n="security_patch_title"></div>
<div class="security-patch-content"> <div class="security-patch-content">
<!-- Usual input -->
<div id="normal-mode-inputs" class="normal-mode-inputs"> <div id="normal-mode-inputs" class="normal-mode-inputs">
<div class="input-group"> <div class="input-group">
<label id="security_patch-all">All</label> <label id="security_patch-all">All</label>
@@ -275,6 +276,7 @@
</div> </div>
</div> </div>
<!-- Advanced input -->
<div id="advanced-mode-inputs" class="advanced-mode-inputs hidden"> <div id="advanced-mode-inputs" class="advanced-mode-inputs hidden">
<div class="input-group"> <div class="input-group">
<label id="security_patch-system">System</label> <label id="security_patch-system">System</label>
@@ -282,14 +284,27 @@
</div> </div>
<div class="input-group"> <div class="input-group">
<label id="security_patch-boot">Boot</label> <label id="security_patch-boot">Boot</label>
<input type="text" id="boot-patch" placeholder="2025-01-01" autocapitalize="none" oninput="formatDate(this, 'boot')" maxlength="10"> <input type="text" id="boot-patch" placeholder="2025-01-01" autocapitalize="none" oninput="formatDate(this)" maxlength="10">
</div> </div>
<div class="input-group"> <div class="input-group">
<label id="security_patch-vendor">Vendor</label> <label id="security_patch-vendor">Vendor</label>
<input type="text" id="vendor-patch" placeholder="2025-01-01" autocapitalize="none" oninput="formatDate(this, 'vendor')" maxlength="10"> <input type="text" id="vendor-patch" placeholder="2025-01-01" autocapitalize="none" oninput="formatDate(this)" maxlength="10">
</div> </div>
</div> </div>
<!-- James' fork input -->
<div id="james-mode-inputs" class="normal-mode-inputs hidden">
<div class="input-group">
<label id="security_patch-james">Security Patch</label>
<input type="text" id="james-patch" placeholder="2025-01-01" autocapitalize="none" oninput="formatDate(this)" maxlength="10">
</div>
<div class="input-group">
<label id="os-james">OS Version</label>
<input type="text" id="james-os" placeholder="34" maxlength="2" autocapitalize="none">
</div>
</div>
<!-- Advanced Toggle -->
<div class="advanced-toggle"> <div class="advanced-toggle">
<input type="checkbox" class="checkbox" id="advanced-mode" /> <input type="checkbox" class="checkbox" id="advanced-mode" />
<label for="advanced-mode" class="custom-checkbox"> <label for="advanced-mode" class="custom-checkbox">

View File

@@ -68,13 +68,23 @@ function checkTrickyStoreVersion() {
const securityPatchElement = document.getElementById('security-patch'); const securityPatchElement = document.getElementById('security-patch');
exec(` exec(`
TS_version=$(grep "versionCode=" "/data/adb/modules/tricky_store/module.prop" | cut -d'=' -f2) TS_version=$(grep "versionCode=" "/data/adb/modules/tricky_store/module.prop" | cut -d'=' -f2)
[ "$TS_version" -ge 158 ] if grep -q "James" "/data/adb/modules/tricky_store/module.prop"; then
`).then(({ errno }) => { echo 0
if (errno === 0) { elif [ "$TS_version" -ge 158 ]; then
echo 0
else
echo $TS_version
fi
`).then(({ stdout }) => {
if (stdout.trim() === "0") {
securityPatchElement.style.display = "flex"; securityPatchElement.style.display = "flex";
} else { } else {
console.log("Tricky Store version is lower than 158, or fail to check Tricky store version."); console.log("Tricky Store version:", stdout.trim());
} }
}).catch(error => {
// debug usage
console.error("Error checking Tricky Store version:", error);
securityPatchElement.style.display = "flex";
}); });
} }

View File

@@ -1,15 +1,21 @@
import { exec, spawn } from './assets/kernelsu.js'; import { exec, spawn } from './assets/kernelsu.js';
import { basePath, showPrompt } from './main.js'; import { basePath, showPrompt } from './main.js';
let jamesFork = false;
const overlay = document.getElementById('security-patch-overlay'); const overlay = document.getElementById('security-patch-overlay');
const overlayContent = document.querySelector('.security-patch-card'); const overlayContent = document.querySelector('.security-patch-card');
const advancedToggleElement = document.querySelector('.advanced-toggle');
const advancedToggle = document.getElementById('advanced-mode'); const advancedToggle = document.getElementById('advanced-mode');
const normalInputs = document.getElementById('normal-mode-inputs'); const normalInputs = document.getElementById('normal-mode-inputs');
const advancedInputs = document.getElementById('advanced-mode-inputs'); const advancedInputs = document.getElementById('advanced-mode-inputs');
const jamesInputs = document.getElementById('james-mode-inputs');
const allPatchInput = document.getElementById('all-patch'); const allPatchInput = document.getElementById('all-patch');
const bootPatchInput = document.getElementById('boot-patch'); const bootPatchInput = document.getElementById('boot-patch');
const systemPatchInput = document.getElementById('system-patch'); const systemPatchInput = document.getElementById('system-patch');
const vendorPatchInput = document.getElementById('vendor-patch'); const vendorPatchInput = document.getElementById('vendor-patch');
const jamesPatchInput = document.getElementById('james-patch');
const jamesOsInput = document.getElementById('james-os');
const getButton = document.getElementById('get-patch'); const getButton = document.getElementById('get-patch');
const autoButton = document.getElementById('auto-config'); const autoButton = document.getElementById('auto-config');
const saveButton = document.getElementById('save-patch'); const saveButton = document.getElementById('save-patch');
@@ -24,22 +30,27 @@ const hideSecurityPatchDialog = () => {
}, 200); }, 200);
} }
// Function to handle security patch operation /**
* Save the security patch configuration to file
* @param {string} mode - 'disable', 'manual'
* @param {string} value - The security patch value to save, if mode is 'manual'.
*/
function handleSecurityPatch(mode, value = null) { function handleSecurityPatch(mode, value = null) {
if (mode === 'disable') { if (mode === 'disable') {
exec(` exec(`
rm -f /data/adb/tricky_store/security_patch_auto_config || true rm -f /data/adb/tricky_store/security_patch_auto_config || true
rm -f /data/adb/tricky_store/security_patch.txt || true rm -f /data/adb/tricky_store/security_patch.txt || true
rm -f /data/adb/tricky_store/devconfig.toml || true
`).then(({ errno }) => { `).then(({ errno }) => {
const result = errno === 0; showPrompt('security_patch_value_empty');
showPrompt(result ? 'security_patch_value_empty' : 'security_patch_save_failed', result); return errno === 0;
return result;
}); });
} else if (mode === 'manual') { } else if (mode === 'manual') {
const configFile = jamesFork ? '/data/adb/tricky_store/devconfig.toml' : '/data/adb/tricky_store/security_patch.txt';
exec(` exec(`
rm -f /data/adb/tricky_store/security_patch_auto_config || true ${jamesFork ? '' : 'rm -f /data/adb/tricky_store/security_patch_auto_config || true'}
echo "${value}" > /data/adb/tricky_store/security_patch.txt echo "${value}" > ${configFile}
chmod 644 /data/adb/tricky_store/security_patch.txt chmod 644 ${configFile}
`).then(({ errno }) => { `).then(({ errno }) => {
const result = errno === 0; const result = errno === 0;
showPrompt(result ? 'security_patch_save_success' : 'security_patch_save_failed', result); showPrompt(result ? 'security_patch_save_success' : 'security_patch_save_failed', result);
@@ -53,7 +64,22 @@ async function loadCurrentConfig() {
let allValue, systemValue, bootValue, vendorValue; let allValue, systemValue, bootValue, vendorValue;
try { try {
const { errno } = await exec('[ -f /data/adb/tricky_store/security_patch_auto_config ]'); const { errno } = await exec('[ -f /data/adb/tricky_store/security_patch_auto_config ]');
if (errno === 0) { if (jamesFork) {
const { stdout } = await exec('cat /data/adb/tricky_store/devconfig.toml');
if (stdout.trim() !== '') {
const lines = stdout.split('\n');
for (const line of lines) {
if (line.startsWith('securityPatch =')) {
const jamesPatchValue = line.split('=')[1].trim().replace(/"/g, '');
if (jamesPatchValue !== '') jamesPatchInput.value = jamesPatchValue;
}
if (line.startsWith('osVersion =')) {
const jamesOsVersionValue = line.split('=')[1].trim().replace(/"/g, '');
if (jamesOsVersionValue !== '') jamesOsInput.value = jamesOsVersionValue;
}
}
}
} else if (errno === 0) {
allValue = null; allValue = null;
systemValue = null; systemValue = null;
bootValue = null; bootValue = null;
@@ -62,8 +88,8 @@ async function loadCurrentConfig() {
// Read values from tricky_store if manual mode // Read values from tricky_store if manual mode
const { stdout } = await exec('cat /data/adb/tricky_store/security_patch.txt'); const { stdout } = await exec('cat /data/adb/tricky_store/security_patch.txt');
if (stdout.trim() !== '') { if (stdout.trim() !== '') {
const trickyLines = stdout.split('\n'); const lines = stdout.split('\n');
for (const line of trickyLines) { for (const line of lines) {
if (line.startsWith('all=')) { if (line.startsWith('all=')) {
allValue = line.split('=')[1] || null; allValue = line.split('=')[1] || null;
if (allValue !== null) allPatchInput.value = allValue; if (allValue !== null) allPatchInput.value = allValue;
@@ -101,6 +127,7 @@ async function loadCurrentConfig() {
// Function to check advanced mode // Function to check advanced mode
function checkAdvanced(shouldCheck) { function checkAdvanced(shouldCheck) {
if (jamesFork) return;
if (shouldCheck) { if (shouldCheck) {
advancedToggle.checked = true; advancedToggle.checked = true;
normalInputs.classList.add('hidden'); normalInputs.classList.add('hidden');
@@ -113,7 +140,7 @@ function checkAdvanced(shouldCheck) {
} }
// Unified date formatting function // Unified date formatting function
window.formatDate = function(input, type) { window.formatDate = function(input) {
let value = input.value.replace(/-/g, ''); let value = input.value.replace(/-/g, '');
let formatted = value.slice(0, 4); let formatted = value.slice(0, 4);
@@ -191,6 +218,15 @@ function isValid8Digit(value) {
// Initialize event listeners // Initialize event listeners
export function securityPatch() { export function securityPatch() {
exec(`grep -q "James" "/data/adb/modules/tricky_store/module.prop"`)
.then(({ errno }) => {
if (errno === 0) {
jamesFork = true;
advancedToggleElement.style.display = 'none';
normalInputs.classList.add('hidden');
jamesInputs.classList.remove('hidden');
}
});
document.getElementById("security-patch").addEventListener("click", () => { document.getElementById("security-patch").addEventListener("click", () => {
setTimeout(() => { setTimeout(() => {
document.body.classList.add("no-scroll"); document.body.classList.add("no-scroll");
@@ -245,7 +281,22 @@ export function securityPatch() {
// Save button // Save button
saveButton.addEventListener('click', async () => { saveButton.addEventListener('click', async () => {
if (!advancedToggle.checked) { if (jamesFork) {
const securityPatchValue = jamesPatchInput.value.trim();
const osVersionValue = jamesOsInput.value.trim();
if (!securityPatchValue) handleSecurityPatch('disable');
if (!securityPatchValue && !osVersionValue) {
hideSecurityPatchDialog();
return;
}
const config = [
securityPatchValue ? `securityPatch = \\"${securityPatchValue}\\"` : '',
osVersionValue ? `osVersion = ${osVersionValue}` : ''
].filter(Boolean).join('\n');
handleSecurityPatch('manual', config);
} else if (!advancedToggle.checked) {
// Normal mode validation // Normal mode validation
const allValue = allPatchInput.value.trim(); const allValue = allPatchInput.value.trim();
if (!allValue) { if (!allValue) {
@@ -298,9 +349,8 @@ export function securityPatch() {
systemValue ? `system=${systemValue}` : '', systemValue ? `system=${systemValue}` : '',
bootValue ? `boot=${bootValue}` : '', bootValue ? `boot=${bootValue}` : '',
vendorValue ? `vendor=${vendorValue}` : '' vendorValue ? `vendor=${vendorValue}` : ''
].filter(Boolean); ].filter(Boolean).join('\n');
const value = config.filter(Boolean).join('\n'); const result = handleSecurityPatch('manual', config);
const result = handleSecurityPatch('manual', value);
if (result) { if (result) {
// Reset inputs // Reset inputs
allPatchInput.value = ''; allPatchInput.value = '';
@@ -323,6 +373,7 @@ export function securityPatch() {
systemPatchInput.value = 'prop'; systemPatchInput.value = 'prop';
bootPatchInput.value = data; bootPatchInput.value = data;
vendorPatchInput.value = data; vendorPatchInput.value = data;
jamesPatchInput.value = data;
}); });
output.stderr.on('data', (data) => { output.stderr.on('data', (data) => {
if (data.includes("failed")) { if (data.includes("failed")) {