change kb logic

This commit is contained in:
KOWX712
2024-11-20 15:05:37 +08:00
parent 67581ae941
commit e848da327b
8 changed files with 90 additions and 90 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,7 @@
MODPATH=${0%/*}
OUTPUT="$MODPATH/exclude-list"
KBOUTPUT="$MODPATH/.extra"
. $MODPATH/util_func.sh
@@ -20,5 +21,12 @@ awk -F'"' '{print $4}' >> "$OUTPUT"
if [ ! -s "$OUTPUT" ]; then
echo "Error: Failed to fetch data." > "$OUTPUT"
rm -f "$KBOUTPUT"
exit 1
fi
wget --no-check-certificate -qO "$KBOUTPUT" "https://raw.githubusercontent.com/KOWX712/Tricky-Addon-Update-Target-List/master/.extra"
if [ ! -s "$KBOUTPUT" ]; then
rm -f "$KBOUTPUT"
fi

View File

@@ -1,9 +1,9 @@
PACKAGE_NAME="io.github.a13e300.ksuwebui"
MODID="set-id"
BBPATH="/data/adb/modules/busybox-ndk/system/*/busybox \
/data/adb/magisk/busybox \
/data/adb/ksu/bin/busybox \
/data/adb/ap/bin/busybox"
/data/adb/magisk/busybox \
/data/adb/ksu/bin/busybox \
/data/adb/ap/bin/busybox"
find_busybox() {
for path in $BBPATH; do

View File

@@ -37,14 +37,6 @@ ui_print "- Creating config directory..."
find_config
migrate_old_boot_hash
ui_print "*********************************************"
ui_print "- Do you want to replace tricky store keybox? (AOSP, no strong)"
ui_print " VOL [+]: YES"
ui_print " VOL [-]: NO"
ui_print "*********************************************"
key_check
kb_operation
rm -f "$MODPATH/install_func.sh"
ui_print "- Installation completed successfully! "

View File

@@ -20,7 +20,7 @@ initialize() {
set_perm $COMPATH/aapt 0 2000 0755
set_perm $SCRIPT_DIR/UpdateTargetList.sh 0 2000 0755
set_perm $COMPATH/get_exclude-list.sh 0 2000 0755
set_perm $COMPATH/get_extra.sh 0 2000 0755
set_perm $COMPATH/get_WebUI.sh 0 2000 0755
if [ "$ACTION" = "false" ]; then
@@ -90,46 +90,4 @@ migrate_old_boot_hash() {
echo -e "\n$hash_value" >> "/data/adb/boot_hash"
fi
fi
}
key_check() {
while true; do
key_check=$(/system/bin/getevent -qlc 1)
key_event=$(echo "$key_check" | awk '{ print $3 }' | grep 'KEY_')
key_status=$(echo "$key_check" | awk '{ print $4 }')
if [[ "$key_event" == *"KEY_"* && "$key_status" == "DOWN" ]]; then
keycheck="$key_event"
break
fi
done
while true; do
key_check=$(/system/bin/getevent -qlc 1)
key_event=$(echo "$key_check" | awk '{ print $3 }' | grep 'KEY_')
key_status=$(echo "$key_check" | awk '{ print $4 }')
if [[ "$key_event" == *"KEY_"* && "$key_status" == "UP" ]]; then
break
fi
done
}
kb_operation() {
if [[ "$keycheck" == "KEY_VOLUMEUP" ]]; then
ui_print "- Backing up original keybox..."
ui_print "- Replacing keybox..."
ui_print "*********************************************"
if [ -f "$ORG_DIR/common/origkeybox" ]; then
mv "$ORG_DIR/common/origkeybox" "$COMPATH/origkeybox"
else
mv "$SCRIPT_DIR/keybox.xml" "$COMPATH/origkeybox"
fi
mv "$kb" "$SCRIPT_DIR/keybox.xml"
else
if [ -f "$ORG_DIR/common/origkeybox" ]; then
mv "$ORG_DIR/common/origkeybox" "$COMPATH/origkeybox"
fi
rm -f "$kb"
fi
}

View File

@@ -6,11 +6,8 @@ if [ -f "/storage/emulated/0/stop-tspa-auto-target" ]; then
rm -f "/storage/emulated/0/stop-tspa-auto-target"
fi
# Remove residue and restore original keybox.
# Remove residue and restore aosp keybox.
rm -rf "$SCRIPT_DIR/target_list_config"
rm -f "$SCRIPT_DIR/UpdateTargetList.sh"
rm -f "/data/adb/boot_hash"
if [ -f "$MODPATH/common/origkeybox" ]; then
rm -f "$SCRIPT_DIR/keybox.xml"
mv "$MODPATH/common/origkeybox" "$SCRIPT_DIR/keybox.xml"
fi
xxd -r -p "$MODPATH/common/.default" | base64 -d > "$SCRIPT_DIR/keybox.xml"

View File

@@ -64,6 +64,12 @@
<li><br></li>
</ul>
</li>
<li>AOSP & Valid Keybox
<ul>
<li>Replace tricky store keybox. AOSP keybox will be replaced if there's no more valid keybox.</li>
<li><br></li>
</ul>
</li>
</ul>
</div>
</div>
@@ -85,7 +91,9 @@
<li id="select-all">Select All</li>
<li id="deselect-all">Deselect All</li>
<li id="select-denylist">Select From DenyList</li>
<li id="deselect-xposed">Deselect Unnecessary</li>
<li id="deselect-unnecessary">Deselect Unnecessary</li>
<li id="aospkb">AOSP Keybox</li>
<li id="extrakb">Valid Keybox</li>
</ul>
</div>
</div>

View File

@@ -96,6 +96,7 @@ async function fetchAppList() {
} catch (error) {
console.error("Failed to fetch or render app list with names:", error);
}
floatingBtn.style.transform = "translateY(-100px)";
}
@@ -112,44 +113,62 @@ async function refreshAppList() {
await new Promise(resolve => setTimeout(resolve, 500));
window.scrollTo(0, 0);
if (noConnection.style.display === "flex") {
await runXposedScript();
await runExtraScript();
}
await fetchAppList();[]
loadingIndicator.style.display = 'none';
isRefreshing = false;
}
// Function to run the Xposed script
async function runXposedScript() {
// Function to select all visible apps
function selectAllApps() {
document.querySelectorAll(".card").forEach(card => {
if (card.style.display !== "none") {
card.querySelector(".checkbox").checked = true;
}
});
}
// Function to deselect all visible apps
function deselectAllApps() {
document.querySelectorAll(".card").forEach(card => {
if (card.style.display !== "none") {
card.querySelector(".checkbox").checked = false;
}
});
}
// Function to run the extra script
async function runExtraScript() {
try {
const scriptPath = `${basePath}get_exclude-list.sh`;
const scriptPath = `${basePath}get_extra.sh`;
await execCommand(scriptPath);
console.log("Xposed script executed successfully.");
console.log("Extra script executed successfully.");
noConnection.style.display = "none";
} catch (error) {
console.error("Failed to execute Xposed script:", error);
console.error("Failed to execute Extra script:", error);
showPrompt("Please check your Internet connection", false);
noConnection.style.display = "flex";
}
}
// Function to read the Xposed list and uncheck corresponding apps
async function deselectXposedApps() {
// Function to read the exclude list and uncheck corresponding apps
async function deselectUnnecessaryApps() {
try {
const result = await execCommand(`cat ${basePath}exclude-list`);
const xposedApps = result.split("\n").map(app => app.trim()).filter(Boolean);
const UnnecessaryApps = result.split("\n").map(app => app.trim()).filter(Boolean);
const apps = document.querySelectorAll(".card");
apps.forEach(app => {
const contentElement = app.querySelector(".content");
const packageName = contentElement.getAttribute("data-package");
const checkbox = app.querySelector(".checkbox");
if (xposedApps.includes(packageName)) {
checkbox.checked = false; // Uncheck if found in Xposed list
if (UnnecessaryApps.includes(packageName)) {
checkbox.checked = false; // Uncheck if found in more-exclude list
}
});
console.log("Xposed apps deselected successfully.");
console.log("unnecessary apps deselected successfully.");
} catch (error) {
console.error("Failed to deselect Xposed apps:", error);
console.error("Failed to deselect unnecessary apps:", error);
}
}
@@ -185,6 +204,7 @@ async function selectDenylistApps() {
`);
const denylistApps = result.split("\n").map(app => app.trim()).filter(Boolean);
const apps = document.querySelectorAll(".card");
await deselectAllApps();
apps.forEach(app => {
const contentElement = app.querySelector(".content");
const packageName = contentElement.getAttribute("data-package");
@@ -199,22 +219,37 @@ async function selectDenylistApps() {
}
}
// Function to select all visible apps
function selectAllApps() {
document.querySelectorAll(".card").forEach(card => {
if (card.style.display !== "none") {
card.querySelector(".checkbox").checked = true;
}
});
// Function to replace aosp kb
async function aospkb() {
try {
const sourcePath = `${basePath}.default`;
const destinationPath = "/data/adb/tricky_store/keybox.xml";
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
console.log("AOSP keybox copied successfully.");
showPrompt("keybox.xml successfully updated with AOSP keybox.");
} catch (error) {
console.error("Failed to copy AOSP keybox:", error);
showPrompt("Failed to update keybox.", false);
}
}
// Function to deselect all visible apps
function deselectAllApps() {
document.querySelectorAll(".card").forEach(card => {
if (card.style.display !== "none") {
card.querySelector(".checkbox").checked = false;
// Function to replace valid kb
async function extrakb() {
const sourcePath = `${basePath}.extra`;
const destinationPath = "/data/adb/tricky_store/keybox.xml";
try {
const fileExists = await execCommand(`[ -f ${sourcePath} ] && echo "exists"`);
if (fileExists.trim() !== "exists") {
throw new Error(".extra file not found");
}
});
await execCommand(`xxd -r -p ${sourcePath} | base64 -d > ${destinationPath}`);
console.log("Valid keybox copied successfully.");
showPrompt("Successfully updated with valid keybox.");
} catch (error) {
console.error("Failed to copy valid keybox:", error);
await aospkb();
showPrompt("No valid keybox found, replaced with AOSP keybox.", false);
}
}
// Function to show the prompt with a success or error message
@@ -265,7 +300,7 @@ function setupMenuToggle() {
}
});
const closeMenuItems = ['refresh', 'select-all', 'deselect-all', 'select-denylist', 'deselect-xposed'];
const closeMenuItems = ['refresh', 'select-all', 'deselect-all', 'select-denylist', 'deselect-unnecessary', 'aospkb', 'extrakb'];
closeMenuItems.forEach(id => {
const item = document.getElementById(id);
if (item) {
@@ -389,10 +424,12 @@ document.addEventListener('DOMContentLoaded', async () => {
document.getElementById("select-all").addEventListener("click", selectAllApps);
document.getElementById("deselect-all").addEventListener("click", deselectAllApps);
document.getElementById("select-denylist").addEventListener("click", selectDenylistApps);
document.getElementById("deselect-xposed").addEventListener("click", deselectXposedApps);
document.getElementById("deselect-unnecessary").addEventListener("click", deselectUnnecessaryApps);
document.getElementById("aospkb").addEventListener("click", aospkb);
document.getElementById("extrakb").addEventListener("click", extrakb);
await fetchAppList();
checkMagisk();
runXposedScript();
runExtraScript();
loadingIndicator.style.display = "none";
});