chahinebrini 63fae25531 fix(android-protection): explicit specialUse FGS type — Samsung/Android 16 crash loop
RebreakVpnService.onStartCommand crashed with SecurityException because Android 16's validateForegroundServiceType rejects the implicit 2-arg startForeground(). Now passes FOREGROUND_SERVICE_TYPE_SPECIAL_USE explicitly (Google's documented best practice) and guards the call so a failed foreground promotion stops the service cleanly instead of crashing the app. Verified vs reported Galaxy A54 / Android 16 signature (97% of crash events, 1-user crash loop).

Bundles pending working-tree work across native/marketing/locales/mac + graphify-out rebuild. gitignore: google-services.json + /screenshots/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 22:33:28 +02:00

113 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# clean.sh — systematisches Reclaiming von Dev-Caches (macOS).
#
# Problem: lokale Builds + globale Toolchain-Caches (Gradle, Xcode DerivedData,
# iOS-Simulatoren) wuchern bis die Platte voll ist und Builds/Emulator failen
# ("not enough disk space"). deploy.sh räumt nur die PROJEKT-Build-Dirs;
# globale Caches verwaltet sonst niemand. Dieses Script schließt die Lücke.
#
# Tiers:
# (default) project: android/build, android/app/build, android/.gradle, ios/build
# + Xcode DerivedData (komplett) + nicht-verfügbare iOS-Sims.
# Alles regeneriert sich beim nächsten Build (kein Daten-Verlust).
# --deep zusätzlich: globaler Gradle-Cache (~/.gradle/caches) + ios/Pods.
# Frei mehr Platz, aber der NÄCHSTE Build lädt Deps/Pods neu (langsamer).
# --check nur Diagnose (df + Top-Verbraucher), löscht nichts.
#
# Nutzung:
# ./clean.sh # sicheres Reclaiming
# ./clean.sh --deep # aggressiv (global gradle + pods)
# ./clean.sh --check # nur anschauen
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ANDROID_DIR="$SCRIPT_DIR/android"
IOS_DIR="$SCRIPT_DIR/ios"
MODE="safe"
GUARD_GB="${2:-8}"
case "${1:-}" in
--deep) MODE="deep" ;;
--check) MODE="check" ;;
--guard) MODE="guard" ;;
"" ) MODE="safe" ;;
*) echo "Unbekannte Option: $1 (erlaubt: --deep, --check, --guard [GB])"; exit 1 ;;
esac
free_gb() { df -g / 2>/dev/null | awk 'NR==2 {print $4}'; }
human() { du -sh "$1" 2>/dev/null | awk '{print $1}'; }
# --guard [GB]: stiller Pre-Build-Check. Warnt nur, wenn frei < Schwelle (8G).
# Wird von dev.sh/deploy.sh vor dem Build aufgerufen — bricht NIE ab (exit 0).
if [ "$MODE" = "guard" ]; then
FREE="$(free_gb)"
if [ "${FREE:-99}" -lt "$GUARD_GB" ]; then
echo "⚠️ Nur ${FREE}G frei (< ${GUARD_GB}G) — Build/Emulator könnte an Speicher scheitern."
echo " Aufräumen: ./clean.sh (mehr: ./clean.sh --deep)"
fi
exit 0
fi
echo "── Disk-Status ────────────────────────────────────────────"
df -h / | sed -n '1p;2p'
BEFORE_GB="$(free_gb)"
echo
report_targets() {
echo "Top-Verbraucher (Dev-Caches):"
for d in "$ANDROID_DIR/app/build" "$ANDROID_DIR/build" "$ANDROID_DIR/.gradle" \
"$IOS_DIR/build" "$IOS_DIR/Pods" "$HOME/.gradle/caches" \
"$HOME/Library/Developer/Xcode/DerivedData" \
"$HOME/Library/Developer/CoreSimulator"; do
[ -e "$d" ] && printf " %-60s %s\n" "$d" "$(human "$d")"
done
}
if [ "$MODE" = "check" ]; then
report_targets
echo; echo "free: ${BEFORE_GB}G — (nur Diagnose, nichts gelöscht)"
exit 0
fi
report_targets
echo
# Gradle-Daemon stoppen, sonst sind android/build & .gradle gelockt.
echo "→ Gradle-Daemon stoppen…"
( cd "$ANDROID_DIR" 2>/dev/null && ./gradlew --stop >/dev/null 2>&1 ) || true
pkill -f "GradleDaemon" 2>/dev/null || true
rmrf() { [ -e "$1" ] && { echo " rm $1 ($(human "$1"))"; rm -rf "$1"; } || true; }
echo "→ Projekt-Build-Artefakte…"
rmrf "$ANDROID_DIR/app/build"
rmrf "$ANDROID_DIR/build"
rmrf "$ANDROID_DIR/.gradle"
rmrf "$IOS_DIR/build"
echo "→ Xcode DerivedData…"
rmrf "$HOME/Library/Developer/Xcode/DerivedData"
echo "→ nicht-verfügbare iOS-Simulatoren…"
xcrun simctl delete unavailable >/dev/null 2>&1 || true
if [ "$MODE" = "deep" ]; then
echo "→ [deep] globaler Gradle-Cache (~/.gradle/caches)…"
rmrf "$HOME/.gradle/caches"
echo "→ [deep] ios/Pods (pod install nötig danach)…"
rmrf "$IOS_DIR/Pods"
fi
echo
echo "── Ergebnis ───────────────────────────────────────────────"
df -h / | sed -n '2p'
AFTER_GB="$(free_gb)"
echo "frei vorher: ${BEFORE_GB}G → nachher: ${AFTER_GB}G (≈ $((AFTER_GB - BEFORE_GB))G zurückgewonnen)"
echo
echo "Hinweis: nächster Android-Build ist langsamer (Caches regenerieren)."
if [ "$MODE" = "deep" ]; then
echo " iOS braucht 'pod install' (ios/Pods gelöscht)."
fi
exit 0