From 981b28894b350b3da7417795e092420ca1ce42c2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 23:42:09 +0000 Subject: [PATCH] refactor(install): optimize cache cleaning and harden checks Co-authored-by: tryigit <40565628+tryigit@users.noreply.github.com> --- .Jules/finisher.md | 8 ++++ Magisk Template/customize.sh | 13 ++++-- Magisk Template/module.prop | 4 +- tests/verify.sh | 86 ++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 .Jules/finisher.md create mode 100755 tests/verify.sh diff --git a/.Jules/finisher.md b/.Jules/finisher.md new file mode 100644 index 0000000..2527af0 --- /dev/null +++ b/.Jules/finisher.md @@ -0,0 +1,8 @@ +# Jules Finisher Learning Journal + +Use this file to document critical learnings, recurring bugs, or architectural constraints for future agents. + +Format: +YYYY-MM-DD - [Title] +Learning: ... +Action: ... diff --git a/Magisk Template/customize.sh b/Magisk Template/customize.sh index e69e472..736a0b3 100644 --- a/Magisk Template/customize.sh +++ b/Magisk Template/customize.sh @@ -41,8 +41,10 @@ else fi ui_print " - Android Version Check..." -if [ $(getprop ro.system.build.version.sdk) -lt 31 ]; then - ui_print "! Unsupported Android version detected, please upgrade." +API=$(getprop ro.system.build.version.sdk) +: ${API:=0} +if [ "$API" -lt 31 ]; then + ui_print "! Unsupported Android version detected ($API), please upgrade." abort else ui_print " - Success 🌍" @@ -94,8 +96,11 @@ ui_print " - Please wait..." gpu_cache_cleaner() { if [ $# -gt 0 ]; then # Remove shader cache directories and GPU cache files - find "$@" \( -type d -name '*shader_cache*' -prune -exec rm -rf {} \; \) -o \ - \( -type f \( -name '*shader*' -o -name '*gpu_cache*' \) -exec rm -f {} \; \) 2>/dev/null || true + find "$@" \( \ + -type d \( -name '*shader_cache*' -o -name '*gpu_cache*' \) -prune -exec rm -rf {} + \ + \) -o \( \ + -type f \( -name '*shader*' -o -name '*gpu_cache*' \) -exec rm -f {} + \ + \) 2>/dev/null || true for path in "$@"; do if [ -d "$path" ]; then diff --git a/Magisk Template/module.prop b/Magisk Template/module.prop index adf935f..a534647 100644 --- a/Magisk Template/module.prop +++ b/Magisk Template/module.prop @@ -1,6 +1,6 @@ id=gpu_driver_free name=Adreno Gpu Driver -version=v1.0.3 -versionCode=103 +version=v1.0.4 +versionCode=104 author=tryigitx description=Open-Source Adreno {Version} Driver | Dump By {@urname} diff --git a/tests/verify.sh b/tests/verify.sh new file mode 100755 index 0000000..1f50421 --- /dev/null +++ b/tests/verify.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Cleanup trap +cleanup() { + rm -rf "$MODPATH" "$MOCK_DATA" +} +trap cleanup EXIT + +# Mock Magisk environment variables +export MODPATH="./mock_modpath" +mkdir -p "$MODPATH" +cp -r "Magisk Template"/* "$MODPATH/" + +# Mock Android filesystem for cache cleaner test +MOCK_DATA="./mock_data" +rm -rf "$MOCK_DATA" +mkdir -p "$MOCK_DATA/user/0/com.example.app/cache/shader_cache" +mkdir -p "$MOCK_DATA/user/0/com.example.app/cache/gpu_cache" +touch "$MOCK_DATA/user/0/com.example.app/cache/shader_cache/some_file" +touch "$MOCK_DATA/user/0/com.example.app/cache/gpu_cache/some_file_named_gpu_cache" +mkdir -p "$MOCK_DATA/data/com.another.app/code_cache" + +# Mock functions +ui_print() { + echo "[UI_PRINT] $@" +} + +abort() { + echo "[ABORT] Script aborted!" + exit 1 +} + +set_perm_recursive() { + echo "[SET_PERM] $@" +} + +getprop() { + case "$1" in + ro.soc.model) echo "SM8450" ;; + ro.build.host) echo "xiaomi.eu" ;; + pm.dexopt.first-use) echo "false" ;; + ro.system.build.version.sdk) echo "33" ;; # Android 13 + *) echo "" ;; + esac +} + +# Export functions so they are available in subshells if needed (not really needed for source) +export -f ui_print abort set_perm_recursive getprop + +# Run the script +echo "Running customize.sh..." +# We source it because that's how Magisk runs it usually, but here we can just execute it if we handle the sourcing +# The script is designed to be sourced by update-binary usually, but standalone execution is fine for testing logic if we provide the environment. +# However, `customize.sh` uses `find` on paths passed to `gpu_cache_cleaner`. +# We need to modify the call to `gpu_cache_cleaner` in the script or mock the paths it uses. +# The script calls: `gpu_cache_cleaner "/data/data" "/data/user_de" "/data/user"` +# We can't easily change the arguments in the sourced script without editing it. +# So we will create a wrapper or use `sed` to replace the paths with our mock paths for testing. + +# Replace paths in customize.sh for testing +sed -i "s|/data/data|\"$MOCK_DATA/data\"|g" "$MODPATH/customize.sh" +sed -i "s|/data/user_de|\"$MOCK_DATA/user_de\"|g" "$MODPATH/customize.sh" +sed -i "s|/data/user|\"$MOCK_DATA/user\"|g" "$MODPATH/customize.sh" + +# Source the script +. "$MODPATH/customize.sh" + +# Verify deletions +RET=0 +if [ -d "$MOCK_DATA/user/0/com.example.app/cache/shader_cache" ]; then + echo "FAIL: shader_cache directory was not removed" + RET=1 +else + echo "PASS: shader_cache directory removed" +fi + +if [ -d "$MOCK_DATA/user/0/com.example.app/cache/gpu_cache" ]; then + echo "FAIL: gpu_cache directory was not removed" + RET=1 +else + echo "PASS: gpu_cache directory removed" +fi + +exit $RET + +# Clean up handled by trap or earlier