Skip to content

Commit

Permalink
Fix x86_64 Android AVD in Windows (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Dec 3, 2024
1 parent b75d209 commit 0d3b1ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
36 changes: 34 additions & 2 deletions scripts/start_avd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,37 @@ if (-not $AVD_FOUND) {
}

# Start the emulator with user-defined AVD and port
Start-Process -FilePath $EMULATOR_PATH -ArgumentList "-avd $AVD_NAME -writable-system -no-snapshot -wipe-data -port $START_PORT"
Write-Output "Emulator started with AVD $AVD_NAME on port $START_PORT."
Start-Process -NoNewWindow -FilePath $EMULATOR_PATH -ArgumentList "-avd $AVD_NAME -writable-system -no-snapshot -wipe-data -port $START_PORT"
Write-Output "Starting AVD $AVD_NAME on port $START_PORT."

# Wait for the emulator to boot completely
Write-Output "Waiting for emulator to boot..."
& $ADB_PATH wait-for-device
Start-Sleep -Seconds 5
Write-Output "Emulator booted successfully."

# Allow /system remount
Write-Output "Restarting adb as root..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "root"

Write-Output "Disabling AVB verification..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "shell avbctl disable-verification"

Write-Output "Disabling verity..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "disable-verity"

Write-Output "Restarting emulator..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "reboot"

Write-Output "Waiting for emulator to reboot..."
& $ADB_PATH wait-for-device
Start-Sleep -Seconds 5
Write-Output "Emulator rebooted successfully."

Write-Output "Restarting adb as root..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "root"

Write-Output "Remounting the filesystem..."
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "remount"

Write-Output "Emulator ready for Dynamic Analysis with MobSF."
6 changes: 4 additions & 2 deletions scripts/start_avd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ done

# Start the emulator with user-defined AVD and port
"$EMULATOR_PATH" -avd "$AVD_NAME" -writable-system -no-snapshot -wipe-data -port "$START_PORT" >/dev/null 2>&1 &
echo "$(tput setaf 2)Emulator AVD $AVD_NAME started on port $START_PORT$(tput sgr0)"
echo "$(tput setaf 2)Starting AVD $AVD_NAME on port $START_PORT$(tput sgr0)"
echo "Waiting for emulator to boot..."
"$ADB_PATH" wait-for-device

# Check if socat is available only on Linux
if [ "$(uname)" = "Linux" ]; then
Expand Down Expand Up @@ -124,7 +126,7 @@ if [ -n "$GAPPS_ZIP" ]; then
tar -x --strip-components 2 -f $f -C $PLAY_EXTRACT_DIR || { echo "$(tput setaf 1)Error: Extraction failed$(tput sgr0)"; exit 1; }
done

echo "Waiting for emulator to complete booting..."
echo "Waiting for the emulator to be ready..."
sleep 25
echo "Installing PlayStore components"
"$ADB_PATH" root
Expand Down

0 comments on commit 0d3b1ec

Please sign in to comment.