mirror of
https://github.com/okhsunrog/vpnhide.git
synced 2026-04-28 14:44:43 +00:00
Dashboard as new landing screen with module status cards (kmod, zygisk, LSPosed), aggregated protection checks (native + Java API), and issue alerts. Uses sealed types for type-safe state modeling (invalid states are unrepresentable). Three separate target lists: kmod, zygisk, and lsposed each have independent targets.txt. Users can configure per-app which layers protect it (L/K/Z chips in app picker). Service.sh scripts decoupled — each resolves only its own component, with migration from unified lists. HookEntry writes /data/system/vpnhide_hook_active with version and boot_id so the app can detect if LSPosed hooks are active this boot. VPN Hide app auto-adds itself to all target lists for self-diagnostics. If just added, shows "restart needed" instead of stale check results. App hides itself from the app picker and target counts. Diagnostics tab no longer runs checks without VPN — shows banner only. Removed "Run All" button (results are cached per process lifetime). Splash screen follows system dark/light theme via Material3 DayNight.
84 lines
2.8 KiB
Bash
84 lines
2.8 KiB
Bash
#!/system/bin/sh
|
|
# Resolves package names → UIDs for kmod and lsposed at boot.
|
|
# kmod targets → /proc/vpnhide_targets
|
|
# lsposed targets → /data/system/vpnhide_uids.txt
|
|
|
|
KMOD_TARGETS="/data/adb/vpnhide_kmod/targets.txt"
|
|
LSPOSED_TARGETS="/data/adb/vpnhide_lsposed/targets.txt"
|
|
PROC_TARGETS="/proc/vpnhide_targets"
|
|
SS_UIDS_FILE="/data/system/vpnhide_uids.txt"
|
|
|
|
# Wait for the proc entry (kernel module must be loaded)
|
|
for i in 1 2 3 4 5 6 7 8 9 10; do
|
|
[ -f "$PROC_TARGETS" ] && break
|
|
sleep 1
|
|
done
|
|
|
|
# Wait for PackageManager to be ready
|
|
for i in $(seq 1 30); do
|
|
pm list packages >/dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
|
|
if [ ! -f "$PROC_TARGETS" ]; then
|
|
log -t vpnhide "kernel module not loaded, skipping kmod UID resolution"
|
|
fi
|
|
|
|
# Migration: if lsposed targets don't exist yet, seed from kmod targets
|
|
if [ ! -f "$LSPOSED_TARGETS" ] && [ -f "$KMOD_TARGETS" ]; then
|
|
cp "$KMOD_TARGETS" "$LSPOSED_TARGETS"
|
|
log -t vpnhide "migrated kmod targets to lsposed targets"
|
|
fi
|
|
|
|
# Get all packages with UIDs in one call
|
|
ALL_PACKAGES="$(pm list packages -U 2>/dev/null)"
|
|
|
|
# resolve_uids <targets_file> — prints resolved UIDs to stdout
|
|
resolve_uids() {
|
|
local targets_file="$1"
|
|
[ -f "$targets_file" ] || return
|
|
local uids=""
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
pkg="$(echo "$line" | tr -d '[:space:]')"
|
|
[ -z "$pkg" ] && continue
|
|
case "$pkg" in \#*) continue ;; esac
|
|
uid="$(echo "$ALL_PACKAGES" | grep "^package:${pkg} " | sed 's/.*uid://')"
|
|
if [ -n "$uid" ]; then
|
|
if [ -z "$uids" ]; then uids="$uid"; else uids="${uids}
|
|
${uid}"; fi
|
|
else
|
|
log -t vpnhide "package not found: $pkg"
|
|
fi
|
|
done < "$targets_file"
|
|
[ -n "$uids" ] && echo "$uids"
|
|
}
|
|
|
|
# Resolve kmod targets → /proc/vpnhide_targets
|
|
if [ -f "$PROC_TARGETS" ] && [ -f "$KMOD_TARGETS" ]; then
|
|
KMOD_UIDS="$(resolve_uids "$KMOD_TARGETS")"
|
|
if [ -n "$KMOD_UIDS" ]; then
|
|
echo "$KMOD_UIDS" > "$PROC_TARGETS"
|
|
count="$(echo "$KMOD_UIDS" | wc -l)"
|
|
log -t vpnhide "kmod: loaded $count target UIDs"
|
|
else
|
|
log -t vpnhide "kmod: no UIDs resolved"
|
|
fi
|
|
fi
|
|
|
|
# Resolve lsposed targets → /data/system/vpnhide_uids.txt
|
|
# Create persist dir if needed (for first-time installs)
|
|
mkdir -p /data/adb/vpnhide_lsposed 2>/dev/null
|
|
if [ -f "$LSPOSED_TARGETS" ]; then
|
|
LSPOSED_UIDS="$(resolve_uids "$LSPOSED_TARGETS")"
|
|
if [ -n "$LSPOSED_UIDS" ]; then
|
|
echo "$LSPOSED_UIDS" > "$SS_UIDS_FILE"
|
|
chmod 644 "$SS_UIDS_FILE"
|
|
chcon u:object_r:system_data_file:s0 "$SS_UIDS_FILE" 2>/dev/null
|
|
count="$(echo "$LSPOSED_UIDS" | wc -l)"
|
|
log -t vpnhide "lsposed: wrote $count UIDs to $SS_UIDS_FILE"
|
|
else
|
|
echo > "$SS_UIDS_FILE"
|
|
chmod 644 "$SS_UIDS_FILE"
|
|
log -t vpnhide "lsposed: no UIDs resolved"
|
|
fi
|
|
fi
|