Skip to content

Instantly share code, notes, and snippets.

@Esl1h
Last active September 9, 2025 13:27
Show Gist options
  • Select an option

  • Save Esl1h/dd9c1b82bee79e52a27fc346519ee85d to your computer and use it in GitHub Desktop.

Select an option

Save Esl1h/dd9c1b82bee79e52a27fc346519ee85d to your computer and use it in GitHub Desktop.

Revisions

  1. Esl1h revised this gist Sep 9, 2025. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions adb-remove-packages.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/bin/bash

    # Used to turn ann old smartphone into a DAP (Digital Audio Player)
    # https://esli.blog.br/transformando-antigo-smartphone-em-dap

    set +e
    export ANDROID_SERIAL=ZF523242ZG # 'adb devices' command to find your device
    LIST=packages-remove.txt
  2. Esl1h revised this gist Sep 8, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion adb-remove-packages.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ for pkg in "${packages[@]}"; do

    # Check if it exists
    if adb shell pm list packages 2>/dev/null | grep -q "package:$pkg$"; then
    echo " -> Encontrado"
    echo " -> Found"

    # Try to remove
    if adb shell pm uninstall --user 0 "$pkg" >/dev/null 2>&1; then
  3. Esl1h created this gist Sep 8, 2025.
    51 changes: 51 additions & 0 deletions adb-remove-packages.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    #!/bin/bash

    set +e
    export ANDROID_SERIAL=ZF523242ZG # 'adb devices' command to find your device
    LIST=packages-remove.txt

    echo "Loading package list..."

    # Load all lines into an array (avoids stdin issues)
    readarray -t packages < "$LIST"

    echo "Total of ${#packages[@]} packages loaded"

    processed=0
    success=0
    failed=0

    for pkg in "${packages[@]}"; do
    # Limpa a linha
    pkg=$(echo "$pkg" | tr -d '\r\n' | xargs)
    [[ -z "$pkg" || "$pkg" =~ ^[[:space:]]*# ]] && continue

    ((processed++))
    echo "[$processed/${#packages[@]}] $pkg"

    # Check if it exists
    if adb shell pm list packages 2>/dev/null | grep -q "package:$pkg$"; then
    echo " -> Encontrado"

    # Try to remove
    if adb shell pm uninstall --user 0 "$pkg" >/dev/null 2>&1; then
    echo " -> ✓ Removed"
    ((success++))
    else
    # Try to disable
    if adb shell pm disable-user --user 0 "$pkg" >/dev/null 2>&1; then
    echo " -> ✓ Disabled"
    ((success++))
    else
    echo " -> ✗ Failed"
    ((failed++))
    fi
    fi
    else
    echo " -> Not found"
    ((failed++))
    fi
    done

    echo ""
    echo "Processed: $processed | Successes: $success | Failures: $failed"