fix: handle condition when app name contain newline charater

This commit is contained in:
KOWX712
2025-07-06 02:24:20 +08:00
parent 311124f3cf
commit 023af806b1
2 changed files with 6 additions and 6 deletions

View File

@@ -108,12 +108,12 @@ echo "# This file is generated from service.sh to speed up load time" > "$OUTPUT
# Get list of third party apps and specific system apps, then cache app name
# Check Xposed module
{
pm list packages -3 | awk -F: '{print $2}' 2>/dev/null
pm list packages -s | awk -F: '{print $2}' | grep -Ex "$SYSTEM_APP" 2>/dev/null || true
pm list packages -3 </dev/null 2>&1 | cat | awk -F: '{print $2}' 2>/dev/null
pm list packages -s </dev/null 2>&1 | cat | awk -F: '{print $2}' | grep -Ex "$SYSTEM_APP" 2>/dev/null || true
} | while read -r PACKAGE; do
# Get APK path for the package
APK_PATH=$(pm path "$PACKAGE" 2>/dev/null | head -n1 | awk -F: '{print $2}')
APP_NAME=$(aapt dump badging "$APK_PATH" 2>/dev/null | grep "application-label:" | sed "s/application-label://g; s/'//g")
APP_NAME=$(aapt dump badging "$APK_PATH" 2>/dev/null | grep "application-label:" | sed "s/application-label://g; s/'//g" | tr -d '\n')
[ -z "$APP_NAME" ] && APP_NAME="$PACKAGE"
echo " {\"app_name\": \"$APP_NAME\", \"package_name\": \"$PACKAGE\"}," >> "$OUTPUT_APP"