#!/bin/bash
# install_apks.sh
# 批量安装当前目录下的所有APK

echo "Searching for APK files in current directory..."

APK_COUNT=0
SUCCESS_COUNT=0
FAIL_COUNT=0

for apk in *.apk; do
    if [ -f "$apk" ]; then
        APK_COUNT=$((APK_COUNT + 1))
        echo ""
        echo "[$APK_COUNT] Installing $apk..."
        
        adb install -r "$apk"
        
        if [ $? -eq 0 ]; then
            echo "✓ Successfully installed $apk"
            SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
        else
            echo "✗ Failed to install $apk"
            FAIL_COUNT=$((FAIL_COUNT + 1))
        fi
    fi
done

echo ""
echo "========================================="
echo "Summary:"
echo "  Total APKs: $APK_COUNT"
echo "  Success: $SUCCESS_COUNT"
echo "  Failed: $FAIL_COUNT"
echo "========================================="
